Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative fix to #42 #44

Merged
merged 2 commits into from
Sep 3, 2020
Merged

Alternative fix to #42 #44

merged 2 commits into from
Sep 3, 2020

Conversation

florisvdh
Copy link
Contributor

Only the second commit differs from #43 . This may be a more elegant solution: parallel is now not imported anymore (hence, one dependency less), but if cl argument is used (hence, stopCluster), it is checked whether parallel can be loaded.

So, you have a choice 😉

For the rest, it works just the same.

library(zen4R)
library(parallel)
download_zenodo("10.5281/zenodo.2547036", 
                parallel = TRUE,
                parallel_handler = mclapply,
                mc.cores = 2)
#> Warning in Sys.setlocale("LC_TIME", "us_US"): OS reports request to set locale
#> to "us_US" cannot be honored
#> [zen4R][INFO] ZenodoRecord - Download in parallel mode 
#> [zen4R][INFO] ZenodoRecord - Using non cluster-based (no cluster 'cl' argument specified) 
#> [zen4R][INFO] ZenodoRecord - Will download 2 files from record '4011667' (doi: '10.5281/zenodo.4011667') - total size: 72 KiB 
#> [zen4R][INFO] Files downloaded at '/tmp/Rtmp6TtrU6/reprex372b4af48f15'.
#> [zen4R][INFO] ZenodoRecord - Verifying file integrity... 
#> [zen4R][INFO] File 'zen4R-0.4.tar.gz': integrity verified (md5sum: e36420deeaf30ebd25fd74dfdcf6d7cd)
#> [zen4R][INFO] File 'zen4R-0.4.zip': integrity verified (md5sum: 5fa140b3837c315bfc9733813b152fd3)
#> [zen4R][INFO] ZenodoRecord - End of download
download_zenodo("10.5281/zenodo.2547036", 
                parallel = TRUE,
                parallel_handler = parLapply,
                cl = makeCluster(2))
#> Warning in Sys.setlocale("LC_TIME", "us_US"): OS reports request to set locale
#> to "us_US" cannot be honored
#> [zen4R][INFO] ZenodoRecord - Download in parallel mode 
#> [zen4R][INFO] ZenodoRecord - Using cluster-based parallel handler (cluster 'cl' argument specified) 
#> [zen4R][INFO] ZenodoRecord - Will download 2 files from record '4011667' (doi: '10.5281/zenodo.4011667') - total size: 72 KiB 
#> [zen4R][INFO] Files downloaded at '/tmp/Rtmp6TtrU6/reprex372b4af48f15'.
#> [zen4R][INFO] ZenodoRecord - Verifying file integrity... 
#> [zen4R][INFO] File 'zen4R-0.4.tar.gz': integrity verified (md5sum: e36420deeaf30ebd25fd74dfdcf6d7cd)
#> [zen4R][INFO] File 'zen4R-0.4.zip': integrity verified (md5sum: 5fa140b3837c315bfc9733813b152fd3)
#> [zen4R][INFO] ZenodoRecord - End of download

Created on 2020-09-03 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Linux Mint 20               
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language nl_BE:nl                    
#>  collate  nl_BE.UTF-8                 
#>  ctype    nl_BE.UTF-8                 
#>  tz       Europe/Brussels             
#>  date     2020-09-03                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.2)
#>  backports     1.1.8   2020-06-17 [1] CRAN (R 4.0.2)
#>  callr         3.4.3   2020-03-28 [1] CRAN (R 4.0.2)
#>  cli           2.0.2   2020-02-28 [1] CRAN (R 4.0.2)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 4.0.2)
#>  curl          4.3     2019-12-02 [1] CRAN (R 4.0.2)
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 4.0.2)
#>  devtools      2.3.1   2020-07-21 [1] CRAN (R 4.0.2)
#>  digest        0.6.25  2020-02-23 [1] CRAN (R 4.0.2)
#>  ellipsis      0.3.1   2020-05-15 [1] CRAN (R 4.0.2)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.2)
#>  fansi         0.4.1   2020-01-08 [1] CRAN (R 4.0.2)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
#>  glue          1.4.1   2020-05-13 [1] CRAN (R 4.0.2)
#>  highr         0.8     2019-03-20 [1] CRAN (R 4.0.2)
#>  htmltools     0.5.0   2020-06-16 [1] CRAN (R 4.0.2)
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.0.2)
#>  jsonlite      1.7.0   2020-06-25 [1] CRAN (R 4.0.2)
#>  keyring       1.1.0   2018-07-16 [1] CRAN (R 4.0.2)
#>  knitr         1.29    2020-06-23 [1] CRAN (R 4.0.2)
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 4.0.2)
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 4.0.2)
#>  pkgbuild      1.1.0   2020-07-13 [1] CRAN (R 4.0.2)
#>  pkgload       1.1.0   2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.0.2)
#>  processx      3.4.3   2020-07-05 [1] CRAN (R 4.0.2)
#>  ps            1.3.4   2020-08-11 [1] CRAN (R 4.0.2)
#>  R6            2.4.1   2019-11-12 [1] CRAN (R 4.0.2)
#>  remotes       2.2.0   2020-07-21 [1] CRAN (R 4.0.2)
#>  reprex        0.3.0   2019-05-16 [1] CRAN (R 4.0.2)
#>  rlang         0.4.7   2020-07-09 [1] CRAN (R 4.0.2)
#>  rmarkdown     2.3     2020-06-18 [1] CRAN (R 4.0.2)
#>  rprojroot     1.3-2   2018-01-03 [1] CRAN (R 4.0.2)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
#>  stringi       1.4.6   2020-02-17 [1] CRAN (R 4.0.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
#>  testthat      2.3.2   2020-03-02 [1] CRAN (R 4.0.2)
#>  usethis       1.6.1   2020-04-29 [1] CRAN (R 4.0.2)
#>  withr         2.2.0   2020-04-20 [1] CRAN (R 4.0.2)
#>  xfun          0.16    2020-07-24 [1] CRAN (R 4.0.2)
#>  xml2          1.3.2   2020-04-23 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.2)
#>  zen4R       * 0.4-1   2020-09-03 [1] local         
#> 
#> [1] /home/floris/lib/R/library
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library

@codecov-commenter
Copy link

codecov-commenter commented Sep 3, 2020

Codecov Report

Merging #44 into master will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #44      +/-   ##
=========================================
- Coverage    6.26%   6.24%   -0.03%     
=========================================
  Files           7       7              
  Lines        1117    1121       +4     
=========================================
  Hits           70      70              
- Misses       1047    1051       +4     
Impacted Files Coverage Δ
R/ZenodoRecord.R 0.00% <0.00%> (ø)
R/zen4R_downloader.R 0.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40e5ed0...d9a72d6. Read the comment docs.

@eblondel eblondel merged commit c80d800 into eblondel:master Sep 3, 2020
@eblondel
Copy link
Owner

eblondel commented Sep 3, 2020

@florisvdh thanks for this
Indeed i prefer having parallel in suggests, and adding the piece of code above.
For CRAN, it will have to wait for a next release, as i sent 0.4-1 this morning (after some changes requested by CRAN) and it was accepted. It will not affect zen4R as it is only for the parallel stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants