Replies: 1 comment
-
Thanks for raising this. I wonder if you've tried the new carrier (0.3.0) - we've now made this easier to use. That would let you do: fn <- crate(\(a, b, c) myfunc(a, b, c), myfunc = myfunc, myotherfunc = myotherfunc) Also as you mentioned, passing this once using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As detailed in this issue, the following patterns are problematic because they end up discovering/passing too much from the environment, which causes invoke-ation to take a large amount of time (4-10 seconds):
The only pattern that works (the other one I describe in the issue does not), is pattern 3:
I am keeping
ExtendedTask
here because I tried this in a Shiny context only.The recommendation from that thread is to use
crate
:This kind of works, but has the major hindrance that the function needs to be defined within the crate, and has other restrictions: notably, function calls have to be referenced by package name, even when it is extremely cumbersome, like with the
data.table
package.It is possible to crate an existing function by doing
crate(rlang::set_env(myfunc)))
, but this does not remove the restrictions above.In practice,
crate
is so constraining that I never end up using it and always use pattern 3. However, this tends to produce very ugly code, and in particular, code duplication, because I need to redefine every function that I want to call inside a mirai separately.My argument is that this severely limits the practical useability of mirai in a scenario that is perhaps not ideal, but that I can't imagine is uncommon: one where functions are defined in the environment and need to be used in a task.
In such a world, there would need to make this kind of pattern not take extra seconds or pass too much data, but the body of the functions only and its dependencies:
Is there a way to reach such a goal? I ensure separately that all packages needed by the functions are loaded through
everywhere
.Beta Was this translation helpful? Give feedback.
All reactions