Title: | Automated Setup of Reproducible Workflows and their Dependencies |
---|---|
Description: | Set up components for reproducible workflows, quickly and painlessly. Apply best practises from [Peikert & Brandmaier (2019)](<https://psyarxiv.com/8xzqy/>), [Van Lissa et. al 2020](<https://osf.io/zcvbs/>) or [The Turing Way Community](<doi.org:10.5281/zenodo.3233986>) easily in your own projects. Based upon the great [`usethis`-package](<https://github.com/r-lib/usethis>). |
Authors: | Aaron Peikert [aut, cre] , Andreas M. Brandmaier [aut] , Caspar J. van Lissa [aut] |
Maintainer: | Aaron Peikert <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-08 05:29:27 UTC |
Source: | https://github.com/aaronpeikert/repro |
automate()
& friends use yaml metadata from RMarkdowns to create
Dockerfile
's and Makefile
's. It should be clear which is created by
automate_docker()
& which by automate_make()
.
automate(path = ".") automate_make(path = ".") automate_publish(path = ".") automate_docker(path = ".")
automate(path = ".") automate_make(path = ".") automate_publish(path = ".") automate_docker(path = ".")
path |
Where should we look for RMarkdowns? |
automate_load_packages()
, automate_load_data()
, automate_load_scripts()
automate_load_packages()
loads all packages listed in YAML via library()
automate_load_scripts()
registeres external scripts via knitr::read_chunk()
automate_load_data()
reads in the data from the yaml with abitrary functions
automate_load_packages() automate_load_scripts() automate_load_data(data, func, ...)
automate_load_packages() automate_load_scripts() automate_load_data(data, func, ...)
data |
How is the entry in the YAML called? It will be the name of the object. |
func |
Which function should be used to read in the data? Its first argument must be the path to the file. |
... |
Further arguments supplied to |
automate_load_packages()
& automate_load_scripts()
do not return anything. automate_load_data()
returns the data.
Check if a dependency is installed and if not it recommends how to install it
depending on the operating system. Most importantly it checks for
git
, make
& docker
. And just for convenience of the installation it
checks on OS X for Homebrew
and on Windows for Chocolately
.
check_docker() check_make() check_git() check_brew() check_choco() check_ssh(install = getOption("repro.install")) check_github_token(install = getOption("repro.install")) check_github_token_access() check_github_ssh() check_github(auth_method = "token") check_renv(install = getOption("repro.install")) check_targets(install = getOption("repro.install")) check_worcs(install = getOption("repro.install"))
check_docker() check_make() check_git() check_brew() check_choco() check_ssh(install = getOption("repro.install")) check_github_token(install = getOption("repro.install")) check_github_token_access() check_github_ssh() check_github(auth_method = "token") check_renv(install = getOption("repro.install")) check_targets(install = getOption("repro.install")) check_worcs(install = getOption("repro.install"))
install |
Should something be installed? Defaults to "ask", but can be TRUE/FALSE. |
auth_method |
How do you want to authenticate with GitHub? Either "token" (default) or "ssh". |
Other checkers:
check_package()
,
has_package()
,
has
,
uses
Check if package exists
check_package(pkg, install = getOption("repro.install"), github = NULL)
check_package(pkg, install = getOption("repro.install"), github = NULL)
pkg |
Which package are we talking about? |
install |
Should we install the package in case its missing? |
github |
A github username/package from which the package is installed. If NULL (the default) CRAN (or whatever repo) you have set is used. |
Other checkers:
check
,
has_package()
,
has
,
uses
Find out what the currently checked out commit is and report its respective hash.
current_hash(length = 7L, backend = NULL)
current_hash(length = 7L, backend = NULL)
length |
The length to which the hash is cut. |
backend |
Can be either of |
Add or modify the Dockerfile in the current project.
use_docker( rver = NULL, stack = "verse", date = Sys.Date(), file = "Dockerfile", open = TRUE ) use_dockerignore(file, open = TRUE)
use_docker( rver = NULL, stack = "verse", date = Sys.Date(), file = "Dockerfile", open = TRUE ) use_dockerignore(file, open = TRUE)
rver |
Which r version to use, defaults to current version. |
stack |
Which stack to use, possible values are |
date |
Which date should be used for package instalation, defaults to today. |
file |
Which file to save to |
open |
Open the newly created file for editing? Happens in RStudio, if applicable, or via utils::file.edit() otherwise. |
Generate the weird format for docker on windows.
docker_windows_path(path = NULL, todo = interactive())
docker_windows_path(path = NULL, todo = interactive())
path |
Some windows path. If NULL the current directory. |
todo |
Should an actionable advice be given. Defaults to TRUE. |
Corresponding functions to check
, but intended for programatic use.
has_make(silent = TRUE, force_logical = TRUE) has_git(silent = TRUE, force_logical = TRUE) has_docker(silent = TRUE, force_logical = TRUE) has_docker_running(silent = TRUE, force_logical = TRUE) has_choco(silent = TRUE, force_logical = TRUE) has_brew(silent = TRUE, force_logical = TRUE) has_ssh(silent = TRUE, force_logical = TRUE) has_github_token(silent = TRUE, force_logical = TRUE) has_github_token_access(silent = TRUE, force_logical = TRUE) has_github_ssh(silent = TRUE, force_logical = TRUE) has_github(silent = TRUE, force_logical = TRUE) has_renv(silent = TRUE, force_logical = TRUE) has_targets(silent = TRUE, force_logical = TRUE) has_worcs(silent = TRUE, force_logical = TRUE) has_gert(silent = TRUE, force_logical = TRUE)
has_make(silent = TRUE, force_logical = TRUE) has_git(silent = TRUE, force_logical = TRUE) has_docker(silent = TRUE, force_logical = TRUE) has_docker_running(silent = TRUE, force_logical = TRUE) has_choco(silent = TRUE, force_logical = TRUE) has_brew(silent = TRUE, force_logical = TRUE) has_ssh(silent = TRUE, force_logical = TRUE) has_github_token(silent = TRUE, force_logical = TRUE) has_github_token_access(silent = TRUE, force_logical = TRUE) has_github_ssh(silent = TRUE, force_logical = TRUE) has_github(silent = TRUE, force_logical = TRUE) has_renv(silent = TRUE, force_logical = TRUE) has_targets(silent = TRUE, force_logical = TRUE) has_worcs(silent = TRUE, force_logical = TRUE) has_gert(silent = TRUE, force_logical = TRUE)
silent |
Should a message be printed that informs the user? |
force_logical |
Should the return value be passed through |
Other checkers:
check_package()
,
check
,
has_package()
,
uses
Check if package exists
has_package(pkg, silent = TRUE, force_logical = TRUE)
has_package(pkg, silent = TRUE, force_logical = TRUE)
pkg |
Which package are we talking about? |
silent |
Should a message be printed that informs the user? |
force_logical |
Should the return value be passed through |
Other checkers:
check_package()
,
check
,
has
,
uses
Add a (GNU-)Makefile(s) with special emphasis on the use of containers.
use_make( docker = FALSE, publish = FALSE, singularity = FALSE, torque = FALSE, open = TRUE ) use_make_docker(file, use_docker = TRUE, dockerignore = TRUE, open = FALSE) use_make_singularity(file, use_singularity = TRUE, open = FALSE) use_make_publish(file, open = FALSE)
use_make( docker = FALSE, publish = FALSE, singularity = FALSE, torque = FALSE, open = TRUE ) use_make_docker(file, use_docker = TRUE, dockerignore = TRUE, open = FALSE) use_make_singularity(file, use_singularity = TRUE, open = FALSE) use_make_publish(file, open = FALSE)
docker |
If true or a path a setup is created that can partially send make commands to a Docker container. |
publish |
Should the |
singularity |
If true or a path a setup is created that can partially send make commands to a Singularity container (which requires the Dockerimage) |
torque |
If true a or a path setup is created that can partially send make comands to a TORQUE job scheduler. Especially usefull in combination with a Singularity container. |
open |
Open the newly created file for editing? Happens in RStudio, if applicable, or via utils::file.edit() otherwise. |
file |
Path to the file that is to be created. |
use_docker |
If true |
dockerignore |
If true a .dockerignore file is created. |
use_singularity |
If true |
reproduce()
inspects the files of a project and suggest a way to reproduce the project.
reproduce(fun, ..., path = ".", cache = FALSE, silent = FALSE) reproduce_make(path, cache = FALSE, silent = FALSE)
reproduce(fun, ..., path = ".", cache = FALSE, silent = FALSE) reproduce_make(path, cache = FALSE, silent = FALSE)
fun |
a function that inspects |
... |
more functions like |
path |
Were should I look for entrypoints? |
cache |
Default is |
silent |
Should a message be presented? |
reproduce()
walks through a list of functions that check for a specific entrypoint.
As soon as a function returns a possible entrypoint the search stops.
If no function is supplied the standard list of reproduce_funs is used.
Returns invisibly the command users should use to reproduce.
reproduce_funs
At the moment only reproduce_make is available.
reproduce_funs
reproduce_funs
An object of class list
of length 1.
reproduce_make
detects make as an entrypoint if there is a Makefile at top level.
If it does also encounter a Makefile_Docker somewhere it recognizes the different make instructions.
reproduce
rerun()
was renamed to reproduce()
. rerun()
is deprecated.
rerun(...)
rerun(...)
... |
passed to |
reproduce_funs
Fills a newly created folder with examples of RMarkdown, scripts, and data, which work well with automate()
.
repro_template(path, ...) use_repro_template(path, ...)
repro_template(path, ...) use_repro_template(path, ...)
path |
character specifieng target folder. Will be created if it doesn't exist. |
... |
Passed down to the markdown template. |
Adds package dependencies as a new RUN statement to Dockerfile. Sorts packages first into source (cran & github) and then alphabetically.
use_docker_packages( packages, github = NULL, strict = TRUE, file = "Dockerfile", write = TRUE, open = write, append = TRUE )
use_docker_packages( packages, github = NULL, strict = TRUE, file = "Dockerfile", write = TRUE, open = write, append = TRUE )
packages |
Which packages to add. |
github |
Are there github packages? |
strict |
Defaults to TRUE, force a specific version for github packages. |
file |
Where is the 'Dockerfile'? |
write |
Should the 'Dockerfile' be modified? |
open |
Should the file be opened? |
append |
Should the return value be appended to the 'Dockerfile'? |
Add an standard actions that builds and publishes an Dockerimage from the Dockerfile
.
use_gha_docker(file = getOption("repro.gha.docker"), open = TRUE)
use_gha_docker(file = getOption("repro.gha.docker"), open = TRUE)
file |
Which file to save to. |
open |
Open the newly created file for editing? Happens in RStudio, if applicable, or via utils::file.edit() otherwise. |
Add an standard actions that builds the publish
-target, and publishes the results on the gh-pages
branch.
Requires a Dockerimage published within the same GitHub repository. See use_gha_docker()
.
use_gha_publish(file = getOption("repro.gha.publish"), open = TRUE)
use_gha_publish(file = getOption("repro.gha.publish"), open = TRUE)
file |
Which file to save to. |
open |
Open the newly created file for editing? Happens in RStudio, if applicable, or via utils::file.edit() otherwise. |
If a template is itself used again as a whisker template, we need some other escape mechanism.
The repro
-template than uses [[]]
instead of {{}}
which are than later reinstated.
use_template_template( template, save_as = template, escape = c(`\\[\\[` = "{{", `\\]\\]` = "}}"), data = list(), ignore = FALSE, open = FALSE, package = "repro" )
use_template_template( template, save_as = template, escape = c(`\\[\\[` = "{{", `\\]\\]` = "}}"), data = list(), ignore = FALSE, open = FALSE, package = "repro" )
template |
|
save_as |
|
escape |
named vector, name is replacement (default curly), value is placeholder (default square) |
data |
|
ignore |
|
open |
|
package |
Check if a project uses certain things, e.g. Make or Docker.
uses_make(silent = FALSE) uses_docker(silent = FALSE) uses_gha_docker(silent = FALSE) uses_gha_publish(silent = FALSE) uses_make_publish(silent = FALSE) uses_make_rmds(silent = FALSE)
uses_make(silent = FALSE) uses_docker(silent = FALSE) uses_gha_docker(silent = FALSE) uses_gha_publish(silent = FALSE) uses_make_publish(silent = FALSE) uses_make_rmds(silent = FALSE)
silent |
Defaults to |
Other checkers:
check_package()
,
check
,
has_package()
,
has