Replies: 3 comments 1 reply
-
Nice summary, thanks! IIUC, remote workers never access the source code but need everything gift-wrapped so that they can just run it? That was new to me. Let's find a way to make it work, then! |
Beta Was this translation helpful? Give feedback.
-
This is a very exciting idea. I frequently bring up a targets project for data exploration and wish I could
|
Beta Was this translation helpful? Give feedback.
-
Hi, I'm still learning, therefore I cannot offer any solutions regarding the topic at hand. However, it made me think of something. During package development,
I looked up the examples of Targetopia packages as well as dicussions, without a clue. I have a feeling that a wrapper like Let me know if this is off-topic and would require its own thread (with more details, reprex etc), I do not want to pollute this discussion but merely showing interest and bringing another angle. BEst, |
Beta Was this translation helpful? Give feedback.
-
Help
Description
@krlmlr, we have been emailing about compatibility between
targets
andpkgload::load_all()
. I posted this discussion to make it easier to share code.Let's say we have a package with this
DESCRIPTION
file:and this
R/functions.R
file:If we were to pursue integration with
load_all()
, I believe we should use a wrapper function around existing functionality for installed packages: https://books.ropensci.org/targets/packages.html#r-packages-as-projects. The wrapper I propose istar_load_all()
defined below, which sets theenvir
,imports
, andpackages
options so that the pipeline uses the package namespace instead of the global environment. Here is the_targets.R
file:When I inspect and run the pipeline locally, everything seems to work.
However, when the target runs in a
crew
worker, the functions in the namespace are missing.The reason this happens is that
targets
is treatingtar_option_get("envir")
as a simple environment when it exports data to parallel workers:targets/R/class_crew.R
Lines 104 to 167 in 8ab4319
In other words, the
envir
argument passed totargets::target_run_worker()
is pretty much justpkgload::pkg_ns()
, and somehow it becomes empty when sent to a worker.I can isolate this behavior in a much simpler example using
callr
from the root of the package file system:If you know of a better way of marshaling package namespaces in a way that works with
pkgload::load_all()
and does not conflict with non-package environments, then maybetar_load_all()
could become part oftargets
for people who wantpkgload::load_all()
-like behavior. Otherwise, I am not sure how to make this work for a package that is not actually installed.Beta Was this translation helpful? Give feedback.
All reactions