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 with cogmapr package #3

Closed
krlmlr opened this issue Apr 18, 2024 · 6 comments · Fixed by #5
Closed

Error with cogmapr package #3

krlmlr opened this issue Apr 18, 2024 · 6 comments · Fixed by #5
Assignees

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Apr 18, 2024

project_name <- "a_new_project"
main_path <- paste0(system.file("testdata", package = "cogmapr"), "/")
my.project <- cogmapr::ProjectCMap(main_path, project_name)
cogmapr::RelationshipTest(my.project, units = c("Belgium", "Québec"))
#> Error in eval(call_to_original, new_caller_env): '...' used in an incorrect context

Created on 2024-04-18 with reprex v2.1.0

Other packages work without error. I'll keep trying.

@moodymudskipper
Copy link
Collaborator

Maybe it's non related, but I see in the trace that collector is called twice, which I tried to avoid, so this should be locked into as well :

traceback()
16: eval(call_to_original, new_caller_env)
15: eval(call_to_original, new_caller_env) at collector.R#116
14: collector::collect_and_run()
13: FUN(X[[i]], ...)
12: lapply(.x, .f, ...) at import-standalone-purrr.R#38
11: map(indices, dplyr_row_slice, data = data) at group-split.R#103
10: dplyr_chop(out, indices) at group-split.R#99
9: group_split_impl(.tbl, .keep = .keep) at group-split.R#85
8: group_split.grouped_df(.) at group-split.R#46
7: (function (.tbl, ..., .keep = TRUE) 
   {
       lifecycle::signal_stage("experimental", "group_split()")
       UseMethod("group_split")
   })(.)
6: eval(call_to_original, new_caller_env)
5: eval(call_to_original, new_caller_env) at collector.R#116
4: collector::collect_and_run()
3: dplyr::group_split(.)
2: df %>% dplyr::group_by(edge) %>% dplyr::filter(edge %in% comparable.edges) %>% 
       dplyr::group_split()
1: cogmapr::RelationshipTest(my.project, units = c("Belgium", "Québec"))

@moodymudskipper
Copy link
Collaborator

No, that's fine, we have in the package :

df %>% dplyr::group_by(edge) %>% dplyr::filter(edge %in% comparable.edges) %>% dplyr::group_split()

These calls are all dplyr calls on the same stack but called from the other package's ns so we do want to record them all

@moodymudskipper
Copy link
Collaborator

We can reproduce outside of the package, group_split always fails:

iris |> 
  group_by(Species) |> 
  group_split()
#> Error in eval(call_to_original, new_caller_env) : 
#>  '...' used in an incorrect context

@moodymudskipper
Copy link
Collaborator

That's something with lapply(...),

lapply(list(cars), mutate, a = 1)
#> Error in eval(call_to_original, new_caller_env) : 
#>  '...' used in an incorrect context

@moodymudskipper
Copy link
Collaborator

Well, just the dots in fact :

fun <- function(...) {
  mutate(cars, ...)
}
fun(a = 1)
#> Error in eval(call_to_original, new_caller_env) : 
#>  '...' used in an incorrect context

@moodymudskipper
Copy link
Collaborator

The code tried to make a lazy binding out of ..., R didn't like that, If we don't try to set is as a lazy binding it removes the failure (still have to check if the value retrieval works ok).

What it means however is that we would always serialize ... even if it's not used. I think it's ok because the dots take trivial space, they just point to bindings we keep the values from only if they're used.

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

Successfully merging a pull request may close this issue.

2 participants