Movatterモバイル変換


[0]ホーム

URL:


Title:Log Execution of Scripts
Version:0.3.1
Description:Logging of scripts suitable for clinical trials using 'Quarto' to create nice human readable logs. 'whirl' enables execution of scripts in batch, while simultaneously creating logs for the execution of each script, and providing an overview summary log of the entire batch execution.
License:Apache License (≥ 2)
URL:https://novonordisk-opensource.github.io/whirl/,https://github.com/novonordisk-opensource/whirl
BugReports:https://github.com/NovoNordisk-OpenSource/whirl/issues
Depends:R (≥ 4.1)
Imports:callr, cli, dplyr, jsonlite, kableExtra, knitr, purrr, quarto,R6 (≥ 2.4.0), reticulate, rlang, sessioninfo, stringr, tibble,unglue, utils, withr, yaml, zephyr (≥ 0.1.1)
Suggests:ggplot2, renv, rstudioapi, testthat (≥ 3.0.0), usethis
VignetteBuilder:knitr
Config/testthat/edition:3
Encoding:UTF-8
RoxygenNote:7.3.2
SystemRequirements:Quarto command line tool(<https://github.com/quarto-dev/quarto-cli>).
NeedsCompilation:no
Packaged:2025-08-25 14:23:34 UTC; oath
Author:Aksel Thomsen [aut, cre], Lovemore Gakava [aut], Cervan Girard [aut], Kristian Troejelsgaard [aut], Steffen Falgreen Larsen [aut], Vladimir Obucina [aut], Michael Svingel [aut], Skander Mulder [aut], Oliver Lundsgaard [aut], Novo Nordisk A/S [cph]
Maintainer:Aksel Thomsen <oath@novonordisk.com>
Repository:CRAN
Date/Publication:2025-08-25 14:50:02 UTC

whirl: Log Execution of Scripts

Description

logo

Logging of scripts suitable for clinical trials using 'Quarto' to create nice human readable logs. 'whirl' enables execution of scripts in batch, while simultaneously creating logs for the execution of each script, and providing an overview summary log of the entire batch execution.

Author(s)

Maintainer: Aksel Thomsenoath@novonordisk.com

Authors:

Other contributors:

See Also

Useful links:


Helper function to log custom messages

Description

Useful for e.g. read and write operations on databases etc.that are not automatically captured.

Usage

log_read(file, log = Sys.getenv("WHIRL_LOG_MSG"))log_write(file, log = Sys.getenv("WHIRL_LOG_MSG"))log_delete(file, log = Sys.getenv("WHIRL_LOG_MSG"))

Arguments

file

character() description of the file that was read, written ordeleted.

log

character() path to the log file.

Details

The default environment variableWHIRL_LOG_MSG is set in the session usedto log scripts, and input is automatically captured in the resulting log.

If run outside of whirl, meaning when the above environment variable isunset, the operations are streamed tostdout(). By default the console.

Examples

# Stream logs to console since `WHIRL_LOG_MSG` is not set:log_read("my/folder/input.txt")log_write("my/folder/output.txt")log_delete("my/folder/old_output.txt")

Execute single or multiple R, R Markdown, and Quarto scripts

Description

Executes and logs the execution of the scripts.Logs for each script are stored in the same folder as the script.

The way the execution is logged is configurable through several options fore.g. the verbosity of the logs.Seewhirl-options on how to configure these.

Usage

run(  input = "_whirl.yml",  steps = NULL,  summary_file = "summary.html",  n_workers = zephyr::get_option("n_workers", "whirl"),  check_renv = zephyr::get_option("check_renv", "whirl"),  track_files = zephyr::get_option("track_files", "whirl"),  out_formats = zephyr::get_option("out_formats", "whirl"),  log_dir = zephyr::get_option("log_dir", "whirl"))

Arguments

input

A character vector of file path(s) to R, R Markdown, Quartoscripts, or files in a folder using regular expression, or to to a whirlconfig file. The input can also be structured in a list where each elementwill be executed sequentially, while scripts within each element can beexecuted in parallel.

steps

An optional argument that can be used if only certain stepswithin a config files (or list) is to be executed. Should be equivalent tothe names of the steps found in the config file. If kept as NULL (default)then all steps listed in the config file will be executed.

summary_file

A character string specifying the file path where thesummary log will be stored.

n_workers

Number of simultaneous workers used in the run function.A maximum of 128 workers is allowed.. Default:1.

check_renv

Should the projects renv status be checked?. Default:FALSE.

track_files

Should files read and written be tracked?Currently only supported on Linux.. Default:FALSE.

out_formats

Which log format(s) to produce. Possibilities arehtml,json, and markdown formats:gfm,commonmark, andmarkua.. Default:"html".

log_dir

The output directory of the log files. Default is the folder ofthe executed script. log_dir can be a path as a character or it can be afunction that takes the script path as input and returns the log directory.For more information see the examples ofrun() orvignette('whirl').. Default:function (x) dirname(x).

Value

A tibble containing the execution results for all the scripts.

Examples

# Copy example scripts:file.copy(  from = system.file("examples", c("success.R", "warning.R", "error.R"),    package = "whirl"  ),  to = tempdir())# Run a single script and create log:run(file.path(tempdir(), "success.R"))# Run several scripts in parallel on up to 2 workers:run(  input = file.path(tempdir(), c("success.R", "warning.R", "error.R")),  n_workers = 2)# Run several scripts in two steps by providing them as list elements:run(  list(    file.path(tempdir(), c("success.R", "warning.R")),    file.path(tempdir(), "error.R")  ))# Re-directing the logs to a sub-folder by utilizing the log_dir argument in# run(). This will require that the sub-folder exists.# Specifying the path using a manually defined characterrun(file.path(tempdir(), "success.R"), log_dir = tempdir())# Specifying the path with a generic function that can handle the scripts# individually.run(  input = file.path(tempdir(), "success.R"),  log_dir = function(x) {paste0(dirname(x), "/logs")})

Use whirl to create biocompute logs

Description

Utility function to setup execution with whirl in your project suitable forcreating biocompute logs withwrite_biocompute():

  1. Creates configuration file (default⁠_whirl.yml⁠) with default values for thebiocompute metadata.

  2. Updates.gitignore to not include log files

Seevignette("whirl") for how to specify paths inside theconfiguration file.

Usage

use_biocompute(  config_file = "_whirl.yml",  parametrics_file = "_parametrics.yml")

Arguments

config_file

Path to the whirl config file, relative to the project

parametrics_file

Path to the biocompute parametrics file, relative to the project


Use whirl

Description

Utility function to setup execution with whirl in your project:

  1. Creates configuration file (default⁠_whirl.yml⁠)

  2. Updates.gitignore to not include log files

Seevignette("whirl") for how to specify paths inside theconfiguration file.

Usage

use_whirl(config_file = "_whirl.yml")

Arguments

config_file

Path to the whirl config file, relative to the project


Options for whirl

Description

verbosity_level

Verbosity level for functions in whirl.Seezephyr::verbosity_level for details.

out_formats

Which log format(s) to produce. Possibilities arehtml,json, and markdown formats:gfm,commonmark, andmarkua.

track_files

Should files read and written be tracked?Currently only supported on Linux.

check_renv

Should the projects renv status be checked?

track_files_discards

List of file naming patterns not be tracked when track_files = TRUE

track_files_keep

List of file naming patterns always to be tracked whentrack_files = TRUE

approved_packages

List of approved R packages and their version in the format: {name}@{version}

approved_python_packages

List of approved Python packages and their version in the format: {name}@{version}

n_workers

Number of simultaneous workers used in the run function.A maximum of 128 workers is allowed.

log_dir

The output directory of the log files. Default is the folder ofthe executed script. log_dir can be a path as a character or it can be afunction that takes the script path as input and returns the log directory.For more information see the examples ofrun() orvignette('whirl').

execute_dir

The working directory of the process executing each script.Default us to execute R files from the working directory when callingrun()and all other functions from the directory of the script. To change providea character path (used for all scripts) or a function that takes the scriptas input and returns the execution directory.

wait_timeout

Timeout for waiting for the R process from callr::r_session tostart, in milliseconds.

environment_secrets

Secret environment variable patterns.Any variables matching will not be included in the logs.


Internal parameters for reuse in functions

Description

Internal parameters for reuse in functions

Arguments

verbosity_level

Verbosity level for functions in whirl.Seezephyr::verbosity_level for details.. Default:NA_character_.

out_formats

Which log format(s) to produce. Possibilities arehtml,json, and markdown formats:gfm,commonmark, andmarkua.. Default:"html".

track_files

Should files read and written be tracked?Currently only supported on Linux.. Default:FALSE.

check_renv

Should the projects renv status be checked?. Default:FALSE.

track_files_discards

List of file naming patterns not be tracked when track_files = TRUE. Default:c("^/lib", "^/etc", "^/lib64", "^/usr", "^/var", "^/opt", "^/sys", "^/proc", "^/tmp", "^/null", "^/urandom", "^/.cache").

track_files_keep

List of file naming patterns always to be tracked whentrack_files = TRUE. Default:NULL.

approved_packages

List of approved R packages and their version in the format: {name}@{version}. Default:NULL.

approved_python_packages

List of approved Python packages and their version in the format: {name}@{version}. Default:NULL.

n_workers

Number of simultaneous workers used in the run function.A maximum of 128 workers is allowed.. Default:1.

log_dir

The output directory of the log files. Default is the folder ofthe executed script. log_dir can be a path as a character or it can be afunction that takes the script path as input and returns the log directory.For more information see the examples ofrun() orvignette('whirl').. Default:function (x) dirname(x).

execute_dir

The working directory of the process executing each script.Default us to execute R files from the working directory when callingrun()and all other functions from the directory of the script. To change providea character path (used for all scripts) or a function that takes the scriptas input and returns the execution directory.. Default:NULL.

wait_timeout

Timeout for waiting for the R process from callr::r_session tostart, in milliseconds.. Default:9000.

environment_secrets

Secret environment variable patterns.Any variables matching will not be included in the logs.. Default:c("BASH_FUNC", "_SSL_CERT", "_KEY", "_PAT", "_TOKEN").

Details

Seewhirl-options for more information.


Create biocompute logs

Description

BioCompute is a standard for logs of programs for for Bioinformatics Computational Analyses.

The BioCompute object is ajson log that can be created based on the output ofrun().

Usage

write_biocompute(queue = run("_whirl.yml"), path = "bco.json", ...)

Arguments

queue

Result fromrun().

path

A character string specifying the file path to write BioCompute log to.

...

Additional arguments parsed tojsonlite::write_json(). Note always usesauto_unbox = TRUE.

Details

The object consists of the following domains:

See theBioCompute Object Portal and theBioCompute Objects Wiki for more information.

Value

(invisible)list of the biocompute domains and their content.


[8]ページ先頭

©2009-2025 Movatter.jp