Closed Aariq closed 7 months ago
E.g. in #45 tests without multiple workers pass, but tests with multiple workers fail
@Aariq I couldn't see tests in #45 with multiple workers?
https://github.com/njtierney/demo-geotargets/blob/main/_targets.R#L57-L67 demonstrates this failure.
Running:
tar_make(country_shapes)
I get
\
Attaching package: ‘arrow’
The following object is masked from ‘package:utils’:
timestamp
Loading required package: terra
terra 1.7.71
/
Attaching package: ‘terra’
The following object is masked from ‘package:arrow’:
buffer
▶ dispatched target some_countries
● completed target some_countries [1.555 seconds]
▶ dispatched branch country_shapes_3f2db3d69162e956
▶ dispatched branch country_shapes_e283ec3d863c309b
▶ dispatched branch country_shapes_22eb5cc8ead488b2
● completed branch country_shapes_3f2db3d69162e956 [44.895 seconds]
▶ dispatched branch country_shapes_727718e808a32bd7
● completed branch country_shapes_e283ec3d863c309b [44.658 seconds]
▶ dispatched branch country_shapes_863d9f12a8c14c21
● completed branch country_shapes_22eb5cc8ead488b2 [45.125 seconds]
▶ dispatched branch country_shapes_32e7a6f900e1d4b6
● completed branch country_shapes_863d9f12a8c14c21 [53.13 seconds]
● completed branch country_shapes_32e7a6f900e1d4b6 [53.899 seconds]
✖ errored branch country_shapes_727718e808a32bd7
✖ errored pipeline [1.987 minutes]
Warning message:
[writeVector] nothing to write
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:
_store_ missing files: _targets/objects/country_shapes_727718e808a32bd7
Last error traceback:
No traceback available.
Although perhaps this is a slightly contrived usage of pattern
, since this function cgaz_countries
is already vectorised...I think it should still work in principle?
https://github.com/njtierney/demo-geotargets/blob/main/_targets.R#L57-L67 demonstrates this failure.
Does this still fail with targets
1.7.0?
Yes, sorry, I should have taken the time to write out a proper reprex:
library(targets)
tar_dir({ # tar_dir() runs code from a temporary directory.
tar_script({
library(geotargets)
# from hypertidy/sds
library(sds)
library(terra)
## demonstration using many countries and multiple workers
cgaz_country <- function(country_name){
cgaz_source <- CGAZ()
cgaz_query <- CGAZ_sql(country_name)
v <- vect(
x = cgaz_source,
query = cgaz_query
)
v
}
list(
tar_target(
some_countries,
countrycode::codelist$iso3c[1:6]
),
tar_terra_vect(
country_shapes,
cgaz_country(some_countries),
pattern = map(some_countries)
)
)
})
tar_make(country_shapes)
tar_load(country_shapes)
})
#> terra 1.7.71
#> ▶ dispatched target some_countries
#> ● completed target some_countries [0.021 seconds]
#> ▶ dispatched branch country_shapes_3f2db3d69162e956
#> ● completed branch country_shapes_3f2db3d69162e956 [35.993 seconds]
#> ▶ dispatched branch country_shapes_e283ec3d863c309b
#> ● completed branch country_shapes_e283ec3d863c309b [28.566 seconds]
#> ▶ dispatched branch country_shapes_22eb5cc8ead488b2
#> ● completed branch country_shapes_22eb5cc8ead488b2 [27.886 seconds]
#> ▶ dispatched branch country_shapes_727718e808a32bd7
#> ✖ errored branch country_shapes_727718e808a32bd7
#> ✖ errored pipeline [2.284 minutes]
#> Warning message:
#> [writeVector] nothing to write
#> 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:
#> _store_ missing files: _targets/objects/country_shapes_727718e808a32bd7
#> Last error traceback:
#> No traceback available.
Created on 2024-04-24 with reprex v2.1.0
That reprex doesn't run multiple workers, so I think it is off topic. A particular branch errors in a way that suggest that perhaps there is no data for that particular country. I have the start of some tests with multiple workers. I can open a draft PR later today.
I think it's important to add tests running pipelines with multiple workers, since that is when the marshaling/unmarshaling of R objects comes into play.