Closed simon-smart88 closed 4 months ago
Popping this here as an example of the wrapping and unwrapping to make {disaggregation}
work with {future}
:
covs_prep <- terra::wrap(covs_prep)
agg <- terra::wrap(agg)
prep_remote %<-% {
prep <- disaggregation::prepare_data(shape, terra::unwrap(covs_prep), terra::unwrap(agg), id_var = "ID_2", response_var = "inc", na.action = TRUE)
prep$covariate_rasters <- terra::wrap(prep$covariate_rasters)
prep}
prep_remote_value <- future::value(prep_remote)
prep_remote_value$covariate_rasters <- terra::unwrap(prep_remote_value$covariate_rasters)
For some reason, prep_mesh
generates Warning: Error in wk_handle.wk_wkb: Loop 1 edge 9 has duplicate near loop 2 edge 1
when it is run at the same time as other tasks. Works fine with MDG data, so may be a peculiarity of the Scotland data/
@timcdlucas I've looked into using ExtendedTask for running slow tasks asynchronously on the async branch. Here's a braindump which we can discuss at some point:
cov
,agg
andprep_mesh
modules where I see this being handy.stop
for when they are being run outside the app or to return the errors when run in the app so that they can be passed to the logger. For mostcov
andagg
modules, this won't be too much of an issue as there are few things which can go wrong inside the function.async
) adding to handle that when run in the app. For the{disaggregation}
functions that are currently used directly, this would mean that they need wrapping in new functions.prep
modules being used whilecov
tasks are still running so the tasks need storing as alist
incommon
(haven't checked whether this is possible yet)