Clean up orderly draft and data directories. Deletes all drafts
(possibly just for a set of report names) and then deletes
dangling data sets that are not pointed to by any draft or
committed reports. Running cleanup does not affect any reports
that have been committed with orderly_commit()
(i.e.,
the contents of the archive/
directory).
Usage
orderly_cleanup(
name = NULL,
root = NULL,
locate = TRUE,
draft = TRUE,
data = TRUE,
failed_only = FALSE
)
Arguments
- name
Optional name; in this case only clean up drafts with this name
- 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.- draft
Logical, indicating if drafts should be removed
- data
Logical, indicating if dangling data should be removed (data not used by any draft or archived report).
- failed_only
Delete only failed reports (those without the end-of-run metadata). This will also clean up drafts created by
orderly_test_start()
Examples
# In a new example orderly, run two reports and commit only the
# second one:
path <- orderly1::orderly_example("minimal")
id1 <- orderly1::orderly_run("example", root = path)
#> [ name ] example
#> [ id ] 20250731-134541-e942121e
#> [ start ] 2025-07-31 13:45:41.913532
#> [ 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_record_1861921880
#> 2
#> [ end ] 2025-07-31 13:45:41.932125
#> [ elapsed ] Ran report in 0.01859307 secs
#> [ artefact ] mygraph.png: a7b94ccda59d3cdc6de2c3b088822f33
id2 <- orderly1::orderly_run("example", root = path)
#> [ name ] example
#> [ id ] 20250731-134541-f4db06a7
#> [ start ] 2025-07-31 13:45:41.958736
#> [ 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_record_1861921880
#> 2
#> [ end ] 2025-07-31 13:45:41.980686
#> [ elapsed ] Ran report in 0.02195024 secs
#> [ artefact ] mygraph.png: a7b94ccda59d3cdc6de2c3b088822f33
orderly1::orderly_commit(id2, root = path)
#> [ commit ] example/20250731-134541-f4db06a7
#> [ copy ]
#> [ import ] example:20250731-134541-f4db06a7
#> [ success ] :)
#> [1] "/tmp/Rtmp82yBdj/file1cbf119d37b0/archive/example/20250731-134541-f4db06a7"
# We now have one draft and one archive report:
orderly1::orderly_list_drafts(root = path)
#> name id
#> 1 example 20250731-134541-e942121e
orderly1::orderly_list_archive(root = path)
#> name id
#> 1 example 20250731-134541-f4db06a7
# To clean up the drafts:
orderly1::orderly_cleanup(root = path)
#> [ clean ] Found 1 draft report
#> [ clean ] /tmp/Rtmp82yBdj/file1cbf119d37b0/draft/example/20250731-134541-e942121e
#> [ clean ] Found 0 csv files
#> [ clean ] Found 0 rds files
# We now have no draft and one archive reports:
orderly1::orderly_list_drafts(root = path)
#> [1] name id
#> <0 rows> (or 0-length row.names)
orderly1::orderly_list_archive(root = path)
#> name id
#> 1 example 20250731-134541-f4db06a7