orderly_run {orderly} | R Documentation |
Run a report
Description
Run a report. This will create a new directory in
drafts/<reportname>
, copy your declared resources there,
extract data from databases (if you are using them), run your
script and check that all expected artefacts were created. Once
successfully run you can use orderly_commit()
to move
it to the archive
directory.
Usage
orderly_run(
name = NULL,
parameters = NULL,
envir = NULL,
root = NULL,
locate = TRUE,
echo = TRUE,
message = NULL,
instance = NULL,
use_draft = FALSE,
remote = NULL,
tags = NULL
)
Arguments
name |
Name of the report to run (see
|
parameters |
Parameters passed to the report. A named list of
parameters declared in the |
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 |
locate |
Logical, indicating if the configuration should be
searched for. If |
echo |
Print the result of running the R code to the console |
message |
An optional character string containing a message explaining why the report was run |
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
|
use_draft |
Should draft reports be used for dependencies?
This should be used only in development. Valid values are
logical ( |
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 |
tags |
Character vector of tags to add to the report. Tags
are immutable and cannot be removed once the report is run.
Tags added here will be in addition to any tags listed in
the |
Details
Parameters are passed to the report as a named list, for example
id <- orderly::orderly_run("other", list(nmin = 0.2), root = path)
(see the examples). The names of the parameters (here,
nmin
) must correspond to declared parameters in the
orderly.yml
. It is an error if parameters without a
default are omitted, and it is an error if unknown parameters are
provided.
Environment variables that are created in orderly_envir.yml
will be available while the report runs. Those that begin with
ORDERLY_
will be saved into the orderly_run.rds
within the $env
section (except for any that match the
patterns "TOKEN", "PAT" or "PASS").
Value
The id of the newly created report
See Also
orderly_log()
for controlling display of log
messages (not just R output)
Examples
path <- orderly::orderly_example("demo")
# To run most reports, provide the report name (and the path if
# not running in the working directory, as is the case here):
id <- orderly::orderly_run("minimal", root = path)
# Every report gets a unique identifier, based on the time (it is
# ISO 8601 time with random hex appended to end)
id
# After being run, a report is a "draft" and will exist in the
# drafts directory:
orderly::orderly_list_drafts(root = path)
# Draft reports are always stored in the path
# <root>/draft/<name>/<id>, so we have
dir(file.path(path, "draft", "minimal", id))
# which contains the files when the report was run.
# If a report has parameters, then these must be passed in as a
# named list.
id <- orderly::orderly_run("other", list(nmin = 0.2), root = path)
# These parameters can be used in SQL queries or in the report
# code.