Giter VIP home page Giter VIP logo

catchr's People

Contributors

burchill avatar lionel- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lionel-

catchr's Issues

New version of `rlang` causes error with dots (...)

I recently updated rlang to v 0.4.11.9000 and am now encountering an error with make_plans and make_catch_fn that has to do with the function catchr:::approx_arg_name and how expr_deparse now deals with ....

Error trace:

`...` is not empty.
i These dots only exist to allow future extensions and should be empty.
x We detected these problematic arguments:
* `..1`
i Did you misspecify an argument?
Backtrace:
     x
  1. +-base::source("~/R/Quant/JobsScripts/TuneHP.R", echo = TRUE)
  2. | +-base::withVisible(eval(ei, envir))
  3. | \-base::eval(ei, envir)
  4. |   \-base::eval(ei, envir)
  5. +-qf::start_cluster(outfile = "~/R/Quant/cl_log.log") ~/R/Quant/JobsScripts/TuneHP.R:12:0
  6. | +-base::eval(...)
  7. | | \-base::eval(...)
  8. | \-catchr::make_catch_fn(...)
  9. |   \-catchr::make_plans(..., .opts = .opts)
 10. |     \-catchr:::check_and_clean_input(..., spec_names = special_terms)
 11. |       \-catchr:::clean_input(akw$kwargs, spec_names)
 12. |         \-`%>%`(...)
 13. +-catchr:::add_back_arg_pos(., qs)
 14. | \-purrr::map2(...)
 15. +-purrr::map(., ~classify_arg(., spec_names))
 16. | \-catchr:::.f(.x[[i]], ...)
 17. |   \-catchr:::classify_arg(., spec_names)
 18. |     \-catchr:::approx_arg_name(!!arg)
 19. |       \-get_expr(enquo(x)) %>% expr_deparse(999) %>% paste(collapse = "")
 20. +-base::paste(., collapse = "")
 21. \-rlang::expr_deparse(., 999)
 22.   \-rlang::check_dots_empty0(...)
 23.     \-rlang::check_dots_empty()
 24.       \-rlang:::action_dots(...)

SessionInfo:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] parsnip_0.1.5        RevoUtils_11.0.2     RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] colorspace_2.0-0    slider_0.1.5        ellipsis_0.3.1     
 [4] class_7.3-17        timetk_2.6.0        fs_1.5.0           
 [7] logspline_2.1.16    rstudioapi_0.13     mice_3.13.0        
[10] listenv_0.8.0       furrr_0.2.1         dials_0.0.9.9000   
[13] bit64_4.0.5         prodlim_2019.11.13  fansi_0.4.2        
[16] mvtnorm_1.1-1       lubridate_1.7.9.2   codetools_0.2-16   
[19] splines_4.0.2       knitr_1.31          jsonlite_1.7.2     
[22] workflows_0.2.2     pROC_1.16.2         broom_0.7.6        
[25] anytime_0.3.9       yardstick_0.0.8     tune_0.1.5         
[28] compiler_4.0.2      httr_1.4.2          tictoc_1.0         
[31] backports_1.2.1     assertthat_0.2.1    Matrix_1.2-18      
[34] cli_2.5.0           htmltools_0.5.1.1   tools_4.0.2        
[37] gtable_0.3.0        glue_1.4.2          dplyr_1.0.5        
[40] Rcpp_1.0.6          DiceDesign_1.8-1    vctrs_0.3.8.9000   
[43] debugme_1.1.0       iterators_1.0.13    timeDate_3043.102  
[46] gower_0.2.2         xfun_0.22           stringr_1.4.0      
[49] globals_0.14.0      lifecycle_1.0.0     qf_0.0.0.9999      
[52] future_1.20.1       tsibble_0.9.3       MASS_7.3-51.6      
[55] zoo_1.8-8           scales_1.1.1        ipred_0.9-9        
[58] parallel_4.0.2      expm_0.999-4        yaml_2.2.1         
[61] quantmod_0.4.17     curl_4.3            Exact_2.0          
[64] memoise_1.1.0       ggplot2_3.3.3       rpart_4.1-15       
[67] stringi_1.5.3       RSQLite_2.2.2       foreach_1.5.1      
[70] TTR_0.23-6          lhs_1.1.1           warp_0.2.0         
[73] boot_1.3-25         lava_1.6.8.1        rlang_0.4.11.9000  
[76] pkgconfig_2.0.3     rsample_0.0.9       evaluate_0.14      
[79] lattice_0.20-41     purrr_0.3.4         recipes_0.1.16     
[82] bit_4.0.4           tidyselect_1.1.0    parallelly_1.21.0  
[85] plyr_1.8.6          magrittr_2.0.1      R6_2.5.0           
[88] DescTools_0.99.37   generics_0.1.0      DBI_1.1.1          
[91] pillar_1.5.1        withr_2.3.0         xts_0.12.1         
[94] RPushbullet_0.3.3.1 survival_3.1-12     nnet_7.3-14        
[97] tibble_3.1.0        crayon_1.4.1        catchr_0.2.3       
[100] utf8_1.2.1          AlpacaforR_1.0.0    rmarkdown_2.7.1    
[103] workflowsets_0.0.2  grid_4.0.2          data.table_1.13.2  
[106] blob_1.2.1          digest_0.6.27       tidyr_1.1.3        
[109] GPfit_1.0-8         munsell_0.5.0 

catchr and rlang 1.0.0

Hello,

I'm seeing several errors with dev rlang. We plan to release it in 2 to 4 weeks. With R CMD check I see these two:

check_and_clean_input(d1 = base::acosh, spec_names = "acosh")
#> Error in `call_name()`: `call` must be a simple call.
#> ℹ Calls to `::` or `:::` are not simple calls.
#> ℹ See `?is_call_simple`.


opts <- catchr_opts(
  default_plan = c(collect, muffle),
  drop_empty_conds = FALSE,
  bare_if_possible = FALSE
)
plans <- make_plans(warning, message, error, .opts = opts)

res <- catch_expr(condition_thrower(), plans)
res2 <- catch_expr(dispense_collected(res), plans)
waldo::compare(res, res2)
#> `old$error[[1]]` is length 2
#> `new$error[[1]]` is length 3
#>
#> `names(old$error[[1]])`: "message" "call"
#> `names(new$error[[1]])`: "message" "call" "trace"
#>
#> `old$error[[1]]$trace` is absent
#> `new$error[[1]]$trace` is an S3 object of class <rlang_trace/rlib_trace/tbl/data.frame>, a list

The call_name() error is a planned breakage, it now needs to be paired with is_call_simple().

I see more issues with interactive devtools::test() but haven't investigated. Could you take a look and let me know if you think there is any bug in rlang that causes failures please?

!! Bang-Bang operator causes error: Error in enquo(expr) : object 'x' not found

Hi @burchill,
I've been thoroughly making use of catchr thanks to the info you provided in the issue over on furrr, thank you for cluing me into this useful package and for your dedicated effort in creating and maintaining it!

I've just encountered a somewhat bizarre error when using catchr to surface message from background processes using the implementation you provided. The bang bang !! operator just doesn't seem to work when catch is used!

Here's a reprex to illustrate:

write_to_file <- function(cond) {
  cond_class <- class(cond)[1]
  msg <- paste(cond_class, ":", cond$message)
  write(msg, file = "outlog", append=TRUE)
}

catch <- catchr::make_catch_fn(
  warning = c(write_to_file, muffle),
  message = c(write_to_file, muffle),
  error   = c(write_to_file, catchr::exit_with("Returned error!"))
)
cl <- parallel::makeCluster(2)
future::plan(future::cluster, workers = cl)

.d <- data.frame(time = rnorm(5), t2 = rnorm(5))
`!!` <- rlang::`!!`
`%>%` <- magrittr::`%>%`
# With normal furrr it's fine
furrr::future_imap(1:2, ~{
  .t <- "time"
  .ts <- rlang::sym(.t)
  .d %>% 
    dplyr::select(!!.ts)
})
# But with catchr the bang bang causes an error
furrr::future_imap(1:2, ~catch({
  .t <- "time"
  .ts <- rlang::sym(.t)
  .d %>% 
    dplyr::select(!!.ts)
}))

parallel::stopCluster(cl)

Error in enquo(expr) : object '.ts' not found

I should also mention that apparently there's a new immediateMessage class in future functionality that allows messages to be surfaced to the console from background processes. You might already know about it, but if you haven't I just recently tagged you again on the issue where you informed me about catchr where Davis Vaughan and Henrik Bengtsson shared it with me. I feel like it's info that is likely useful you and this package.

Here's my sessionInfo JIC you need it:

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] RevoUtils_11.0.3     AlpacaforR_1.0.0     printr_0.1           dplyr_1.0.0          magrittr_1.5        
[6] RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5.2         HDA_0.0.0.9000       catchr_0.2.2         pillar_1.4.6.9000    compiler_3.5.3      
 [6] tools_3.5.3          digest_0.6.25.1      packrat_0.5.0        bit_1.1-15.2         lubridate_1.7.9     
[11] jsonlite_1.7.0       RSQLite_2.2.0.9000   memoise_1.1.0        lifecycle_0.2.0.9000 tibble_3.0.3.9000   
[16] pkgconfig_2.0.3      rlang_0.4.7.9000     DBI_1.1.0            rstudioapi_0.11      parallel_3.5.3      
[21] xfun_0.15.1          furrr_0.1.0.9002     httr_1.4.1           stringr_1.4.0        knitr_1.29.3        
[26] globals_0.12.5       generics_0.0.2       vctrs_0.3.2          bit64_0.9-7          websocket_1.1.0     
[31] tidyselect_1.1.0     glue_1.4.1.9000      listenv_0.8.0        R6_2.4.1             tidyr_1.1.0         
[36] purrr_0.3.4.9000     blob_1.2.1           codetools_0.2-16     ellipsis_0.3.1       future_1.18.0       
[41] stringi_1.4.7        crayon_1.3.4   

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.