Drake: conflict between assertive and drake's internal S3 classes

Created on 2 Feb 2020  路  7Comments  路  Source: ropensci/drake

Prework

  • [x] Read and abide by drake's code of conduct.
  • [x] Search for duplicates among the existing issues, both open and closed.
  • [x] Advanced users: verify that the bug still persists in the current development version (i.e. remotes::install_github("ropensci/drake")) and mention the SHA-1 hash of the Git commit you install.

Description

For some reason, one of my production pipelines has broken over the weekend, for only one of my projects. Over the weekend, the changes I made were to upgrade to the latest version of R, change the MRAN snapshot date to 2020-01-27.

No changes made to the actual project itself. I can't figure out what to correct here. I've tried deleting the .drake and starting the whole plan from scratch, but to no avail.

Any ideas?

> drake::r_outdated() 
Loading packages...
Loading download functions...
Loading report functions...
Loading hubble functions...
Loading supply functions...
Loading aggregation functions...
Loading memory functions...
Loading export functions...
Loading shiny-dash functions...
Loading plan...
|
Error : $ operator is invalid for atomic vectors

Error: <callr_status_error: callr subprocess failed: $ operator is invalid for atomic vectors>
-->
<callr_remote_error: $ operator is invalid for atomic vectors>
 in process 6696 

See `.Last.error.trace` for a stack trace.
> .Last.error.trace

 Stack trace:

 Process 6578:
 1. drake::r_outdated()
 2. drake:::r_drake(source, drake::outdated, list(...), r_fn, r_args)
 3. base:::do.call(r_fn, r_args)
 4. (function (func, args = list(), libpath = .libPaths(), repos = default_repos(),  ...
 5. callr:::get_result(output = out, options)
 6. throw(newerr, parent = remerr[[2]])

 x callr subprocess failed: $ operator is invalid for atomic vectors 

 Process 6696:
 18. (function (source, d_fn, d_args)  ...
 19. base:::do.call(d_fn, d_args)
 20. (function (config, make_imports = TRUE, do_prework = TRUE)  ...
 21. drake:::process_imports(config = config)
 22. drake:::process_imports_mclapply(config)
 23. drake:::lightly_parallelize(X = imports, FUN = drake::process_import,  ...
 24. drake:::lightly_parallelize_atomic(X = X, FUN = FUN, jobs = jobs,  ...
 25. drake:::weak_mclapply(X = keys, FUN = FUN, mc.cores = jobs, ...)
 26. base:::lapply(X = X, FUN = FUN, ...)
 27. drake:::FUN(X[[i]], ...)
 28. drake:::store_item(target = import, value = value, meta = meta,  ...
 29. drake:::store_meta(target = target, value = value, meta = meta,  ...
 30. drake:::finalize_meta(target = target, value = value, meta = meta,  ...
 31. drake:::finalize_times(target, meta, config)
 32. drake:::runtime_entry(meta$time_command, target)
 33. base:::as.character(target)
 34. assertive.files:::as.character.file(target)
 35. base:::.handleSimpleError(function (e)  ...
 36. h(simpleError(msg, call))

 x $ operator is invalid for atomic vectors 

>

Reproducible example

This was a tough one to make a repro example for.

I don't think it's a drake issue or a R version issue. All my other prod pipelines work just fine. Except this one. I'm really lost.

Session info

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.2 tools_3.6.2    packrat_0.5.0 
bug

All 7 comments

That's a surprising error and traceback. I think I will need a reprex to really get to the bottom of this.

What version of drake were you using before and after the upgrade? Version 7.10.0 just went to CRAN.

The MRAN snapshot I was using before this was ~Jul-2019.

I've narrowed down the error a function I'm using to generate a report and return variables as well.

make_abcd_report <- function(dat, date) {
        render(
                input = knitr_in("rmd/forecast/abcd.Rmd"),
                output_file = file_out("abcd.html"),
                output_dir = paste0("reports/forecasts/",date),
                quiet = TRUE
        )
        return(list(fcst,sim))
}

# in plan.R
forecast_plan <- drake_plan(
  ...
  fc_abcd = make_abcd_report(some_dat, some_date),
  ...
)

If I comment this out, the outdated() runs as expected.... something from Jul to now has changed which causes this function to fail.

Further investigation shows that commenting out input = knitr_in("rmd/forecast/abcd.Rmd"), removes that error.

I tried reproducing the error here: https://github.com/rsangole/temp-drake but the exact functions work just fine.

Found it!!

It's my call to library(assertive) in R/packages.R which is causing an issue.

Can you try and replicate?

https://github.com/rsangole/temp-drake updated with code which breaks

Thanks, I never would have found the problem otherwise. Turns out the example somehow creates a conflict with drakes internal S3 classes. Should be fixed now.

Was this page helpful?
0 / 5 - 0 ratings