simon-smart88 / disagapp

R shiny app for disaggregation regression
https://simon-smart88.github.io/disagapp/
0 stars 0 forks source link

Use ExtendedTask for slow operations #35

Closed simon-smart88 closed 4 months ago

simon-smart88 commented 5 months ago

@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:

simon-smart88 commented 5 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)
simon-smart88 commented 4 months ago

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/