Print the dependency tree for a given report using orderly log
Source:R/dependencies.R
orderly_graph.Rd
Investigate the dependency structure in a set of orderly reports. This function allows the dependency graph to be created for set of reports that have been run and committed (the archive) or of a set of reports that could be run (the src) to be discovered and printed to screen. This is experimental and somewhat subject to change and improvement.
Usage
orderly_graph(
name,
id = "latest",
root = NULL,
locate = TRUE,
direction = "downstream",
propagate = TRUE,
max_depth = Inf,
recursion_limit = 100,
show_all = FALSE,
use = "archive"
)
Arguments
- name
the name of the report
- id
the id of the report, if omitted, use the id of the latest report
- root
The path to an orderly root directory, or
NULL
(the default) to search for one from the current working directory iflocate
isTRUE
.- locate
Logical, indicating if the configuration should be searched for. If
TRUE
andconfig
is not given, then orderly looks in the working directory and up through its parents until it finds anorderly_config.yml
file.- direction
A string indicating if we want to move up or down the tree permitted values are upstream, downstream
- propagate
A boolean indicating if we want to propagate out of date through the tree
- max_depth
A numeric, how far back should the tree go, this can be useful to truncate a very large tree. (default = Inf)
- recursion_limit
A numeric, limit for depth of tree, if the tree goes beyond this then an error is thrown. (default = 100)
- show_all
A boolean, should we show all reports in the tree, not just the latest.
- use
Character string indicating what we read to infer the dependency tree. Current valid values are
archive
(the default), which reads from archive reports andsrc
which reads from the source reports.
Details
orderly allows a report to rely on the artefacts of one or more other orderly reports. This allows users to develop a network of interconnected reports where the output from report becomes the source of data for another. There are two natural questions that can develop around this workflow:
We have updated a report; what are the reports that depend on this so that we can re-run them?
We have a report that we want to re-run to ensure uses the latest information. Which other reports are used (directly or indirectly) by this report?
This function displays this information in an easily readable format. Allowing users to see the dependency tree and which reports are out of date and need to be re-run.
Remark
By default the tree is built using data from the local report database (see orderly_commit, orderly_db). This means that it will not find changes from a report that has not be run and committed. That is, if a user changes a report to use or create different artefacts this will not be picked up by the function until the reports are re-run and committed to the archive.
It is possible to generate a tree from the source reports by using
use = "src"
- this generates the "theoretical tree", and has
no concept of being "up to date" or of ids.
Warning
This interface is considered experimental and may change without notice. Please do not depend on it in scripts as it may break things. Consider this a (hopefully) useful way of exploring the dependencies in your reports interactively - let us know what is missing and we'll try and build it out.
Examples
path <- orderly1::orderly_example("demo")
id <- orderly1::orderly_run("other", root = path, parameters=list(nmin=0))
#> [ name ] other
#> [ id ] 20250731-134545-63048c16
#> [ sources ] functions.R
#> [ parameter ] nmin: 0
#> [ start ] 2025-07-31 13:45:45.391925
#> [ data ] source => extract: 20 x 2
#> [ parameter ] nmin: 0
#>
#> > 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_record_577715486
#> 2
#> [ end ] 2025-07-31 13:45:45.412733
#> [ elapsed ] Ran report in 0.02080774 secs
#> [ artefact ] summary.csv: 3fac8347e152c84c96e6676413c718b7
#> [ ... ] graph.png: 67b3e662440b3978ee78b9d4cc159884
orderly1::orderly_commit(id, root = path)
#> [ commit ] other/20250731-134545-63048c16
#> [ copy ]
#> [ import ] other:20250731-134545-63048c16
#> [ success ] :)
#> [1] "/tmp/Rtmp82yBdj/file1cbf213723cb/archive/other/20250731-134545-63048c16"
id <- orderly1::orderly_run("use_dependency", root = path)
#> [ name ] use_dependency
#> [ id ] 20250731-134545-9eafd67e
#> [ depends ] other@20250731-134545-63048c16:summary.csv -> incoming.csv
#> [ start ] 2025-07-31 13:45:45.623092
#>
#> > d <- read.csv("incoming.csv", stringsAsFactors = FALSE)
#>
#> > png("graph.png")
#>
#> > par(mar = c(15, 4, 0.5, 0.5))
#>
#> > barplot(setNames(d$number, d$name), las = 2)
#>
#> > dev.off()
#> agg_record_577715486
#> 2
#>
#> > info <- orderly1::orderly_run_info()
#>
#> > saveRDS(info, "info.rds")
#> [ end ] 2025-07-31 13:45:45.638347
#> [ elapsed ] Ran report in 0.0152545 secs
#> [ artefact ] graph.png: 67b3e662440b3978ee78b9d4cc159884
#> [ ... ] info.rds: 80db902f0cdffc287eccb16c817cb068
orderly1::orderly_commit(id, root = path)
#> [ commit ] use_dependency/20250731-134545-9eafd67e
#> [ copy ]
#> [ import ] use_dependency:20250731-134545-9eafd67e
#> [ success ] :)
#> [1] "/tmp/Rtmp82yBdj/file1cbf213723cb/archive/use_dependency/20250731-134545-9eafd67e"
id <- orderly1::orderly_run("use_dependency_2", root = path)
#> [ name ] use_dependency_2
#> [ id ] 20250731-134545-c4d51205
#> [ depends ] use_dependency@20250731-134545-9eafd67e:graph.png -> graph.png
#> [ start ] 2025-07-31 13:45:45.77205
#>
#> > stopifnot(file.exists("graph.png"))
#>
#> > saveRDS(orderly1::orderly_run_info(), "third.rds")
#> [ end ] 2025-07-31 13:45:45.77472
#> [ elapsed ] Ran report in 0.002670288 secs
#> [ artefact ] third.rds: 06fed696019250c9e871868f4353b82b
orderly1::orderly_commit(id, root = path)
#> [ commit ] use_dependency_2/20250731-134545-c4d51205
#> [ copy ]
#> [ import ] use_dependency_2:20250731-134545-c4d51205
#> [ success ] :)
#> [1] "/tmp/Rtmp82yBdj/file1cbf213723cb/archive/use_dependency_2/20250731-134545-c4d51205"
orderly1::orderly_graph("other", root = path)
#> other [20250731-134545-63048c16]
#> └──use_dependency [20250731-134545-9eafd67e]
#> └──use_dependency_2 [20250731-134545-c4d51205]
#>
orderly1::orderly_graph("use_dependency_2", root = path,
direction = "upstream")
#> use_dependency_2 [20250731-134545-c4d51205]
#> └──use_dependency [20250731-134545-9eafd67e]
#> └──other [20250731-134545-63048c16]
#>