class: title-slide count: false .title[ # 11 - Requirements ] .subtitle[ ## Open Science Tools ] .author[ ### Claudio Zandonella & Davide Massidda ] .institute[ ] --- class: center, middle, inverse # Step X: Requirements --- # Requirements <br> -- .pull-left-50[ - **System Prerequisites**<br>(e.g., Operating System and CPU details) {{content}} ] .pull-right-50[ ] -- - **Software**<br>(e.g., R, Python, or Julia) {{content}} -- - **Libraries** --- # Requirements <br> .pull-left-50[ - **System Prerequisites**<br>(e.g., Operating System and CPU details) - **Software**<br>(e.g., R, Python, or Julia) - **Libraries** ] .pull-right-50[ ```r #---- requirements.txt ---- library_1==x.xx.xx library_2==x.xx.xx ... ``` .move-down-30[ .li-small[ {{content}} ] ] ] -- #### Versioning x.xx.xx - Patch - Minor Release - Major Release --- # Installation <br> -- .pull-left-50[ #### Instruction - Download project - Install required libraries .move-down-50[ {{content}} ] ] .pull-right-50[ ] -- - Unusual software - Configuration settings --- # Installation <br> .pull-left-50[ #### Instruction - Download project - Install required libraries .move-down-50[ - Unusual software - Configuration settings ] ] .pull-right-50[ Example: - [RStan](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started) - [Jekyll](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll) {{content}} ] -- Nice to have: - `install.sh` --- class: inverse, middle, center # R Dependencies --- # R Dependencies -- .pull-left-50[ #### R Version .code-size-12[ {{content}} ] ] .pull-right-50[ ] -- ```r version ## _ ## platform x86_64-apple-darwin20 ## arch x86_64 ## os darwin20 ## system x86_64, darwin20 ## status ## major 4 ## minor 3.0 ## year 2023 ## month 04 ## day 21 ## svn rev 84292 ## language R ## version.string R version 4.3.0 (2023-04-21) ## nickname Already Tomorrow ``` --- # R Dependencies .pull-left-50[ #### R Version .code-size-12[ ```r version ## _ ## platform x86_64-apple-darwin20 ## arch x86_64 ## os darwin20 ## system x86_64, darwin20 ## status ## major 4 ## minor 3.0 ## year 2023 ## month 04 ## day 21 ## svn rev 84292 ## language R ## version.string R version 4.3.0 (2023-04-21) ## nickname Already Tomorrow ``` ] ] .pull-right-50[ #### Other Related Software .code-size-12[ {{content}} ] ] -- ```r sessioninfo::session_info()$platform ## setting value ## version R version 4.3.0 (2023-04-21) ## os macOS Ventura 13.4 ## system x86_64, darwin20 ## ui RStudio ## language (EN) ## collate en_US.UTF-8 ## ctype en_US.UTF-8 ## tz Europe/Rome ## date 2023-06-10 ## rstudio 2023.03.1+446 Cherry Blossom (desktop) ## pandoc 2.19.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown) ## ``` --- # R Dependencies .pull-left-50[ #### R Packages .code-small[ {{content}} ] ] .pull-right-50[ ] -- ```r sessioninfo::session_info() ## ─ Session info ───────────────────────────────────────────── ## ## [...] ## ## ─ Packages ───────────────────────────────────────────────── ## ! package * version date (UTC) lib source ## P devtools 2.4.5 2022-10-11 [?] CRAN (R 4.3.0) ## P dplyr 1.1.2 2023-04-20 [?] CRAN (R 4.3.0) ## P knitr 1.43 2023-05-25 [?] CRAN (R 4.3.0) ## P magrittr 2.0.3 2022-03-30 [?] CRAN (R 4.3.0) ## rmarkdown 2.22 2023-06-01 [1] CRAN (R 4.3.0) ## P tibble 3.2.1 2023-03-20 [?] CRAN (R 4.3.0) ## P xaringan 0.28 2022-12-13 [?] CRAN (R 4.3.0) ## ## P ── Loaded and on-disk path mismatch. ## ──────────────────────────────────────────────────────────── ``` --- # R Dependencies .pull-left-50[ #### R Packages .code-small[ ```r sessioninfo::session_info() ## ─ Session info ───────────────────────────────────────────── ## ## [...] ## ## ─ Packages ───────────────────────────────────────────────── ## ! package * version date (UTC) lib source ## P devtools 2.4.5 2022-10-11 [?] CRAN (R 4.3.0) ## P dplyr 1.1.2 2023-04-20 [?] CRAN (R 4.3.0) ## P knitr 1.43 2023-05-25 [?] CRAN (R 4.3.0) ## P magrittr 2.0.3 2022-03-30 [?] CRAN (R 4.3.0) ## rmarkdown 2.22 2023-06-01 [1] CRAN (R 4.3.0) ## P tibble 3.2.1 2023-03-20 [?] CRAN (R 4.3.0) ## P xaringan 0.28 2022-12-13 [?] CRAN (R 4.3.0) ## ## P ── Loaded and on-disk path mismatch. ## ──────────────────────────────────────────────────────────── ``` ] ] .pull-right-50[ #### .code-small[ ```r ## ─ Python configuration ────────────────────────────────────────────────────────────── ## python: /usr/bin/python3 ## libpython: /usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so ## pythonhome: //usr://usr ## version: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] ## numpy: [NOT FOUND] ## ## python versions found: ## /usr/bin/python3 ## /usr/share/miniconda/bin/python ## ## ───────────────────────────────────────────────────────────────────────────────────── ``` ] ] --- class: inverse, middle, center # R Package Managment --- ## `renv` .pull-left-30[ .move-down-90[ <img src="images/11-requirements/renv-hex.png" width="80%" style="display: block; margin: auto;" /> ] .font-14[ .center[ https://rstudio.github.io/renv/ ] ] ] .pull-right-70[ {{content}} ] -- <img src="images/11-requirements/proj-library.png" width="70%" style="display: block; margin: auto;" /> --- ## `renv` .pull-left-30[ .move-down-90[ <img src="images/11-requirements/renv-hex.png" width="80%" style="display: block; margin: auto;" /> ] .font-14[ .center[ https://rstudio.github.io/renv/ ] ] ] .pull-right-70[ .move-up-50[ #### Caching System ] .move-down-50[ {{content}} ] ] -- <table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Platform </th> <th style="text-align:left;"> Location </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Linux </td> <td style="text-align:left;"> ~/.local/share/renv </td> </tr> <tr> <td style="text-align:left;"> macOS </td> <td style="text-align:left;"> ~/Library/Application Support/renv </td> </tr> <tr> <td style="text-align:left;"> Windows </td> <td style="text-align:left;"> %LOCALAPPDATA%/renv </td> </tr> </tbody> </table> {{content}} -- <img src="images/11-requirements/cache-revrsion.png" width="70%" style="display: block; margin: auto;" /> {{content}} -- <img src="images/11-requirements/cache-package.png" width="70%" style="display: block; margin: auto;" /> --- ## `renv` Workflow -- .pull-left-40[ .move-down-110[ {{content}} ] ] .pull-right-60[ .move-down-50[ <img src="images/11-requirements/use-renv.png" width="70%" style="display: block; margin: auto;" /> ] ] -- - `init()` --- ## `renv` Workflow .pull-left-40[ .move-down-110[ - `init()` ] ] .pull-right-60[ .move-down-50[ <img src="images/11-requirements/renv-active.png" width="80%" style="display: block; margin: auto;" /> ] .code-size-12[ {{content}} ] ] -- ```r # Install packages as usual install.packages('<name-package>') ``` --- ## `renv` Workflow .pull-left-40[ .move-down-110[ - `init()` - `snapshot()` ] ] .pull-right-60[ .move-down-50[ <img src="images/11-requirements/renv-active.png" width="80%" style="display: block; margin: auto;" /> ] .code-size-12[ ```r # Install packages as usual install.packages('<name-package>') # Capturing project's R package dependencies renv::snapshot() ``` ] ] --- ## `renv` Workflow .pull-left-40[ .move-down-110[ - `init()` - `snapshot()` ] ] .pull-right-60[ .move-up-100[ .code-small[ ``` #---- renv.lock ----# "DBI": { "Package": "DBI", "Version": "1.1.3", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "methods" ], "Hash": "d0d9a365c08b9a8b31c73c26057160b1" }, "HDInterval": { "Package": "HDInterval", "Version": "0.2.4", "Source": "Repository", "Repository": "CRAN", "Hash": "b5b77433b286dd869ff33ee7fd5c545f" }, "MASS": { "Package": "MASS", "Version": "7.3-58.3", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "grDevices", "graphics", "utils" ], "Hash": "9586b552d57f5516fe4d25398c1bacd6" } ``` ] ] ] --- ## `renv` Workflow .pull-left-40[ .move-down-110[ - `init()` - `snapshot()` - `restore()` ] ] .pull-right-60[ .move-down-50[ <img src="images/11-requirements/renv-active.png" width="80%" style="display: block; margin: auto;" /> ] .code-size-12[ ```r # Install packages as usual install.packages('<name-package>') # Capturing project's R package dependencies renv::snapshot() # Restore a project's dependencies renv::restore() ``` ] ] --- ## `renv` Workflow .pull-left-40[ .move-down-110[ - `init()` - `snapshot()` - `restore()` ] ] .pull-right-60[ .move-down-110[ <img src="images/11-requirements/renv-actions.png" width="80%" style="display: block; margin: auto;" /> ] ] --- ## `renv` Advanced Features -- .pull-left-50[ .move-down-80[ #### Files Structure ] .move-down-30[ <img src="images/11-requirements/proj-folder.png" width="80%" style="display: block; margin: auto;" /> ] ] .pull-right-50[ ] --- ## `renv` Advanced Features .pull-left-50[ .move-down-80[ #### Files Structure ] .move-down-30[ <img src="images/11-requirements/proj-folder.png" width="80%" style="display: block; margin: auto;" /> ] ] .pull-right-50[ .move-down-80[ .li-small[ - `.Rprofile` <img src="images/11-requirements/renv-rprofile.png" width="80%" style="display: block; margin: auto;" /> ] ] ] --- ## `renv` Advanced Features .pull-left-50[ .move-down-80[ #### Files Structure ] .move-down-30[ <img src="images/11-requirements/proj-folder.png" width="80%" style="display: block; margin: auto;" /> ] ] .pull-right-50[ .move-down-80[ .li-small[ - `.Rprofile` - `renv.lock` <img src="images/11-requirements/lock-file.png" width="80%" style="display: block; margin: auto;" /> ] ] ] --- ## `renv` Advanced Features .pull-left-50[ .move-down-80[ #### Files Structure ] .move-down-30[ <img src="images/11-requirements/proj-folder.png" width="80%" style="display: block; margin: auto;" /> ] ] .pull-right-50[ .move-down-80[ .li-small[ - `.Rprofile` - `renv.lock` - `renv/` <img src="images/11-requirements/renv-folder.png" width="80%" style="display: block; margin: auto;" /> ] ] ] --- ## `renv` Advanced Features <br> .pull-left-50[ #### Snapshot Types .li-small[ - `"all"` - `"implicit"` (default) - `"explicit"` (project `DESCRIPTION` file) - `"custom"` user-defined filter instead ] ] .pull-right-50[ .code-size-12[ {{content}} ] ] -- #### Detecting Packages ```r # Correctly detected by renv library("tidyverse") trackdown::upload_file(...) # Not detected by renv packages_list <- c("tidyverse", "trackdown") lapply(packages_list, library, character.only = TRUE) for (package in packages_list) { library(package, character.only = TRUE) } ``` --- ## `renv` Advanced Features <br> - R version ```r ## Warning: Project requested R version '3.6.1' but '4.1.0' is currently being used ``` -- - `.renvignore` File -- - Restore Issue(s) --- class: inverse, center, middle # A Package to Rule Them All ## Moving to the next step...