orderly_develop_start: Develop an orderly report

Description Usage Arguments Details Value Examples

View source: R/develop.R

Description

The functions orderly_develop_start, orderly_develop_status and orderly_develop_clean provide a workflow for developing a report in much the same way as one might write code outside of orderly. orderly_develop_start will copy all files required (global resources and dependencies) into the report source directory, as well as collect all data and parameters - at this point the directory can be developed in directly. It will also load all declared packages, and source all code files listed in the packages: and sources: sections of your orderly.yml. orderly_develop_status provides information about the status of files in the directory, while orderly_develop_clean deletes all copied files.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
orderly_develop_start(
  name = NULL,
  parameters = NULL,
  envir = parent.frame(),
  root = NULL,
  locate = TRUE,
  instance = NULL,
  use_draft = FALSE,
  remote = NULL
)

orderly_develop_status(name = NULL, root = NULL, locate = TRUE)

orderly_develop_clean(name = NULL, root = NULL, locate = TRUE)

Arguments

name

Name of the report to develop (see orderly_list()). A leading src/ will be removed if provided, allowing easier use of autocomplete. Alternatively, the default of NULL is useful if you have already set the working directory to be the source directory.

parameters

Parameters passed to the report. A named list of parameters declared in the orderly.yml. Each parameter must be a scalar character, numeric, integer or logical.

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.

instance

Select instance of the source database to be used, where multiple instances are configured. Use a single unnamed character string to indicate an instance to match. If given, then this name must be present in all databases where instances are listed in orderly_config.yml, and will be ignored by all database where instances are not given. See the "orderly" vignette for further information.

use_draft

Should draft reports be used for dependencies? This should be used only in development. Valid values are logical (TRUE, FALSE) or use the string newer to use draft reports where they are newer than archive reports. For consistency, always and never are equivalent to TRUE and FALSE, respectively.

remote

Remote to use to resolve dependencies. Use this in order to run a report with the same dependencies as are available on a remote server, particularly when using id = "latest". Note that this is not the same as running orderly_pull_dependencies(), then orderly_run with remote = NULL, as the pull/run approach will use the latest report in your archive but the remote = "remote" approach will use the latest approach in the remote archive (which might be less recent).

Details

These functions are designed to work within a report's src directory. For example, for a report analysis they will alter or report on the directory src/analysis. It is intended that orderly_develop_start can be run repeatedly; doing this will refresh the contents of the directory if upstream files have been updated.

Some degree of care should be used while using these functions.

Because orderly_develop_start copies files into your source tree you should be careful to add these files to your .gitignore files so that they are not included if using git. Rerunning orderly_develop_start will copy a fresh copy of dependencies into your tree, overwriting files that are there without warning.

Repeatedly running orderly_develop_start is "safe", in that it will re-run through the setup steps, but beware that sourcing functions is additive and never subtractive. If you delete (or rename) a function within a source file, it will not be removed from your global environment. Similarly, environment variables will be loaded each time you call this, but no deletions will happen. When in doubt, restart your R session.

Note that these functions are much more permissive as to the state of your orderly.yml than orderly_run() - in particular, they will run, with a message, even if you have not yet defined a script: or any artefacts:.

The orderly_develop_clean function will delete dependencies without warning.

Value

A character vector with the full path to the directory, invisibly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
path <- orderly::orderly_example("demo")

# This report uses a dependency - it requires that the file
# incoming.csv exists.  This file is created from the report 'other'
orderly::orderly_develop_status("use_dependency", root = path)

# Copy the required dependencies over, in this case from a draft report
orderly::orderly_run("other", list(nmin = 0), root = path, echo = FALSE)
orderly::orderly_develop_start("use_dependency", root = path,
                               use_draft = TRUE)

# Files have been copied across into the source directory
orderly::orderly_develop_status("use_dependency", root = path)

# The report can then be developed as needed, interactively.  After
# we're happy things can be cleaned up with
orderly::orderly_develop_clean("use_dependency", root = path)

orderly documentation built on Sept. 22, 2021, 5:09 p.m.