Run a reportSource:
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
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 )
Name of the report to run (see
orderly_list()). A leading
src/will be removed if provided, allowing easier use of autocomplete. Alternatively, the default of
NULLis useful if you have already set the working directory to be the source directory.
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.
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.
The path to an orderly root directory, or
NULL(the default) to search for one from the current working directory if
Logical, indicating if the configuration should be searched for. If
configis not given, then orderly looks in the working directory and up through its parents until it finds an
Print the result of running the R code to the console
An optional character string containing a message explaining why the report was run
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.
Should draft reports be used for dependencies? This should be used only in development. Valid values are logical (
FALSE) or use the string
newerto use draft reports where they are newer than archive reports. For consistency,
neverare equivalent to
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
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).
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
orderly.ymland must be present in
Parameters are passed to the report as a named list, for example
(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
Environment variables that are created in
will be available while the report runs. Those that begin with
ORDERLY_ will be saved into the
$env section (except for any that match the
patterns "TOKEN", "PAT" or "PASS").
orderly_log() for controlling display of log
messages (not just R output)
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) #> [ name ] minimal #> [ id ] 20220516-160556-74f58c86 #> [ start ] 2022-05-16 16:05:56 #> [ data ] source => dat: 20 x 2 #> #> > png("mygraph.png") #> #> > par(mar = c(15, 4, 0.5, 0.5)) #> #> > barplot(setNames(dat$number, dat$name), las = 2) #> #> > dev.off() #> agg_png #> 2 #> [ end ] 2022-05-16 16:05:56 #> [ elapsed ] Ran report in 0.01711535 secs #> [ artefact ] mygraph.png: 175369b2bcf4115f343c8ad746c0c072 # Every report gets a unique identifier, based on the time (it is # ISO 8601 time with random hex appended to end) id #>  "20220516-160556-74f58c86" # After being run, a report is a "draft" and will exist in the # drafts directory: orderly::orderly_list_drafts(root = path) #> name id #> 1 minimal 20220516-160556-74f58c86 # Draft reports are always stored in the path # <root>/draft/<name>/<id>, so we have dir(file.path(path, "draft", "minimal", id)) #>  "mygraph.png" "orderly.yml" "orderly_run.rds" "script.R" # 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) #> [ name ] other #> [ id ] 20220516-160556-83cb6d13 #> [ sources ] functions.R #> [ parameter ] nmin: 0.2 #> [ start ] 2022-05-16 16:05:56 #> [ data ] source => extract: 19 x 2 #> [ parameter ] nmin: 0.2 #> #> > extract$number <- extract$number + rnorm(1) #> #> > write.csv(extract, "summary.csv", row.names = TRUE) #> #> > png("graph.png") #> #> > par(mar = c(15, 4, 0.5, 0.5)) #> #> > do_plot(extract) #> #> > dev.off() #> agg_png #> 2 #> [ end ] 2022-05-16 16:05:56 #> [ elapsed ] Ran report in 0.01790285 secs #> [ artefact ] summary.csv: 08a4566d063098080bfd318f675926f2 #> [ ... ] graph.png: 9d98e56ce7726a1523c1b03eb0e4efb4 # These parameters can be used in SQL queries or in the report # code.