You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm that your issue is a genuine bug in the targets package itself and not a user error, known limitation, or issue from another package that targets depends on. For example, if you get errors running tar_make_clustermq(), try isolating the problem in a reproducible example that runs clustermq and not targets. And for miscellaneous troubleshooting, please post to discussions instead of issues.
If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
When I wrap tar_make(callr_function = NULL) with callr::r code changes in source files affecting targets are not detected.
If I remove the callr::r wrapping changes are detected.
If I make a change in the plan script file, correct (modified) source code is used.
Background: I was doing this as per @noamross's suggestion in the rOpensci #pipelinetoolkits slack channel. The idea is you have an outer iteration that allows you to inject different parameters into the same plan being run several times against different stores.
The second time tar_read(result, store = script_store) is called it should return the result 3, following the change in result_fn written to the function source file.
Instead we don't see this result until the third time, when the plan script is modified.
It's because source() is somehow assigning the function to the wrong environment. It will work if you run eval(parse(text = readLines(script_file), envir = tar_option_get("envir")) (or use tar_source(), which I added today.) I don't consider this a bug because callr_function = NULL is only for debugging purposes (and in some cases, tests) and is likely to break in similar environment-related ways in practice. I know you are looking for a way to insert options and environment variables from the session, and I would recommend a workaround that respects the R session encapsulation that targets is trying to enforce. Maybe programmatically writing to _targets.R or implementing something that depends on the project/_targets.yaml.
Ahhh thanks Will. I know there's that gotcha where source always assigns the function in the top level environment maybe that's part of it, although I would have thought that would work in this case.
Prework
targets
package itself and not a user error, known limitation, or issue from another package thattargets
depends on. For example, if you get errors runningtar_make_clustermq()
, try isolating the problem in a reproducible example that runsclustermq
and nottargets
. And for miscellaneous troubleshooting, please post to discussions instead of issues.targets::tar_reprex()
,reprex::reprex()
, or similar, post a minimal reproducible example like this one so the maintainer can troubleshoot the problems you identify. A reproducible example is:Description
When I wrap
tar_make(callr_function = NULL)
withcallr::r
code changes in source files affecting targets are not detected.If I remove the
callr::r
wrapping changes are detected.If I make a change in the plan script file, correct (modified) source code is used.
Background: I was doing this as per @noamross's suggestion in the rOpensci #pipelinetoolkits slack channel. The idea is you have an outer iteration that allows you to inject different parameters into the same plan being run several times against different stores.
Reproducible example
targets::tar_reprex()
,reprex::reprex()
, or similar, post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:Applogies if this is not minimal I wanted you to know what I know about this problem:
Created on 2022-08-03 by the reprex package (v2.0.1)
Expected result
The second time
tar_read(result, store = script_store)
is called it should return the result 3, following the change inresult_fn
written to the function source file.Instead we don't see this result until the third time, when the plan script is modified.
Diagnostic information
sessionInfo()
orreprex(si = TRUE)
.traceback()
orrlang::trace_back()
.targets
currently installed.packageDescription("targets")$GithubSHA1
shows you this.The text was updated successfully, but these errors were encountered: