Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Combining list of SpatRasters with rast fails with multiple workers #52

@Aariq

Description

@Aariq

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 multiple crew workers, but not sure.

targets::tar_script({
    targets::tar_option_set(controller = crew::crew_controller_local(workers = 2))
    list(
        geotargets::tar_terra_rast(
            rast_raw,
            terra::rast(system.file("ex/elev.tif", package = "terra"))
        ),
        targets::tar_target(x, 1:3),
        geotargets::tar_terra_rast(
            rast_plus,
            rast_raw + x,
            pattern = map(x),
            iteration = "list"
        ),
        geotargets::tar_terra_rast(
            combined,
            terra::rast(unname(rast_plus))
        )
    )
})
targets::tar_make()
#> ▶ dispatched target x
#> ▶ dispatched target rast_raw
#> ● completed target x [0.028 seconds]
#> ● completed target rast_raw [5.603 seconds]
#> ▶ dispatched branch rast_plus_29239c8a
#> ▶ dispatched branch rast_plus_7cc32924
#> ● completed branch rast_plus_7cc32924 [0.008 seconds]
#> ▶ dispatched branch rast_plus_bd602d50
#> ● completed branch rast_plus_bd602d50 [0.005 seconds]
#> ● completed branch rast_plus_29239c8a [0.006 seconds]
#> ● completed pattern rast_plus
#> ▶ dispatched target combined
#> ▶ ended pipeline [19.278 seconds]
#> Error:
#> ! Error running targets::tar_make()
#> Error messages: targets::tar_meta(fields = error, complete_only = TRUE)
#> Debugging guide: https://books.ropensci.org/targets/debugging.html
#> How to ask for help: https://books.ropensci.org/targets/help.html
#> Last error message:
#>     target combined error: unable to find an inherited method for function ‘wrap’ for signature ‘"NULL"’
#> Last error traceback:
#>     base::tryCatch(base::withCallingHandlers({ NULL base::saveRDS(base::do.c...
#>     tryCatchList(expr, classes, parentenv, handlers)
#>     tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), na...
#>     doTryCatch(return(expr), name, parentenv, handler)
#>     tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#>     tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>     doTryCatch(return(expr), name, parentenv, handler)
#>     base::withCallingHandlers({ NULL base::saveRDS(base::do.call(base::do.ca...
#>     base::saveRDS(base::do.call(base::do.call, base::c(base::readRDS("/var/f...
#>     base::do.call(base::do.call, base::c(base::readRDS("/var/folders/wr/by_l...
#>     (function (what, args, quote = FALSE, envir = parent.frame()) { if (!is....
#>     (function (targets_function, targets_arguments, options, envir = NULL, s...
#>     tryCatch(out <- withCallingHandlers(targets::tar_callr_inner_try(targets...
#>     tryCatchList(expr, classes, parentenv, handlers)
#>     tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>     doTryCatch(return(expr), name, parentenv, handler)
#>     withCallingHandlers(targets::tar_callr_inner_try(targets_function = targ...
#>     targets::tar_callr_inner_try(targets_function = targets_function, target...
#>     do.call(targets_function, targets_arguments)
#>     (function (pipeline, path_store, names_quosure, shortcut, reporter, seco...
#>     crew_init(pipeline = pipeline, meta = meta_init(path_store = path_store)...
#>     self$run_crew()
#>     self$iterate()
#>     self$conclude_worker_task()
#>     tar_assert_all_na(result$error, msg = paste("target", result$name, "erro...
#>     tar_throw_validate(msg %|||% default)
#>     tar_error(message = paste0(...), class = c("tar_condition_validate", "ta...
#>     rlang::abort(message = message, class = class, call = tar_empty_envir)
#>     signal_abort(cnd, .file)

Created on 2024-04-09 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions