Skip to content

Commit

Permalink
Explicit arguments to orderly_run
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Oct 18, 2024
1 parent c767d16 commit 83d508f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
16 changes: 9 additions & 7 deletions R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
##' @section Equivalence to the old `use_draft` option:
##'
##' The above location handling generalises orderly (v1)'s old
##' `use_draft` option, in terms of the `location` argument to
##' orderly2::orderly_search_options`:
##' `use_draft` option, in terms of the new `location` argument:
##'
##' * `use_draft = TRUE` is `location = "local"`
##' * `use_draft = FALSE` is `location = c(...)` where you should provide
Expand All @@ -72,7 +71,7 @@
##' as they currently exist on production right now with the options:
##'
##' ```
##' location = "production", pull_metadata = TRUE, require_unpacked = FALSE
##' location = "production", pull_metadata = TRUE
##' ```
##'
##' which updates your current metadata from production, then runs
Expand Down Expand Up @@ -127,9 +126,7 @@
##' @param echo Optional logical to control printing output from
##' `source()` to the console.
##'
##' @param search_options Optional control over locations, when used
##' with [orderly2::orderly_dependency]; converted into a
##' [orderly2::orderly_search_options] object, see Details.
##' @inheritParams orderly_search
##'
##' @param root The path to the root directory, or `NULL` (the
##' default) to search for one from the current working
Expand All @@ -153,7 +150,8 @@
##' # and we can query the metadata:
##' orderly2::orderly_metadata_extract(name = "data", root = path)
orderly_run <- function(name, parameters = NULL, envir = NULL, echo = TRUE,
search_options = NULL, root = NULL) {
location = NULL, allow_remote = NULL,
pull_metadata = FALSE, root = NULL) {
env_root_src <- Sys.getenv("ORDERLY_SRC_ROOT", NA_character_)
root <- root_open(root, require_orderly = is.na(env_root_src),
call = environment())
Expand All @@ -175,6 +173,10 @@ orderly_run <- function(name, parameters = NULL, envir = NULL, echo = TRUE,
parameters <- check_parameters(parameters, dat$parameters, environment())
orderly_validate(dat, src)

search_options <- orderly_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)

id <- outpack_id()
path <- file.path(root_src, "draft", name, id)
fs::dir_create(path)
Expand Down
32 changes: 25 additions & 7 deletions man/orderly_run.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-run.R
Original file line number Diff line number Diff line change
Expand Up @@ -781,15 +781,15 @@ test_that("Can select location when querying dependencies for a report", {

## Filter to only allow prod:
id2 <- orderly_run_quietly("depends",
search_options = list(location = "prod"),
location = "prod",
root = path[["us"]],
envir = new.env())
expect_equal(orderly_metadata(id2, path[["us"]])$depends$packet,
ids[["prod"]])

## Allow any location:
id3 <- orderly_run_quietly("depends",
search_options = list(location = c("prod", "dev")),
location = c("prod", "dev"),
root = path[["us"]],
envir = new.env())
expect_equal(orderly_metadata(id3, path[["us"]])$depends$packet,
Expand Down

0 comments on commit 83d508f

Please sign in to comment.