zoon
zoon copied to clipboard
Reproducible workflow when arguments are objects
Related to #192
It seems reasonable that people might use objects to define arguments. However, for the workflow object to be reproducible we would want to save the call as if it wasn't an object.
k = 2
work2 <- workflow(occurrence = UKAnophelesPlumbeus,
covariate = UKAir,
process = BackgroundAndCrossvalid(k = k),
model = LogisticRegression,
output = PerformanceMeasures)
RerunWorkflow(work2)
Caught errors:
Error in 1:k: NA/NaN argument
...
===================
Call: workflow(occurrence = UKAnophelesPlumbeus, covariate = UKAir, process = BackgroundAndCrossvalid(k = k), model = LogisticRegression, output = PerformanceMeasures, forceReproducible = FALSE)
We would want the call to be saved as k=2
.
Seems sensible for this use case. We could handle this by checking whether arguments are objects in the calling environment and then dput
ing them.
That approach would be awful for large objects (e.g. rasters passed to PredictNewAreaMap
#145) though.
An alternative would be to store all the objects used in the workflow object.
Yes think the latter is a better general idea. Then RerunWorkflow
needs to know where to find those objects. Possibly by writing those things from the workflow object to the global environment at the beginning.
Rather than writing to global, we could:
- define a new environment
obj_env
inworkflow
- copy the named objects from global into
obj_env
- set that
obj_env
as the place to look for named objects - return
obj_env
in the workflow object
Then rerunworkflow could just fetch objects from obj_env
in the workflow object.