futureverse / progressr

三 R package: An Inclusive, Unifying API for Progress Updates
https://progressr.futureverse.org
281 stars 12 forks source link

cli R package progress bars not showing through progressr handler #156

Closed rafev closed 1 year ago

rafev commented 1 year ago

I am having an issue where my progress bar no longer shows. I use the progressr package and use handler("cli") to display the progress bar as a CLI version for the ETA output. This worked perfectly under R v4.2.1 on my M1 mac, but now on v4.3 it does not display at all. Other progress handlers work, except for the CLI version, so I assume it's this version. Any clue what's happening?

handlers(global = TRUE)
handlers("cli")

my_1way.mods = function(modules_being_tested) {
    p = progressor(along = modules_being_tested)
    foreach (i = modules_being_tested) %dopar% {
        # Run GLMNET
        set.seed(32)
        Net.fit = train(x = train_grp[, module_df[module_df$colors == i, 1]],
                        y = train_pheno,
                        method = "glmnet",
                        trControl = cctrl1,
                        metric = "RMSE",
                        tuneGrid = expand.grid(.alpha = seq(.05, 1, length = 15),
                                               .lambda = seq(0.01, 1, 0.005)))

            p(sprintf("i=%s", i))

        my_list[[i]] = Net.fit
    }
}
HenrikBengtsson commented 1 year ago

I just checked, the following example from https://progressr.futureverse.org/ still works:

$ R --quiet --vanilla

> library(progressr)
> handlers(global = TRUE)
> handlers("cli")

> slow_sum(1:10, message = FALSE)
[1] 55
>

i.e. it produces a green cli progress in the terminal. I recommend that you start by making sure that works.

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /home/henrik/shared/software/CBI/R-4.3.0-gcc11/lib/R/lib/libRblas.so 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

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

other attached packages:
[1] progressr_0.13.0

loaded via a namespace (and not attached):
[1] compiler_4.3.0 cli_3.6.1      digest_0.6.31

EDIT: +5 min: I've re-checked with CRAN progressr 0.13.0. All good on my end.

rafev commented 1 year ago

Thank you. Confirmed to work on my end as well after a laptop reboot, oddly enough.