Skip to contents

This function allows inspection of some of orderly's metadata during an orderly run. The format returned is internal to orderly and subject to change. It is designed to be used within report code. To use in conjunction with orderly_test_start(), you must pass in the path to the report in question.

Usage

orderly_run_info(path = NULL)

Arguments

path

Path to the report currently being run. This should be left as NULL when running a report, and the path to the report being run should be used when using orderly_test_start()

Value

A list of metadata about the current report

Warning

It is important that this data is treated as readonly!

Examples

path <- orderly::orderly_example("demo")

# This example uses orderly_run_info within its script, saving the
# output to "output.rds"
readLines(file.path(path, "src", "use_dependency", "script.R"))
#> [1] "d <- read.csv(\"incoming.csv\", stringsAsFactors = FALSE)"
#> [2] ""                                                         
#> [3] "png(\"graph.png\")"                                       
#> [4] "par(mar = c(15, 4, .5, .5))"                              
#> [5] "barplot(setNames(d$number, d$name), las = 2)"             
#> [6] "dev.off()"                                                
#> [7] ""                                                         
#> [8] "info <- orderly::orderly_run_info()"                      
#> [9] "saveRDS(info, \"info.rds\")"                              

# Run the dependency:
id <- orderly::orderly_run("other", list(nmin = 0), root = path)
#> [ name       ]  other
#> [ id         ]  20220118-093859-e9daf78f
#> [ sources    ]  functions.R
#> [ parameter  ]  nmin: 0
#> [ start      ]  2022-01-18 09:38:59
#> [ 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_png 
#>       2 
#> [ end        ]  2022-01-18 09:38:59
#> [ elapsed    ]  Ran report in 0.06274104 secs
#> [ artefact   ]  summary.csv: 3fac8347e152c84c96e6676413c718b7
#> [ ...        ]  graph.png: 22c5cd614e90dfa0660595620b2af604
orderly::orderly_commit(id, root = path)
#> [ commit     ]  other/20220118-093859-e9daf78f
#> [ copy       ]
#> [ import     ]  other:20220118-093859-e9daf78f
#> [ success    ]  :)
#> [1] "/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmpMWUKEw/file17e344d75945/archive/other/20220118-093859-e9daf78f"

# Then the report
id <- orderly::orderly_run("use_dependency", root = path)
#> [ name       ]  use_dependency
#> [ id         ]  20220118-093900-58a99b8a
#> [ depends    ]  [email protected]:summary.csv -> incoming.csv
#> [ start      ]  2022-01-18 09:39:00
#> 
#> > 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_png 
#>       2 
#> 
#> > info <- orderly::orderly_run_info()
#> 
#> > saveRDS(info, "info.rds")
#> [ end        ]  2022-01-18 09:39:00
#> [ elapsed    ]  Ran report in 0.03875113 secs
#> [ artefact   ]  graph.png: 22c5cd614e90dfa0660595620b2af604
#> [ ...        ]  info.rds: c829fe9d80866926cb08db5fd84e9d00

# This is the contents:
readRDS(file.path(path, "draft", "use_dependency", id, "info.rds"))
#> $id
#> [1] "20220118-093900-58a99b8a"
#> 
#> $name
#> [1] "use_dependency"
#> 
#> $root
#> [1] "/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmpMWUKEw/file17e344d75945"
#> 
#> $depends
#>                         id index  name draft    filename           as is_pinned
#> 1 20220118-093859-e9daf78f     1 other    NA summary.csv incoming.csv     FALSE
#>                                                                                                                          path
#> 1 /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmpMWUKEw/file17e344d75945/archive/other/20220118-093859-e9daf78f
#>   is_latest                             hash                time id_requested
#> 1      TRUE 3fac8347e152c84c96e6676413c718b7 2022-01-18 09:39:00       latest
#>