-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combining list of SpatRasters with rast fails with multiple workers #52
Comments
I'm stumped on this one. As a workaround, setting |
Hmmm... getting this same bug with a |
Ok, I suspect the reason for this has something to do with how marshaling works with branching. In this example, |
I think you might be right there with some kind of nice |
Unable to reproduce this with just library(crew)
library(terra)
#> terra 1.7.71
library(purrr)
controller <- crew_controller_local(
name = "example",
workers = 2,
seconds_idle = 10
)
controller$start()
marshal <- terra::wrap
unmarshal <- terra::unwrap
rast_list <- list(a = marshal(terra::rast(system.file("ex/logo.tif", package = "terra"))),
b = marshal(terra::rast(system.file("ex/logo.tif", package = "terra")) + 1))
#goal is to combine rast list like so:
terra::rast(purrr::map(rast_list, unmarshal))
#> class : SpatRaster
#> dimensions : 77, 101, 6 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax)
#> coord. ref. : Cartesian (Meter)
#> source(s) : memory
#> names : a_1, a_2, a_3, b_1, b_2, b_3
#> min values : 0, 0, 0, 1, 1, 1
#> max values : 255, 255, 255, 256, 256, 256
controller$push(
name = "combine",
command = marshal(terra::rast(purrr::map(rast_list, unmarshal))),
data = list(rast_list = rast_list, marshal = marshal, unmarshal = unmarshal)
)
controller$wait(mode = "all")
result <- controller$pop()
result$result |> map(unmarshal)
#> [[1]]
#> class : SpatRaster
#> dimensions : 77, 101, 6 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax)
#> coord. ref. : Cartesian (Meter)
#> source(s) : memory
#> names : a_1, a_2, a_3, b_1, b_2, b_3
#> min values : 0, 0, 0, 1, 1, 1
#> max values : 255, 255, 255, 256, 256, 256 Created on 2024-04-12 with reprex v2.1.0 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31)
#> os macOS Sonoma 14.4.1
#> system x86_64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/Phoenix
#> date 2024-04-12
#> pandoc 3.1.13 @ /usr/local/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.0)
#> codetools 0.2-20 2024-03-31 [1] CRAN (R 4.3.2)
#> crew * 0.9.0 2024-02-08 [1] CRAN (R 4.3.2)
#> data.table 1.15.4 2024-03-30 [1] CRAN (R 4.3.2)
#> digest 0.6.35 2024-03-11 [1] CRAN (R 4.3.2)
#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.0)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.0)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0)
#> getip 0.1-4 2023-12-10 [1] CRAN (R 4.3.0)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.0)
#> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.0)
#> knitr 1.46 2024-04-06 [1] CRAN (R 4.3.2)
#> later 1.3.2 2023-12-06 [1] CRAN (R 4.3.0)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.0)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
#> mirai 0.12.1 2024-02-02 [1] CRAN (R 4.3.2)
#> nanonext 0.13.0 2024-02-07 [1] CRAN (R 4.3.2)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0)
#> processx 3.8.4 2024-03-16 [1] CRAN (R 4.3.2)
#> promises 1.2.1 2023-08-10 [1] CRAN (R 4.3.0)
#> ps 1.7.6 2024-01-18 [1] CRAN (R 4.3.0)
#> purrr * 1.0.2 2023-08-10 [1] CRAN (R 4.3.0)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.0)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.2)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.0)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
#> Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.0)
#> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.0)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.0)
#> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.0)
#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.0)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
#> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.0)
#> terra * 1.7-71 2024-01-31 [1] CRAN (R 4.3.2)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0)
#> tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.3.2)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.0)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.0)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.0)
#> xfun 0.43 2024-03-25 [1] CRAN (R 4.3.2)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.0)
#>
#> [1] /Users/ericscott/Library/R/x86_64/4.3/library
#> [2] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
This was caused by a marshaling bug in |
Confirmed that this works now! Thanks @wlandau! |
I'm encountering a bug when trying to combine a list of rasters created by dynamic branching. It seems related to marshaling, since the error message mentions
wrap()
and I only get the error with multiplecrew
workers, but not sure.Created on 2024-04-09 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: