orderly (version 1.0.4)

orderly_test_start: Prepare a directory for orderly to use

Description

For interactive testing of orderly code. This runs through and sets everything up as orderly would (creates a new working directory and copies files into it, pulls data from the database, copies over any dependent reports) but then rather than running the report hands back to the user. The orderly_data function returns an environment with the extracted data.

Usage

orderly_test_start(name, parameters = NULL, envir = parent.frame(),
  root = NULL, locate = TRUE)

orderly_test_check(path = NULL)

orderly_data(name, parameters = NULL, envir = NULL, root = NULL, locate = TRUE)

Arguments

name

Name of the report to run (see orderly_list).

parameters

Parameters passed to the report. A named list of parameters declared in the orderly.yml.

envir

The parent of the environment that will be used to evaluate the report script; by default a new environment will be made with the global environment as the parent.

root

The path to an orderly root directory, or NULL (the default) to search for one from the current working directory if locate is TRUE.

locate

Logical, indicating if the configuration should be searched for. If TRUE and config is not given, then orderly looks in the working directory and up through its parents until it finds an orderly_config.yml file.

path

Path to the report that is currently being run

Value

The path to the report directory

Details

Previous versions of orderly changed into the created directory when using orderly::orderly_test_start, which allowed interactive testing of a report, including ensuring that it has created all expected outputs. However, CRAN rules do not allow changing the working directory, which significantly reduces the usefulness of this function - as such we may remove it entirely in a future version of orderly if it does not prove useful in this more limited form.

The new suggested workflow is:

  1. run orderly_test_start(...) to prepare a report directory

  2. manually change into that directory following the printed instructions

  3. use orderly_test_check to check that your report has created the expected artefacts

  4. manually change back to your original directory

Examples

Run this code
# NOT RUN {
path <- orderly::orderly_example("minimal")
p <- orderly::orderly_test_start("example", root = path)

# The data in the orderly example is now available to use
dat

# Check to see which artefacts have been created so far:
orderly::orderly_test_check(p)

# Manually the code that this report has in its script
png(file.path(p, "mygraph.png"))
barplot(setNames(dat$number, dat$name), las = 2)
dev.off()

# We now confirm that the artefact has been created:
orderly::orderly_test_check(p)
# The function orderly_data does all the preparation work that
# orderly_run does, but does not run the report; instead it
# returns the created environment with all the data and parameters
# set.
path <- orderly::orderly_example("demo")
env <- orderly::orderly_data("other", list(nmin = 0.2), root = path)
ls(env)
env$nmin
env$extract
# }

Run the code above in your browser using DataCamp Workspace