diff --git a/.Rbuildignore b/.Rbuildignore index b7ceba19e5445e957479aa32476ff28dbe54e840..179f6c2cb5cfafd3228a9b3488fe8bd40c9924b2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,3 +4,13 @@ ^public$ ^templates$ ^ci$ +^data-raw$ +^\.gitlab-ci\.yml$ +^\.vscode$ +^LICENSE\.md$ +^README\.Rmd$ +^man-examples$ +^public$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e29d471e32ea3445dec27ce79d0ac4a7863a10 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/rocker-org/devcontainer-templates/tree/main/src/r-ver +{ + "name": "R (rocker/geospatial)", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "rocker/geospatial:latest", + "customizations": { + "vscode": { + "extensions": [ + "janisdd.vscode-edit-csv", + "streetsidesoftware.code-spell-checker", + "eamodio.gitlens", + "REditorSupport.r" + ] + } + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "R -q -e 'install.packages(c(\"languageserver\"));remotes::install_deps(dep = TRUE)'", + "postStartCommand": "R -q -e 'devtools::install()'" + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitignore b/.gitignore index 39cf9fd097602c90cc296336e8765b42be2a9a02..c6dd0bedf822d84eca5c59f72eb9d3db1e197b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,5 @@ rsconnect/ /reports /templates /.vscode +docs +pkgdown diff --git a/DESCRIPTION b/DESCRIPTION index 19311b4d882018c7d1817fc513af0b4190700d6f..83b1737c11dd326f81452ff40e2999db970014f8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,12 +7,17 @@ Description: R-package proposing a framework to apply FAIR principles based on r License: AGPL (>= 3) Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Imports: bookdown, + config, gert, + httr, + jsonlite, magrittr, + pkgload, rlang, + urltools, usethis, yaml, zlib diff --git a/NAMESPACE b/NAMESPACE index 463745ba2479984957340ea089bf2091b8726353..bcf3d4df22f0d2f5a60cc75d6c472f39cd146966 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,9 +3,12 @@ export("%>%") export(add_gitignore) export(add_report) +export(cleanDataCache) export(create_fairify) export(create_reports) +export(getDataPath) export(iconv_filename) +export(loadConfig) export(mermaid) export(mermaid_gen_link) export(pkg_sys) @@ -13,4 +16,6 @@ export(purge_string) export(render_report) export(render_reports) export(updateMermaid) +export(update_fairify) +import(utils) importFrom(magrittr,"%>%") diff --git a/R/add_gitignore.R b/R/add_gitignore.R index 924fc93567980f9abf409c107bead22dc9bd6a34..9bf7ab9c6ec99ff2ed3219c6ec11840eca332182 100644 --- a/R/add_gitignore.R +++ b/R/add_gitignore.R @@ -8,9 +8,11 @@ #' @export #' #' @examples +#' \dontrun{ #' path <- tempdir() #' add_gitignore(path = path) #' readLines(file.path(path, ".gitignore")) +#' } add_gitignore <- function(path = ".", url = "https://raw.githubusercontent.com/github/gitignore/main/R.gitignore", additional_patterns = c("/public")) { diff --git a/R/cleanDataCache.R b/R/cleanDataCache.R new file mode 100644 index 0000000000000000000000000000000000000000..f6feb33ebc8aedb95a5cc97af091fd912d04d021 --- /dev/null +++ b/R/cleanDataCache.R @@ -0,0 +1,22 @@ +#' Clean the local data cache +#' +#' @description +#' This function is intented to be called by the same name function +#' in the fairify project. +#' +#' +#' @details +#' Raises an error if the deleting failed. +#' +#' +#' @inheritParams getDataPath +#' +#' @return This function is only used for side effect. +#' @export +#' +#' +cleanDataCache <- function(cache) { + r <- unlink(cache, recursive = TRUE, force = TRUE) + if (r != 0) stop("Clean data cache failed in folder: ", cache) + invisible() +} diff --git a/R/create_fairify.R b/R/create_fairify.R index 77055842788976c9324c6105428e4bcc79c3c9ca..de211c4bccc836bb05c92a22bc3ed19c2a51a948 100644 --- a/R/create_fairify.R +++ b/R/create_fairify.R @@ -1,10 +1,11 @@ -#' Create a "fairified" project +#' Create a "fairify" project #' #' Create a package ready for fairify your project. #' #' @inheritParams usethis::create_package -#' @param tidy if `TRUE`, run [usethis::use_testthat()], [usethis::use_tidy_description()], and [usethis::use_tidy_dependencies()] -#' @param with_reports If `TRUE`, run `create_reports`, preparing package structure for report publications +#' @param tidy if `TRUE`, run [usethis::use_testthat()], and [usethis::use_tidy_description()] +#' @param reports If `TRUE`, run `create_reports`, preparing package structure for report publications +#' @param cloud If `TRUE`, copy fairify functions for cloud capabilities #' @param git if `TRUE`, initialises a Git repository #' @param ... Further parameters passed to [usethis::create_package] #' @@ -13,18 +14,20 @@ #' #' @examples #' path <- tempfile(pattern = "dir") -#' create_fairify(path, open = FALSE) +#' create_fairify(path, open = FALSE, git = FALSE) #' list.files(path) create_fairify <- function(path, tidy = TRUE, check_name = FALSE, open = rlang::is_interactive(), - with_reports = TRUE, + reports = TRUE, + cloud = TRUE, git = TRUE, ...) { usethis::create_package(path, rstudio = TRUE, open = FALSE, check_name = check_name, ...) usethis::proj_set(path) + if (cloud) update_fairify(path) if (tidy) { usethis::local_project(path) usethis::use_testthat() @@ -34,10 +37,11 @@ create_fairify <- gert::git_init(path) add_gitignore(path) } - if (with_reports) - create_reports(path = path) + if (reports) + create_reports(path = path, git = git) usethis::use_package("fairify", "Depends") - #file.copy() + message("Fairify project created") + message("Don't forget to edit the file `inst/config.yml` for configuring the data location for your project") if (open) { usethis::proj_activate(path) } diff --git a/R/create_reports.R b/R/create_reports.R index 891500ee3b62c702ca236343d69de66675d2ef54..f367713c97716da095964bead66d43385beb830f 100644 --- a/R/create_reports.R +++ b/R/create_reports.R @@ -2,21 +2,22 @@ #' #' @param path Destination folder for reports and templates #' @param overwrite Allow overwriting templates folder +#' @param git add gitignore file suitable for TeX and HTML reports #' #' @return The path to the created reports folder. #' @export #' #' @examples #' # Create structure for reports -#' path <- tempfile(pattern = "dir") +#' path <- tempfile(pattern = "report-example") #' dir.create(path) -#' create_reports(path) +#' create_reports(path, git = FALSE) #' list.files(path, recursive = TRUE) #' #' # Add a new report #' report_path <- add_report("my_report", path) #' list.files(report_path) -create_reports <- function(path = ".", overwrite = FALSE) { +create_reports <- function(path = ".", overwrite = FALSE, git = TRUE) { # Copy templates if (dir.exists(file.path(path, "templates"))) { if (overwrite) { @@ -35,9 +36,13 @@ create_reports <- function(path = ".", overwrite = FALSE) { # Create reports folder reports_path <- file.path(path, "reports") - dir.create(reports_path) - add_gitignore(reports_path, - url = "https://raw.githubusercontent.com/github/gitignore/main/TeX.gitignore", - additional_patterns = readLines(pkg_sys("reports_gitignore.txt"))) + dir.create(reports_path, showWarnings = FALSE) + if (git) { + add_gitignore( + reports_path, + url = "https://raw.githubusercontent.com/github/gitignore/main/TeX.gitignore", + additional_patterns = readLines(pkg_sys("reports_gitignore.txt")) + ) + } invisible(file.path(path, "reports")) } diff --git a/R/fairify-package.R b/R/fairify-package.R new file mode 100644 index 0000000000000000000000000000000000000000..c7eb451f9a639ac660596bfbf92a8e8e55a80111 --- /dev/null +++ b/R/fairify-package.R @@ -0,0 +1,12 @@ +#' @title fairify: a package for creating FAIR reports +#' +#' @description +#' ```{r child = "man-examples/fairify.md"} +#' ``` +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +#' @import utils +## usethis namespace: end +NULL diff --git a/R/getDataPath.R b/R/getDataPath.R new file mode 100644 index 0000000000000000000000000000000000000000..06507121fb9e94036b0851bdb55283f9c62eeabe --- /dev/null +++ b/R/getDataPath.R @@ -0,0 +1,81 @@ +#' Give the complete path of the data and cache data on local disk +#' +#' @description +#' It supports Nextcloud public links in case of using cloud. In this case, +#' this function can download the file in a temporary +#' folder and returns the path of the downloaded file. +#' This functionality is useful for `read_excel` from the package *readxl* +#' (See: https://stackoverflow.com/a/41368947/5300212). +#' +#' @param path [character] representing the path of the data in the database +#' @param ... [character] path elements to add after `path` +#' @param use_cache [logical] download the data and use cache location +#' @param root [character] URL or path of the database root +#' @param cache [character] path where downloaded files from cloud are cached (See details) +#' @param cfg a config object. Configuration to use. See [loadConfig] for details +#' +#' @details +#' The cache directory is by default located in the system temporary folder in a +#' subdirectory named as the package name or the value of the environment variable +#' "PKG_DATA_CACHE" if it is defined. +#' +#' @return [character] with the path of the file to read either on: +#' - the local storage if `cfg$data$mode == "local"` +#' - the cache directory if `cfg$data$mode != "local"` and `use_cache == TRUE` +#' - the cloud URL if `cfg$data$mode != "local"` and `use_cache == FALSE` +#' @export +#' +getDataPath <- function(path, + ..., + use_cache = TRUE, + cfg, + root = cfg$data[[cfg$data$mode]], + cache) { + path <- file.path(path, ...) + stopifnot(is.character(path), + length(path) == 1) + + if (cfg$data$mode != "local") { + file <- basename(path) + ext <- tools::file_ext(file) + + folder <- dirname(path) + # model of link on Nextcloud https://nextcloud.inrae.fr/s/QbwR7yCo2HSDCb9/download?path=hydrometrie&files=Hydrometrie_site.csv + query <- file.path(root, "download") + query <- urltools::param_set(query, + key = "path", + value = urltools::url_encode(folder)) + query <- urltools::param_set(query, + key = "files", + value = urltools::url_encode(file)) + + if (use_cache) { + exdir <- cache + if (folder != ".") { + exdir <- file.path(exdir, folder) + } + dir.create(exdir, showWarnings = FALSE, recursive = TRUE) + path <- file.path(exdir, file) + if (!file.exists(path)) { + message("Download from URL: ", query) + resp <- httr::GET(query, + httr::write_disk(path)) + if (!identical(httr::status_code(resp), 200L)) { + stop("Error ", httr::status_code(resp), " on query ", query) + } + if (ext == "") { + # Folder in ZIP format + zipfile <- paste(path, "zip", sep = ".") + file.rename(path, zipfile) + utils::unzip(zipfile, exdir = exdir) + unlink(zipfile) + } + } + return(path) + } else { + return(query) + } + } else { + return(file.path(root, path)) + } +} diff --git a/R/loadConfig.R b/R/loadConfig.R new file mode 100644 index 0000000000000000000000000000000000000000..c06bc098021be2dd8d8040570df291ce9dcabc73 --- /dev/null +++ b/R/loadConfig.R @@ -0,0 +1,38 @@ +#' Read package configuration +#' +#' Read default package configuration and complete it with eventual user config. +#' +#' @details +#' User file configuration (by default the `config.yml` file in the working +#' directory) can overwrite items of the default configuration (See examples). +#' +#' @param userFile location of the user config YML file +#' @param pathDefaultCfg The location of the default configuration (located in "inst/config.yml" of the package by default) +#' +#' @return A configuration as it is returned by [config::get] +#' @export +#' +loadConfig <- function(userFile = "config.yml", pathDefaultCfg) { + if (userFile == basename(userFile)) { + # Search in package sub folders + pkg_path <- pkgload::pkg_path() + current_path <- getwd() + repeat { + userFile <- file.path(current_path, basename(userFile)) + if (file.exists(userFile) || current_path == pkg_path) break + current_path <- dirname(current_path) + } + } + cfg <- config::get(file = pathDefaultCfg) + if (file.exists(userFile)) { + message("Read user configuration from: ", userFile) + cfg = config::merge(cfg,config::get(file = userFile)) + } + stopifnot(cfg$data$mode %in% c("local", "remote"), + is.logical(cfg$data$write_results)) + if (cfg$data$write_results && cfg$data$mode == "remote") { + warning("cfg$data$write_results is forced to `FALSE` in 'remote' mode") + cfg$data$write_results <- FALSE + } + cfg +} diff --git a/R/render_report.R b/R/render_report.R index 01f7af69512f3e1b2486da64cb55394deca94c43..e62d237f88d13ad58474101c54edbda73f09d244 100644 --- a/R/render_report.R +++ b/R/render_report.R @@ -10,7 +10,7 @@ render_report <- function(input, stopifnot(output_format %in% c("bookdown::gitbook", "bookdown::pdf_book")) if (output_format == "bookdown::pdf_book") { - if (!require("tinytex")) install.packages("tinytex") + if (!requireNamespace("tinytex", quietly=TRUE)) install.packages("tinytex") } message("output_format=", output_format) diff --git a/R/render_reports.R b/R/render_reports.R index 35f29fde8a3cf07d17e40fcd207f0f10d02538e5..22243a7511e9ac24ef7c0892c4c47b3b72093fb4 100644 --- a/R/render_reports.R +++ b/R/render_reports.R @@ -13,7 +13,8 @@ #' @export #' @rdname render_reports #' -#' @examples +#' @example man-examples/render_reports.R +#' render_reports <- function(reports_dir = "./reports", reports = list.dirs(reports_dir, full.names = FALSE, recursive = FALSE), publish_dir = "../../public/reports", diff --git a/R/update_fairify.R b/R/update_fairify.R new file mode 100644 index 0000000000000000000000000000000000000000..83c0f8a99120c10d4351af2ae6dd494bfe6437f5 --- /dev/null +++ b/R/update_fairify.R @@ -0,0 +1,32 @@ +#' Update or install the fairify functions and default configuration +#' in a project created with fairify +#' +#' @param path Path of the fairify project or inside the fairify project +#' +#' @return Use for side effect. +#' @export +#' +update_fairify <- function(path = ".") { + path <- pkgload::pkg_path(path) + b <- file.copy( + from = list.files(system.file("functions", package = "fairify"), full.names = TRUE), + to = file.path(path, "R"), + overwrite = TRUE + ) + if (any(!b)) { + stop("Error during the copy of fairify functions") + } + to = file.path(path, "inst") + if (file.exists(file.path(path, "inst", "config.yml"))) { + warning("config.yml already exists in the target project") + } else { + dir.create(file.path(path, "inst"), showWarnings = FALSE) + b <- file.copy( + from = system.file("config.yml", package = "fairify"), + to = file.path(path, "inst", "config.yml") + ) + if (any(!b)) { + stop("Error during the copy of default configuration") + } + } +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..725005d7ad0772b801759974824f4ca3ab722e43 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,41 @@ +--- +output: github_document +--- + +<!-- README.md is generated from README.Rmd. Please edit that file --> + +```{r opts, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# fairify: an R package for creating FAIR reports + +<img src="man/figures/logo.png" align="right" style="float: right; height: 220px; margin: 15px;"/> + +FAIR principles stands for **F**indability, **A**ccessibility, **I**nteroperability, and **R**euse. + +This package provide tools to help you to create reports based on Rmarkdown with +data stored on the cloud. + +**fairify** currently supports data access Owncloud/Nextcloud servers and provides +templates for Inrae website and PDF reports. + +## Installation + +```r +# install.packages("remotes") +remotes::install_git( + "https://forgemia.inra.fr/david.dorchies/fairify.git", + dependencies = TRUE +) +``` + +```{r import_documentationchild, results='asis', echo=FALSE} +s <- readLines("man-examples/fairify.md") +cat(paste(s, collapse = "\n")) +``` diff --git a/README.md b/README.md index da69cf38e2b604c61337a4011fd1c97fda7f8b79..6facf1adaa982e090d683299d9b8782626b78825 100644 --- a/README.md +++ b/README.md @@ -1,91 +1,204 @@ -# fairify: an R package for creating FAIR reports +<!-- README.md is generated from README.Rmd. Please edit that file --> -## Getting started +# fairify: an R package for creating FAIR reports -To make it easy for you to get started with GitLab, here's a list of recommended next steps. +<img src="man/figures/logo.png" align="right" style="float: right; height: 220px; margin: 15px;"/> -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +FAIR principles stands for **F**indability, **A**ccessibility, +**I**nteroperability, and **R**euse. -## Add your files +This package provide tools to help you to create reports based on +Rmarkdown with data stored on the cloud. -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: +**fairify** currently supports data access Owncloud/Nextcloud servers +and provides templates for Inrae website and PDF reports. -``` -cd existing_repo -git remote add origin https://forgemia.inra.fr/in-wop/fairify.git -git branch -M main -git push -uf origin main +## Installation + +``` r +# install.packages("remotes") +remotes::install_git( + "https://forgemia.inra.fr/david.dorchies/fairify.git", + dependencies = TRUE +) ``` -## Integrate with your tools +## Create a *fairify* project -- [ ] [Set up project integrations](https://forgemia.inra.fr/in-wop/fairify/-/settings/integrations) +`create_fairify` creates a R-package skeleton with several and open your +project on Rstudio: -## Collaborate with your team + # Create a project in a temporary folder for the example + path <- file.path(tempdir(), "my_fairify_project") + fairify::create_fairify(path) -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) + ## ✔ Creating 'C:/Users/DDORCH~1/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project/' + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + ## ✔ Creating 'R/' + ## ✔ Writing 'DESCRIPTION' -## Test and Deploy + ## Package: my_fairify_project + ## Title: What the Package Does (One Line, Title Case) + ## Version: 0.0.0.9000 + ## Authors@R (parsed): + ## * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID) + ## Description: What the package does (one paragraph). + ## License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a + ## license + ## Encoding: UTF-8 + ## Roxygen: list(markdown = TRUE) + ## RoxygenNote: 7.3.1 -Use the built-in continuous integration in GitLab. + ## ✔ Writing 'NAMESPACE' + ## ✔ Writing 'my_fairify_project.Rproj' + ## ✔ Adding '^my_fairify_project\\.Rproj$' to '.Rbuildignore' + ## ✔ Adding '.Rproj.user' to '.gitignore' + ## ✔ Adding '^\\.Rproj\\.user$' to '.Rbuildignore' + ## ✔ Setting active project to '<no active project>' + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + ## ✔ Adding 'testthat' to Suggests field in DESCRIPTION + ## ✔ Adding '3' to Config/testthat/edition + ## ✔ Creating 'tests/testthat/' + ## ✔ Writing 'tests/testthat.R' + ## • Call `use_test()` to initialize a basic test file and open it for editing. + ## ✔ Adding 'fairify' to Depends field in DESCRIPTION + ## • Are you sure you want Depends? Imports is almost always the better choice. + ## Fairify project created + ## + ## Don't forget to edit the file `inst/config.yml` for configuring the data location for your project + ## + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) + list.files(path) -*** + ## [1] "DESCRIPTION" "inst" + ## [3] "my_fairify_project.Rproj" "NAMESPACE" + ## [5] "R" "reports" + ## [7] "templates" "tests" -# Editing this README +## Create reports with **bookdown** -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +By default, the *fairify* project contains a `reports` folder which +contains bookdown reports. -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. +Use the function `fairify::add_report` for creating a new report. -## Name -Choose a self-explaining name for your project. + # Create a report + fairify::add_report("my_report", path) -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. + ## [1] "C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT/my_fairify_project/reports/my_report" -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. + # Add a chapter + writeLines( + c( + "# A new chapter", + "", + "With a new paragraph." + ), + file.path(path, "reports/my_report/01-new_chapter.Rmd") + ) -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +## Render reports -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +By default, the reports are rendered in the public folder of the +*fairify* project. + + # Render the report in HTML format + fairify::render_reports(reports_dir = file.path(path, "reports")) + + ## folder list: + + ## my_report + + ## ******************************************************************* + + ## ** RENDER my_report + + ## ******************************************************************* + + ## output_format=bookdown::gitbook + + ## Rendering book in directory 'C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT/my_fairify_project/reports/my_report' + + ## processing file: report.Rmd + + ## output file: report.knit.md + + ## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS report.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output report.html --lua-filter "C:\Users\ddorchies\AppData\Local\Programs\R\R-4.2.2\library\bookdown\rmarkdown\lua\custom-environment.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\latex-div.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\anchor-sections.lua" --metadata-file "C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT\file384434cd7298" --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\Users\ddorchies\AppData\Local\Programs\R\R-4.2.2\library\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --css style.css --mathjax --include-in-header "C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT\rmarkdown-str384462592dc7.html" --citeproc + + ## + ## Output created: ../../public/reports/my_report/index.html + + # Render the report in PDF format + fairify::render_reports(reports_dir = file.path(path, "reports"), + output_format = "bookdown::pdf_book") + + ## folder list: + + ## my_report + + ## ******************************************************************* + + ## ** RENDER my_report + + ## ******************************************************************* + + ## Loading required package: tinytex + + ## Warning: package 'tinytex' was built under R version 4.2.3 + + ## output_format=bookdown::pdf_book + + ## Rendering book in directory 'C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT/my_fairify_project/reports/my_report' + + ## processing file: report.Rmd + + ## output file: report.knit.md + + ## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS report.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output report.tex --lua-filter "C:\Users\ddorchies\AppData\Local\Programs\R\R-4.2.2\library\bookdown\rmarkdown\lua\custom-environment.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\latex-div.lua" --metadata-file "C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT\file38447a441ba0" --embed-resources --standalone --table-of-contents --toc-depth 2 --number-sections --highlight-style tango --pdf-engine pdflatex --biblatex --include-in-header "..\..\templates\umr_geau\preamble.tex" --include-after-body "..\..\templates\inrae\after_body.tex" --variable graphics --wrap preserve --variable tables=yes --standalone -Mhas-frontmatter=false + + ## + ## Output created: ../../public/reports/my_report/report.pdf + +## Use data located on the cloud (or not…) + +### How it works? -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. +The *fairify* project provides a function `getDataPath` which helps you +to use data located on the cloud in your R scripts. -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. +List of supported cloud servers: -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. +- [Owncloud](https://owncloud.com/) +- [Nextcloud](https://nextcloud.com/) -## Contributing -State if you are open to contributions and what your requirements are for accepting them. +To use it, you first need to define your cloud configuration in the file +`inst/config.yml`: -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. + default: + data: + mode: remote + local: "path_for_data_on_your_disk" + remote: "https://public_link_on_your_cloud" + write_results: false -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +The `local` path stands for storing your data on a local or network disk +directly readable and writable by your Operating System. -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +### Caching results -## License -For open source projects, say how it is licensed. +`write_results` logical parameter is an helper for caching data results +of long calculations. The basic strategy is to either calculate and save +a result or read this result depending of the value of this boolean: -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. + computeSomeThing <- function(cfg = loadConfig()) { + if (cfg$data$write_results) { + myBigResult <- 2 + 2 + saveRDS(myBigResult, getDataPath("myBigResult.RDS")) + } else { + myBigResult <- readRDS(getDataPath("myBigResult.RDS")) + } + return(myBigResult) + } diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000000000000000000000000000000000000..d71acfb90c81b09bc8b25aad2115925afcd1ff7d --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,4 @@ +url: ~ +template: + bootstrap: 5 + diff --git a/data-raw/fair_symbols3.png b/data-raw/fair_symbols3.png new file mode 100644 index 0000000000000000000000000000000000000000..5791fd5c402dc808eb8dd339aab14aadeca7ee61 Binary files /dev/null and b/data-raw/fair_symbols3.png differ diff --git a/data-raw/make_hex_logo.R b/data-raw/make_hex_logo.R new file mode 100644 index 0000000000000000000000000000000000000000..d8924bd9b4501c1f156331a5b6a83d64adbdbd2d --- /dev/null +++ b/data-raw/make_hex_logo.R @@ -0,0 +1,17 @@ +library(showtext) +## Loading Google fonts (http://www.google.com/fonts) +font_add_google("Raleway", "Raleway") +## Automatically use showtext to render text for future devices +showtext_auto() + + +hexSticker::sticker("data-raw/fair_symbols3.png", + s_x = 1, s_y = 1, s_width = .68, + package="fairify", + p_y = 1, p_size = 48, + p_family = "Raleway", + p_fontface = "bold", + p_color = InraeThemes::palette_inrae()["inrae_taupe_clair"], + h_fill = InraeThemes::palette_inrae()["inrae"], + h_color = InraeThemes::palette_inrae()["inrae_cyan"], + filename ="man/figures/logo.png") diff --git a/inst/config.yml b/inst/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..de186d70232d4bf35a15740797463cf6538f181d --- /dev/null +++ b/inst/config.yml @@ -0,0 +1,6 @@ +default: + data: + mode: remote + local: "path_for_data_on_your_disk" + remote: "https://public_link_on_your_cloud" + write_results: false diff --git a/inst/functions/cleanDataCache.R b/inst/functions/cleanDataCache.R new file mode 100644 index 0000000000000000000000000000000000000000..0bddab40141721bf0d223d94c2d06924d0b3f834 --- /dev/null +++ b/inst/functions/cleanDataCache.R @@ -0,0 +1,7 @@ +#' @inherit fairify::cleanDataCache +#' @export +cleanDataCache <- function(cache = Sys.getenv("PKG_DATA_CACHE", + file.path(dirname(tempdir()), + utils::packageName()))) { + fairify::cleanDataCache(cache = cache) +} diff --git a/inst/functions/getDataPath.R b/inst/functions/getDataPath.R new file mode 100644 index 0000000000000000000000000000000000000000..0d365660806eaf7fa4b686a4a477926341110553 --- /dev/null +++ b/inst/functions/getDataPath.R @@ -0,0 +1,17 @@ +#' @inherits fairify::getDataPath +#' @export +getDataPath <- function(path, + ..., + use_cache = TRUE, + cfg = loadConfig(), + root = cfg$data[[cfg$data$mode]], + cache = Sys.getenv("PKG_DATA_CACHE", + file.path(dirname(tempdir()), + utils::packageName()))) { + fairify::getDataPath(path, + ..., + use_cache = use_cache, + cfg = cfg, + root = root, + cache = cache) +} diff --git a/inst/functions/loadConfig.R b/inst/functions/loadConfig.R new file mode 100644 index 0000000000000000000000000000000000000000..caeac6b240921936c77f0570cad3f67c1d231633 --- /dev/null +++ b/inst/functions/loadConfig.R @@ -0,0 +1,5 @@ +#' @inherit fairify::loadConfig +#' @export +loadConfig <- function(userFile = "config.yml", pathDefaultCfg = system.file("config.yml", package = utils::packageName())) { + fairify::loadConfig(userFile = userFile, pathDefaultCfg = pathDefaultCfg) +} diff --git a/inst/templates/inrae/preamble.tex b/inst/templates/inrae/preamble.tex index 78b1f9920dc92cb1ac1de59d7e686fdde557512f..688f8bbf346e194b1065df3ab581dac3875618aa 100644 --- a/inst/templates/inrae/preamble.tex +++ b/inst/templates/inrae/preamble.tex @@ -7,7 +7,7 @@ \input{../../templates/inrae/preambule_inrae.tex} -\usepackage[french]{babel} +%\usepackage[french]{babel} \newcommand{\service}{UMR G-EAU} \newcommand{\site}{ diff --git a/inst/templates/inrae/preambule_inrae.tex b/inst/templates/inrae/preambule_inrae.tex index 5ca73c93a6c59fd429a8e353f16b9e365a758f63..93f21f08a7b5cd491f5cb46fbc70b843178f652d 100644 --- a/inst/templates/inrae/preambule_inrae.tex +++ b/inst/templates/inrae/preambule_inrae.tex @@ -9,7 +9,7 @@ \usepackage[style=authoryear,]{biblatex} % Keep lower case in biblatex French % https://tex.stackexchange.com/questions/438423/keep-lowercase-in-biblatex -\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily} +%\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily} % Beau tableau \usepackage{booktabs} diff --git a/inst/templates/umr_geau/preamble.tex b/inst/templates/umr_geau/preamble.tex index 89cad8fdabedfea519bfa67cfe78252157713c94..900866aa7905d47dc1212907eca70f4c4a539175 100644 --- a/inst/templates/umr_geau/preamble.tex +++ b/inst/templates/umr_geau/preamble.tex @@ -2,7 +2,7 @@ % BEGIN PREAMBLE.TEX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\usepackage[french]{babel} +%\usepackage[french]{babel} \newcommand{\insertsecondlogo}{\includegraphics[width=4cm]{../../templates/umr_geau/logo_umr_geau.png}} \newcommand{\insertthirdlogo}{} diff --git a/man-examples/fairify.Rmd b/man-examples/fairify.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..c09ad11d5a4e9d066d46dd4f69b21a4ecbb36526 --- /dev/null +++ b/man-examples/fairify.Rmd @@ -0,0 +1,100 @@ +--- +title: "Fairify" +author: "David Dorchies" +output: md_document +--- + + +## Create a _fairify_ project + +`create_fairify` creates a R-package skeleton with several and open your project +on Rstudio: + +```{r} +# Create a project in a temporary folder for the example +path <- file.path(tempdir(), "my_fairify_project") +fairify::create_fairify(path) +list.files(path) +``` + + +## Create reports with **bookdown** + +By default, the _fairify_ project contains a `reports` folder which contains +bookdown reports. + +Use the function `fairify::add_report` for creating a new report. + +```{r} +# Create a report +fairify::add_report("my_report", path) + +# Add a chapter +writeLines( + c( + "# A new chapter", + "", + "With a new paragraph." + ), + file.path(path, "reports/my_report/01-new_chapter.Rmd") +) +``` + +## Render reports + +By default, the reports are rendered in the public folder of the _fairify_ project. + +```{r} +# Render the report in HTML format +fairify::render_reports(reports_dir = file.path(path, "reports")) + +# Render the report in PDF format +fairify::render_reports(reports_dir = file.path(path, "reports"), + output_format = "bookdown::pdf_book") +``` + + +## Use data located on the cloud (or not...) + +### How it works? + +The _fairify_ project provides a function `getDataPath` which helps you to +use data located on the cloud in your R scripts. + +List of supported cloud servers: + +- [Owncloud](https://owncloud.com/) +- [Nextcloud](https://nextcloud.com/) + +To use it, you first need to define your cloud configuration in the file +`inst/config.yml`: + +```yaml +default: + data: + mode: remote + local: "path_for_data_on_your_disk" + remote: "https://public_link_on_your_cloud" + write_results: false +``` + +The `local` path stands for storing your data on a local or network disk directly +readable and writable by your Operating System. + +### Caching results + +`write_results` logical parameter is an helper for caching data results of +long calculations. The basic strategy is to either calculate and save a result or +read this result depending of the value of this boolean: + +```r +computeSomeThing <- function(cfg = loadConfig()) { + if (cfg$data$write_results) { + myBigResult <- 2 + 2 + saveRDS(myBigResult, getDataPath("myBigResult.RDS")) + } else { + myBigResult <- readRDS(getDataPath("myBigResult.RDS")) + } + return(myBigResult) +} +``` diff --git a/man-examples/fairify.md b/man-examples/fairify.md new file mode 100644 index 0000000000000000000000000000000000000000..c773ff8fe0d4848c57a0e5a8e99eceb079f219f6 --- /dev/null +++ b/man-examples/fairify.md @@ -0,0 +1,178 @@ +## Create a *fairify* project + +`create_fairify` creates a R-package skeleton with several and open your +project on Rstudio: + + # Create a project in a temporary folder for the example + path <- file.path(tempdir(), "my_fairify_project") + fairify::create_fairify(path) + + ## ✔ Creating 'C:/Users/DDORCH~1/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project/' + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + ## ✔ Creating 'R/' + ## ✔ Writing 'DESCRIPTION' + + ## Package: my_fairify_project + ## Title: What the Package Does (One Line, Title Case) + ## Version: 0.0.0.9000 + ## Authors@R (parsed): + ## * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID) + ## Description: What the package does (one paragraph). + ## License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a + ## license + ## Encoding: UTF-8 + ## Roxygen: list(markdown = TRUE) + ## RoxygenNote: 7.3.1 + + ## ✔ Writing 'NAMESPACE' + ## ✔ Writing 'my_fairify_project.Rproj' + ## ✔ Adding '^my_fairify_project\\.Rproj$' to '.Rbuildignore' + ## ✔ Adding '.Rproj.user' to '.gitignore' + ## ✔ Adding '^\\.Rproj\\.user$' to '.Rbuildignore' + ## ✔ Setting active project to '<no active project>' + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + ## ✔ Adding 'testthat' to Suggests field in DESCRIPTION + ## ✔ Adding '3' to Config/testthat/edition + ## ✔ Creating 'tests/testthat/' + ## ✔ Writing 'tests/testthat.R' + ## • Call `use_test()` to initialize a basic test file and open it for editing. + ## ✔ Adding 'fairify' to Depends field in DESCRIPTION + ## • Are you sure you want Depends? Imports is almost always the better choice. + ## Fairify project created + ## + ## Don't forget to edit the file `inst/config.yml` for configuring the data location for your project + ## + ## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + + list.files(path) + + ## [1] "DESCRIPTION" "inst" + ## [3] "my_fairify_project.Rproj" "NAMESPACE" + ## [5] "R" "reports" + ## [7] "templates" "tests" + +## Create reports with **bookdown** + +By default, the *fairify* project contains a `reports` folder which +contains bookdown reports. + +Use the function `fairify::add_report` for creating a new report. + + # Create a report + fairify::add_report("my_report", path) + + ## [1] "C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT/my_fairify_project/reports/my_report" + + # Add a chapter + writeLines( + c( + "# A new chapter", + "", + "With a new paragraph." + ), + file.path(path, "reports/my_report/01-new_chapter.Rmd") + ) + +## Render reports + +By default, the reports are rendered in the public folder of the +*fairify* project. + + # Render the report in HTML format + fairify::render_reports(reports_dir = file.path(path, "reports")) + + ## folder list: + + ## my_report + + ## ******************************************************************* + + ## ** RENDER my_report + + ## ******************************************************************* + + ## output_format=bookdown::gitbook + + ## Rendering book in directory 'C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT/my_fairify_project/reports/my_report' + + ## processing file: report.Rmd + + ## output file: report.knit.md + + ## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS report.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output report.html --lua-filter "C:\Users\ddorchies\AppData\Local\Programs\R\R-4.2.2\library\bookdown\rmarkdown\lua\custom-environment.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\latex-div.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\anchor-sections.lua" --metadata-file "C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT\file384434cd7298" --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\Users\ddorchies\AppData\Local\Programs\R\R-4.2.2\library\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --css style.css --mathjax --include-in-header "C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT\rmarkdown-str384462592dc7.html" --citeproc + + ## + ## Output created: ../../public/reports/my_report/index.html + + # Render the report in PDF format + fairify::render_reports(reports_dir = file.path(path, "reports"), + output_format = "bookdown::pdf_book") + + ## folder list: + + ## my_report + + ## ******************************************************************* + + ## ** RENDER my_report + + ## ******************************************************************* + + ## Loading required package: tinytex + + ## Warning: package 'tinytex' was built under R version 4.2.3 + + ## output_format=bookdown::pdf_book + + ## Rendering book in directory 'C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT/my_fairify_project/reports/my_report' + + ## processing file: report.Rmd + + ## output file: report.knit.md + + ## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS report.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output report.tex --lua-filter "C:\Users\ddorchies\AppData\Local\Programs\R\R-4.2.2\library\bookdown\rmarkdown\lua\custom-environment.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\ddorchies\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\latex-div.lua" --metadata-file "C:\Users\DDORCH~1\AppData\Local\Temp\RtmpkNEQuT\file38447a441ba0" --embed-resources --standalone --table-of-contents --toc-depth 2 --number-sections --highlight-style tango --pdf-engine pdflatex --biblatex --include-in-header "..\..\templates\umr_geau\preamble.tex" --include-after-body "..\..\templates\inrae\after_body.tex" --variable graphics --wrap preserve --variable tables=yes --standalone -Mhas-frontmatter=false + + ## + ## Output created: ../../public/reports/my_report/report.pdf + +## Use data located on the cloud (or not…) + +### How it works? + +The *fairify* project provides a function `getDataPath` which helps you +to use data located on the cloud in your R scripts. + +List of supported cloud servers: + +- [Owncloud](https://owncloud.com/) +- [Nextcloud](https://nextcloud.com/) + +To use it, you first need to define your cloud configuration in the file +`inst/config.yml`: + + default: + data: + mode: remote + local: "path_for_data_on_your_disk" + remote: "https://public_link_on_your_cloud" + write_results: false + +The `local` path stands for storing your data on a local or network disk +directly readable and writable by your Operating System. + +### Caching results + +`write_results` logical parameter is an helper for caching data results +of long calculations. The basic strategy is to either calculate and save +a result or read this result depending of the value of this boolean: + + computeSomeThing <- function(cfg = loadConfig()) { + if (cfg$data$write_results) { + myBigResult <- 2 + 2 + saveRDS(myBigResult, getDataPath("myBigResult.RDS")) + } else { + myBigResult <- readRDS(getDataPath("myBigResult.RDS")) + } + return(myBigResult) + } diff --git a/man-examples/loadConfig.R b/man-examples/loadConfig.R new file mode 100644 index 0000000000000000000000000000000000000000..73cbad6ee11785cabf9137228f65d77954d17329 --- /dev/null +++ b/man-examples/loadConfig.R @@ -0,0 +1,10 @@ +# Create a temporary fairify project +path <- tempfile(pattern = "loadConfig") +create_fairify(path, open = FALSE, git = FALSE) + +# Load the created fairify project +pkgload::load_all(path) + +# Load the default config provided by fairify +cfg <- loadConfig() +str(cfg) diff --git a/man-examples/render_reports.R b/man-examples/render_reports.R new file mode 100644 index 0000000000000000000000000000000000000000..1a2a5f9b285344db9a1d11cab96d47b91abdeb74 --- /dev/null +++ b/man-examples/render_reports.R @@ -0,0 +1,27 @@ +# Create a fairify project in a temporary folder +path <- tempfile(pattern = "fairify_") +fairify::create_fairify(path, git = FALSE, open = FALSE) +owd <- setwd(path) + +# Create a report +fairify::add_report("my_report") + +# Add a chapter +writeLines( + c( + "# A new chapter", + "", + "With a new paragraph." + ), + file.path(path, "reports", "my_report", "01-new_chapter.Rmd") +) + +# Render the report in HTML format +render_reports(reports_dir = file.path(path, "reports")) + +# Render the report in PDF format +render_reports(reports_dir = file.path(path, "reports"), + output_format = "bookdown::pdf_book") + +# Back to initial working directory +setwd(owd) diff --git a/man/add_gitignore.Rd b/man/add_gitignore.Rd index e6e5b6b8ef42973233ba31450554c51e3a34576e..19eb509e75fac42a5ee332249d5fab4d346b6ade 100644 --- a/man/add_gitignore.Rd +++ b/man/add_gitignore.Rd @@ -25,7 +25,9 @@ created, provided that the parent path exists.} Add .gitignore file suitable for R project } \examples{ +\dontrun{ path <- tempdir() add_gitignore(path = path) readLines(file.path(path, ".gitignore")) } +} diff --git a/man/add_report.Rd b/man/add_report.Rd index 2850c75444a8f1215984e1dd8c08e28be72b44d0..86ee2df69013fe698a7350c1128d1a164981c489 100644 --- a/man/add_report.Rd +++ b/man/add_report.Rd @@ -19,9 +19,9 @@ Add a new report in a fairify project } \examples{ # Create structure for reports -path <- tempfile(pattern = "dir") +path <- tempfile(pattern = "report-example") dir.create(path) -create_reports(path) +create_reports(path, git = FALSE) list.files(path, recursive = TRUE) # Add a new report diff --git a/man/cleanDataCache.Rd b/man/cleanDataCache.Rd new file mode 100644 index 0000000000000000000000000000000000000000..0e336cdf9de5e904d611c6e27ed393c9736de59b --- /dev/null +++ b/man/cleanDataCache.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cleanDataCache.R +\name{cleanDataCache} +\alias{cleanDataCache} +\title{Clean the local data cache} +\usage{ +cleanDataCache(cache) +} +\arguments{ +\item{cache}{\link{character} path where downloaded files from cloud are cached (See details)} +} +\value{ +This function is only used for side effect. +} +\description{ +This function is intented to be called by the same name function +in the fairify project. +} +\details{ +Raises an error if the deleting failed. +} diff --git a/man/create_fairify.Rd b/man/create_fairify.Rd index 20bd01f831a043cacb321668d4de5828a34b65b8..a75d25f9652635e4a13bbdff58b7dfbd752bec29 100644 --- a/man/create_fairify.Rd +++ b/man/create_fairify.Rd @@ -2,14 +2,15 @@ % Please edit documentation in R/create_fairify.R \name{create_fairify} \alias{create_fairify} -\title{Create a "fairified" project} +\title{Create a "fairify" project} \usage{ create_fairify( path, tidy = TRUE, check_name = FALSE, open = rlang::is_interactive(), - with_reports = TRUE, + reports = TRUE, + cloud = TRUE, git = TRUE, ... ) @@ -18,7 +19,7 @@ create_fairify( \item{path}{A path. If it exists, it is used. If it does not exist, it is created, provided that the parent path exists.} -\item{tidy}{if \code{TRUE}, run \code{\link[usethis:use_testthat]{usethis::use_testthat()}}, \code{\link[usethis:tidyverse]{usethis::use_tidy_description()}}, and \code{\link[usethis:tidyverse]{usethis::use_tidy_dependencies()}}} +\item{tidy}{if \code{TRUE}, run \code{\link[usethis:use_testthat]{usethis::use_testthat()}}, and \code{\link[usethis:tidyverse]{usethis::use_tidy_description()}}} \item{check_name}{Whether to check if the name is valid for CRAN and throw an error if not.} @@ -30,7 +31,9 @@ error if not.} \item Otherwise, the working directory and active project is changed. }} -\item{with_reports}{If \code{TRUE}, run \code{create_reports}, preparing package structure for report publications} +\item{reports}{If \code{TRUE}, run \code{create_reports}, preparing package structure for report publications} + +\item{cloud}{If \code{TRUE}, copy fairify functions for cloud capabilities} \item{git}{if \code{TRUE}, initialises a Git repository} @@ -44,6 +47,6 @@ Create a package ready for fairify your project. } \examples{ path <- tempfile(pattern = "dir") -create_fairify(path, open = FALSE) +create_fairify(path, open = FALSE, git = FALSE) list.files(path) } diff --git a/man/create_reports.Rd b/man/create_reports.Rd index cf6fd51cdbcd13891b9d5c18603d61b078795dbc..1ae54c1879d191f6fc59df89f2c36b98efd1d485 100644 --- a/man/create_reports.Rd +++ b/man/create_reports.Rd @@ -4,12 +4,14 @@ \alias{create_reports} \title{Set reports folder structure} \usage{ -create_reports(path = ".", overwrite = FALSE) +create_reports(path = ".", overwrite = FALSE, git = TRUE) } \arguments{ \item{path}{Destination folder for reports and templates} \item{overwrite}{Allow overwriting templates folder} + +\item{git}{add gitignore file suitable for TeX and HTML reports} } \value{ The path to the created reports folder. @@ -19,9 +21,9 @@ Set reports folder structure } \examples{ # Create structure for reports -path <- tempfile(pattern = "dir") +path <- tempfile(pattern = "report-example") dir.create(path) -create_reports(path) +create_reports(path, git = FALSE) list.files(path, recursive = TRUE) # Add a new report diff --git a/man/fairify-package.Rd b/man/fairify-package.Rd new file mode 100644 index 0000000000000000000000000000000000000000..4f566f66a733c650a84a08c7669aead3a459423d --- /dev/null +++ b/man/fairify-package.Rd @@ -0,0 +1,204 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fairify-package.R +\docType{package} +\name{fairify-package} +\alias{fairify} +\alias{fairify-package} +\title{fairify: a package for creating FAIR reports} +\description{ +\subsection{Create a \emph{fairify} project}{ + +\code{create_fairify} creates a R-package skeleton with several and open your +project on Rstudio: + +\if{html}{\out{<div class="sourceCode">}}\preformatted{# Create a project in a temporary folder for the example +path <- file.path(tempdir(), "my_fairify_project") +fairify::create_fairify(path) + +## ✔ Creating 'C:/Users/DDORCH~1/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project/' +## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' +## ✔ Creating 'R/' +## ✔ Writing 'DESCRIPTION' + +## Package: my_fairify_project +## Title: What the Package Does (One Line, Title Case) +## Version: 0.0.0.9000 +## Authors@R (parsed): +## * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID) +## Description: What the package does (one paragraph). +## License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a +## license +## Encoding: UTF-8 +## Roxygen: list(markdown = TRUE) +## RoxygenNote: 7.3.1 + +## ✔ Writing 'NAMESPACE' +## ✔ Writing 'my_fairify_project.Rproj' +## ✔ Adding '^my_fairify_project\\\\.Rproj$' to '.Rbuildignore' +## ✔ Adding '.Rproj.user' to '.gitignore' +## ✔ Adding '^\\\\.Rproj\\\\.user$' to '.Rbuildignore' +## ✔ Setting active project to '<no active project>' +## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' +## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' +## ✔ Adding 'testthat' to Suggests field in DESCRIPTION +## ✔ Adding '3' to Config/testthat/edition +## ✔ Creating 'tests/testthat/' +## ✔ Writing 'tests/testthat.R' +## • Call `use_test()` to initialize a basic test file and open it for editing. +## ✔ Adding 'fairify' to Depends field in DESCRIPTION +## • Are you sure you want Depends? Imports is almost always the better choice. +## Fairify project created +## +## Don't forget to edit the file `inst/config.yml` for configuring the data location for your project +## +## ✔ Setting active project to 'C:/Users/ddorchies/AppData/Local/Temp/RtmpkNEQuT/my_fairify_project' + +list.files(path) + +## [1] "DESCRIPTION" "inst" +## [3] "my_fairify_project.Rproj" "NAMESPACE" +## [5] "R" "reports" +## [7] "templates" "tests" +}\if{html}{\out{</div>}} +} + +\subsection{Create reports with \strong{bookdown}}{ + +By default, the \emph{fairify} project contains a \code{reports} folder which +contains bookdown reports. + +Use the function \code{fairify::add_report} for creating a new report. + +\if{html}{\out{<div class="sourceCode">}}\preformatted{# Create a report +fairify::add_report("my_report", path) + +## [1] "C:\\\\Users\\\\DDORCH~1\\\\AppData\\\\Local\\\\Temp\\\\RtmpkNEQuT/my_fairify_project/reports/my_report" + +# Add a chapter +writeLines( + c( + "# A new chapter", + "", + "With a new paragraph." + ), + file.path(path, "reports/my_report/01-new_chapter.Rmd") +) +}\if{html}{\out{</div>}} +} + +\subsection{Render reports}{ + +By default, the reports are rendered in the public folder of the +\emph{fairify} project. + +\if{html}{\out{<div class="sourceCode">}}\preformatted{# Render the report in HTML format +fairify::render_reports(reports_dir = file.path(path, "reports")) + +## folder list: + +## my_report + +## ******************************************************************* + +## ** RENDER my_report + +## ******************************************************************* + +## output_format=bookdown::gitbook + +## Rendering book in directory 'C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT/my_fairify_project/reports/my_report' + +## processing file: report.Rmd + +## output file: report.knit.md + +## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS report.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output report.html --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\Programs\\R\\R-4.2.2\\library\\bookdown\\rmarkdown\\lua\\custom-environment.lua" --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\R\\win-library\\4.2\\rmarkdown\\rmarkdown\\lua\\pagebreak.lua" --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\R\\win-library\\4.2\\rmarkdown\\rmarkdown\\lua\\latex-div.lua" --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\R\\win-library\\4.2\\rmarkdown\\rmarkdown\\lua\\anchor-sections.lua" --metadata-file "C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT\\file384434cd7298" --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\\Users\\ddorchies\\AppData\\Local\\Programs\\R\\R-4.2.2\\library\\bookdown\\templates\\gitbook.html" --highlight-style pygments --number-sections --css style.css --mathjax --include-in-header "C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT\\rmarkdown-str384462592dc7.html" --citeproc + +## +## Output created: ../../public/reports/my_report/index.html + +# Render the report in PDF format +fairify::render_reports(reports_dir = file.path(path, "reports"), + output_format = "bookdown::pdf_book") + +## folder list: + +## my_report + +## ******************************************************************* + +## ** RENDER my_report + +## ******************************************************************* + +## Loading required package: tinytex + +## Warning: package 'tinytex' was built under R version 4.2.3 + +## output_format=bookdown::pdf_book + +## Rendering book in directory 'C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT/my_fairify_project/reports/my_report' + +## processing file: report.Rmd + +## output file: report.knit.md + +## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS report.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output report.tex --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\Programs\\R\\R-4.2.2\\library\\bookdown\\rmarkdown\\lua\\custom-environment.lua" --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\R\\win-library\\4.2\\rmarkdown\\rmarkdown\\lua\\pagebreak.lua" --lua-filter "C:\\Users\\ddorchies\\AppData\\Local\\R\\win-library\\4.2\\rmarkdown\\rmarkdown\\lua\\latex-div.lua" --metadata-file "C:\\Users\\DDORCH~1\\AppData\\Local\\Temp\\RtmpkNEQuT\\file38447a441ba0" --embed-resources --standalone --table-of-contents --toc-depth 2 --number-sections --highlight-style tango --pdf-engine pdflatex --biblatex --include-in-header "..\\..\\templates\\umr_geau\\preamble.tex" --include-after-body "..\\..\\templates\\inrae\\after_body.tex" --variable graphics --wrap preserve --variable tables=yes --standalone -Mhas-frontmatter=false + +## +## Output created: ../../public/reports/my_report/report.pdf +}\if{html}{\out{</div>}} +} + +\subsection{Use data located on the cloud (or not…)}{ +\subsection{How it works?}{ + +The \emph{fairify} project provides a function \code{getDataPath} which helps you +to use data located on the cloud in your R scripts. + +List of supported cloud servers: +\itemize{ +\item \href{https://owncloud.com/}{Owncloud} +\item \href{https://nextcloud.com/}{Nextcloud} +} + +To use it, you first need to define your cloud configuration in the file +\code{inst/config.yml}: + +\if{html}{\out{<div class="sourceCode">}}\preformatted{default: + data: + mode: remote + local: "path_for_data_on_your_disk" + remote: "https://public_link_on_your_cloud" + write_results: false +}\if{html}{\out{</div>}} + +The \code{local} path stands for storing your data on a local or network disk +directly readable and writable by your Operating System. +} + +\subsection{Caching results}{ + +\code{write_results} logical parameter is an helper for caching data results +of long calculations. The basic strategy is to either calculate and save +a result or read this result depending of the value of this boolean: + +\if{html}{\out{<div class="sourceCode">}}\preformatted{computeSomeThing <- function(cfg = loadConfig()) \{ + if (cfg$data$write_results) \{ + myBigResult <- 2 + 2 + saveRDS(myBigResult, getDataPath("myBigResult.RDS")) + \} else \{ + myBigResult <- readRDS(getDataPath("myBigResult.RDS")) + \} + return(myBigResult) +\} +}\if{html}{\out{</div>}} +} + +} +} +\author{ +\strong{Maintainer}: David Dorchies \email{david.dorchies@inrae.fr} (\href{https://orcid.org/0000-0002-6595-7984}{ORCID}) + +} +\keyword{internal} diff --git a/man/figures/logo.png b/man/figures/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..199b4443c9881ac6b6d3abe08ad541d643db166a Binary files /dev/null and b/man/figures/logo.png differ diff --git a/man/getDataPath.Rd b/man/getDataPath.Rd new file mode 100644 index 0000000000000000000000000000000000000000..fd86fcc8a787936815ba5cb75926d7b1638d8e39 --- /dev/null +++ b/man/getDataPath.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getDataPath.R +\name{getDataPath} +\alias{getDataPath} +\title{Give the complete path of the data and cache data on local disk} +\usage{ +getDataPath( + path, + ..., + use_cache = TRUE, + cfg, + root = cfg$data[[cfg$data$mode]], + cache +) +} +\arguments{ +\item{path}{\link{character} representing the path of the data in the database} + +\item{...}{\link{character} path elements to add after \code{path}} + +\item{use_cache}{\link{logical} download the data and use cache location} + +\item{cfg}{a config object. Configuration to use. See \link{loadConfig} for details} + +\item{root}{\link{character} URL or path of the database root} + +\item{cache}{\link{character} path where downloaded files from cloud are cached (See details)} +} +\value{ +\link{character} with the path of the file to read either on: +\itemize{ +\item the local storage if \code{cfg$data$mode == "local"} +\item the cache directory if \code{cfg$data$mode != "local"} and \code{use_cache == TRUE} +\item the cloud URL if \code{cfg$data$mode != "local"} and \code{use_cache == FALSE} +} +} +\description{ +It supports Nextcloud public links in case of using cloud. In this case, +this function can download the file in a temporary +folder and returns the path of the downloaded file. +This functionality is useful for \code{read_excel} from the package \emph{readxl} +(See: https://stackoverflow.com/a/41368947/5300212). +} +\details{ +The cache directory is by default located in the system temporary folder in a +subdirectory named as the package name or the value of the environment variable +"PKG_DATA_CACHE" if it is defined. +} diff --git a/man/loadConfig.Rd b/man/loadConfig.Rd new file mode 100644 index 0000000000000000000000000000000000000000..c44d4c6d852db7c246f9b262aab722f3b6fa7123 --- /dev/null +++ b/man/loadConfig.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/loadConfig.R +\name{loadConfig} +\alias{loadConfig} +\title{Read package configuration} +\usage{ +loadConfig(userFile = "config.yml", pathDefaultCfg) +} +\arguments{ +\item{userFile}{location of the user config YML file} + +\item{pathDefaultCfg}{The location of the default configuration (located in "inst/config.yml" of the package by default)} +} +\value{ +A configuration as it is returned by \link[config:get]{config::get} +} +\description{ +Read default package configuration and complete it with eventual user config. +} +\details{ +User file configuration (by default the \code{config.yml} file in the working +directory) can overwrite items of the default configuration (See examples). +} diff --git a/man/render_reports.Rd b/man/render_reports.Rd index f249226fe1e1176d4b29e182f5303faf2e9d1cc8..910af4e3777967cc64a05c06833a101e9a2ef29e 100644 --- a/man/render_reports.Rd +++ b/man/render_reports.Rd @@ -52,3 +52,32 @@ folder which is in format \code{"./reports/my_report"}} \description{ Render reports } +\examples{ +# Create a fairify project in a temporary folder +path <- tempfile(pattern = "fairify_") +fairify::create_fairify(path, git = FALSE, open = FALSE) +owd <- setwd(path) + +# Create a report +fairify::add_report("my_report") + +# Add a chapter +writeLines( + c( + "# A new chapter", + "", + "With a new paragraph." + ), + file.path(path, "reports", "my_report", "01-new_chapter.Rmd") +) + +# Render the report in HTML format +render_reports(reports_dir = file.path(path, "reports")) + +# Render the report in PDF format +render_reports(reports_dir = file.path(path, "reports"), + output_format = "bookdown::pdf_book") + +# Back to initial working directory +setwd(owd) +} diff --git a/man/update_fairify.Rd b/man/update_fairify.Rd new file mode 100644 index 0000000000000000000000000000000000000000..17b897b32a41b286c76929d64d3acb9a94f7cd4f --- /dev/null +++ b/man/update_fairify.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/update_fairify.R +\name{update_fairify} +\alias{update_fairify} +\title{Update or install the fairify functions and default configuration +in a project created with fairify} +\usage{ +update_fairify(path = ".") +} +\arguments{ +\item{path}{Path of the fairify project or inside the fairify project} +} +\value{ +Use for side effect. +} +\description{ +Update or install the fairify functions and default configuration +in a project created with fairify +} diff --git a/tests/testthat/helper-fairify.R b/tests/testthat/helper-fairify.R new file mode 100644 index 0000000000000000000000000000000000000000..e02e0152d581fe01968ca6f1b29b7e33e8061838 --- /dev/null +++ b/tests/testthat/helper-fairify.R @@ -0,0 +1,7 @@ +helper_create_fairify <- function(pattern = paste(sample(LETTERS, 8, TRUE), collapse = ""), + path = tempfile(pattern = pattern), + ...) { + path <- tempfile(pattern = pattern) + fairify::create_fairify(path, open = FALSE, ...) + return(path) +} diff --git a/tests/testthat/test-create_fairify.R b/tests/testthat/test-create_fairify.R index a11d0ca90cff6a92ad496678a0e65a34b7d5f2de..cb4062abfa89a2799916d860ad4dbea80b821b0d 100644 --- a/tests/testthat/test-create_fairify.R +++ b/tests/testthat/test-create_fairify.R @@ -1,14 +1,16 @@ test_that("create_fairify works", { - path <- tempfile(pattern = "dir") - create_fairify(path, open = FALSE) + path <- helper_create_fairify() project <- basename(path) expect_true(file.exists(file.path(path, paste0(project, ".Rproj")))) - expect_true(file.exists(file.path(path, ".git"))) + expect_true(dir.exists(file.path(path, ".git"))) + expect_true(file.exists(file.path(path, ".gitignore"))) + expect_true(dir.exists(file.path(path, "R"))) + expect_warning(update_fairify(path)) + unlink(path, recursive = TRUE) }) test_that("create_fairify with git = FALSE doesn't create git repo works", { - path <- tempfile(pattern = "dir") - create_fairify(path, open = FALSE, git = FALSE) + path <- helper_create_fairify(git = FALSE) project <- basename(path) expect_false(file.exists(file.path(path, ".git"))) }) diff --git a/tests/testthat/test-create_reports.R b/tests/testthat/test-create_reports.R index 16499132bd41db5f5e9d9a7a6cf721374cef3563..8f94b1be5ec6ddaaf13aa9bea4edc5e80ed34fbe 100644 --- a/tests/testthat/test-create_reports.R +++ b/tests/testthat/test-create_reports.R @@ -1,5 +1,5 @@ test_that("create_reports works", { - path <- tempfile(pattern = "dir") + path <- tempfile(pattern = "create_reports") dir.create(path, recursive = TRUE) expect_equal(create_reports(path), file.path(path, "reports")) diff --git a/tests/testthat/test-loadConfig.R b/tests/testthat/test-loadConfig.R new file mode 100644 index 0000000000000000000000000000000000000000..54af98fd754d42710e1dcee94152d2f63347a235 --- /dev/null +++ b/tests/testthat/test-loadConfig.R @@ -0,0 +1,26 @@ +test_that("loadConfig works", { + path_pkg <- helper_create_fairify() + path_pkg <- normalizePath(path_pkg, winslash = "/") + pkgload::load_all(path_pkg, export_all = FALSE) + loadConfig <- get("loadConfig", envir = loadNamespace(basename(path_pkg))) + path <- file.path(path_pkg, "tata/toto") + dir.create(path, recursive = TRUE) + setwd(path) + s <- "default: + data: + mode: local + write_results: true" + writeLines(s, "config.yml") + cfg <- loadConfig() + expect_true(cfg$data$write_results) + file.rename("config.yml", "../config.yml") + expect_message(loadConfig(), + regexp = paste("Read user configuration from:", + file.path(path_pkg, "tata/config.yml"))) + file.rename(file.path(path_pkg, "tata/config.yml"), + file.path(path_pkg, "config.yml")) + expect_message(loadConfig(), + regexp = paste("Read user configuration from:", + file.path(path_pkg, "config.yml"))) + +}) diff --git a/tests/testthat/test-render_reports.R b/tests/testthat/test-render_reports.R index 6a6f38c844da833f56b944c6435a57b91220d65c..6ca9698d1f10c6da9e1b945823fb6d6d1f990894 100644 --- a/tests/testthat/test-render_reports.R +++ b/tests/testthat/test-render_reports.R @@ -12,4 +12,5 @@ test_that("render_reports works", { render_reports(reports_dir = file.path(path, "reports"), output_format = "bookdown::pdf_book") expect_true(file.exists(file.path(path, "public/reports/my_report/report.pdf"))) + unlink(path, recursive = TRUE) })