Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in yaml::yaml.load(i): Parser error #49

Open
vgherard opened this issue Jul 16, 2021 · 4 comments
Open

Error in yaml::yaml.load(i): Parser error #49

vgherard opened this issue Jul 16, 2021 · 4 comments

Comments

@vgherard
Copy link

Here I'm trying autotest::autotest_package() on kgrams (I'm using here the CRAN version for ease of reproducibility). It looks like it is failing to convert some of my examples to YAML, but the errors are somewhat cryptic. Might these be due to the fact that some of my examples contain infix operators (e.g. %|%)? I recall having some problems also with pkgdown for this reason.

I will try to jump into the debugger to catch the culprit example(s?). Meanwhile, any idea on this?

Thanks,
Valerio

autotest::autotest_package(package = "kgrams")
#> ٭ Extracting example code from 14 .Rd files
#>   |                                                                              |                                                                      |   0%  |                                                                              |=====                                                                 |   7%  |                                                                              |==========                                                            |  14%  |                                                                              |===============                                                       |  21%  |                                                                              |====================                                                  |  29%  |                                                                              |=========================                                             |  36%  |                                                                              |==============================                                        |  43%  |                                                                              |===================================                                   |  50%  |                                                                              |========================================                              |  57%  |                                                                              |=============================================                         |  64%
#> Error in qstart[i]:qend[i]: Argomento NA/NaN
autotest::autotest_package(package = "kgrams", exclude = "preprocess")
#> ٭ Extracting example code from 13 .Rd files
#>   |                                                                              |                                                                      |   0%  |                                                                              |=====                                                                 |   8%  |                                                                              |===========                                                           |  15%  |                                                                              |================                                                      |  23%  |                                                                              |======================                                                |  31%  |                                                                              |===========================                                           |  38%  |                                                                              |================================                                      |  46%  |                                                                              |======================================                                |  54%  |                                                                              |===========================================                           |  62%  |                                                                              |================================================                      |  69%  |                                                                              |======================================================                |  77%  |                                                                              |===========================================================           |  85%  |                                                                              |=================================================================     |  92%  |                                                                              |======================================================================| 100%
#> ✓ Extracted example code
#> ٭ Converting 10 examples to yaml
#>   |                                                                              |                                                                      |   0%  |                                                                              |=======                                                               |  10%  |                                                                              |==============                                                        |  20%  |                                                                              |=====================                                                 |  30%  |                                                                              |============================                                          |  40%  |                                                                              |===================================                                   |  50%  |                                                                              |==========================================                            |  60%
#> Error in yaml::yaml.load(i): Parser error: while parsing a block mapping at line 6, column 7 did not find expected key at line 9, column 9

Created on 2021-07-16 by the reprex package (v2.0.0)

@vgherard
Copy link
Author

In the first call, autotest::autotest_package(package = "kgrams"), the error occurs in autotest:::get_fn_exs(), which gets called from autotest::examples_to_yaml() with the following arguments:

library(kgrams)
        

package <- "kgrams"
rdname <- "preprocess"
topic <- "preprocess"
is_source <- FALSE


autotest:::get_fn_exs(package, rdname, topic, is_source)
#> Error in qstart[i]:qend[i]: Argomento NA/NaN

Created on 2021-07-16 by the reprex package (v2.0.0)

If you jump in the debugger and see how the code of the first example is preprocessed, you will notice that the output after preprocessing is invalid R code.

Hope this helps

@mpadge
Copy link
Member

mpadge commented Jul 16, 2021

@vgherard Thanks for this one - this particular 🐛 is definitely internal to autotest, and not to kmeans. As mentioned in #48, the entire procedure to identify input types is going to be restructured to avoid current hand-parsing of example code. The bunch of commits above partially address the bugs this revealed, but a real solution won't really be possible until the restructure. Those commits get us up to encountering the %|% symbol which indeed crashes everything here, and is unable to be resolved with autotest designed as it current is. Examples are all converted to yaml form, and parsing characters like that requires hand re-coding for each new one encountered, which is obviously not sustainable. The re-design will avoid the need for manual parsing, for which this package will provide a great test case, so thanks! I'll leave this issue open, and you'll hopefully see results here.

I'll leave this issue open, and use this package as a test cast for the re-design. Thanks!

@vgherard
Copy link
Author

Thank you @mpadge, looking forward for the next version then 😃. If I can help in any way, let me know!

@mpadge
Copy link
Member

mpadge commented Aug 17, 2022

Hi @vgherard, just letting you know that I'm finally get back to these issues, if you're still interested. I'll leave both this one and #48 open to test the new approach with once it gets that far. Sorry for any inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants