Skip to content

Commit

Permalink
Rename arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Oct 24, 2024
1 parent 9ddcc1d commit edb6e2e
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 87 deletions.
12 changes: 6 additions & 6 deletions R/compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ compare_filesets <- function(target, current) {
orderly_compare_packets <- function(target, current,
location = NULL,
allow_remote = NULL,
pull_metadata = FALSE,
fetch_metadata = FALSE,
root = NULL) {
root <- root_open(root, require_orderly = FALSE)
validate_outpack_id(target, call = environment())
validate_outpack_id(current, call = environment())

options <- build_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
fetch_metadata = fetch_metadata)

if (options$pull_metadata) {
if (options$fetch_metadata) {
orderly_location_fetch_metadata(options$location, root = root)
}

Expand Down Expand Up @@ -115,7 +115,7 @@ compare_file_contents <- function(cmp, files) {
# very straightforward, and covers the case where the file only exists
# remotely transparent.
#
# pull_metadata is intentionally hardcoded to FALSE, regardless of what the
# fetch_metadata is intentionally hardcoded to FALSE, regardless of what the
# user may have specified as an argument to orderly_compare_packets: the
# latter would have already pulled the files once, and we don't need to do it
# again.
Expand All @@ -124,15 +124,15 @@ compare_file_contents <- function(cmp, files) {
files = files,
location = cmp$search_options$location,
allow_remote = cmp$search_options$allow_remote,
pull_metadata = FALSE,
fetch_metadata = FALSE,
root = cmp$root)

orderly_copy_files(cmp$current$id,
dest = path_current,
files = files,
location = cmp$search_options$location,
allow_remote = cmp$search_options$allow_remote,
pull_metadata = FALSE,
fetch_metadata = FALSE,
root = cmp$root)


Expand Down
4 changes: 2 additions & 2 deletions R/interactive.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ detect_orderly_interactive_path <- function(
##' @export
orderly_interactive_set_search_options <- function(location = NULL,
allow_remote = NULL,
pull_metadata = FALSE) {
fetch_metadata = FALSE) {
options <- build_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
fetch_metadata = fetch_metadata)
.interactive$search_options <- options
}

Expand Down
8 changes: 4 additions & 4 deletions R/location.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ orderly_location_pull_metadata <- function(...) {
orderly_location_pull <- function(expr,
name = NULL,
location = NULL,
pull_metadata = FALSE,
fetch_metadata = FALSE,
recursive = NULL,
options = NULL,
root = NULL) {
Expand All @@ -410,14 +410,14 @@ orderly_location_pull <- function(expr,
name = name,
location = location,
allow_remote = TRUE,
pull_metadata = pull_metadata,
fetch_metadata = fetch_metadata,
root = root)
}

if (length(ids) == 0 || (length(ids) == 1 && is.na(ids))) {
if (!pull_metadata) {
if (!fetch_metadata) {
hint <- c(i = paste("Did you forget to pull metadata? You can do this",
"by using the argument {.code pull_metadata = TRUE}",
"by using the argument {.code fetch_metadata = TRUE}",
"in the call to 'orderly_location_pull()', or",
"by running 'orderly_location_fetch_metadata()'"))
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ orderly_dependency <- function(name, query, files) {
parameters = ctx$parameters,
location = search_options$location,
allow_remote = search_options$allow_remote,
pull_metadata = search_options$pull_metadata,
fetch_metadata = search_options$fetch_metadata,
envir = ctx$envir,
root = ctx$root)
}
Expand Down
6 changes: 3 additions & 3 deletions R/outpack_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
##' @export
orderly_copy_files <- function(expr, files, dest, overwrite = TRUE,
name = NULL, location = NULL,
allow_remote = NULL, pull_metadata = FALSE,
allow_remote = NULL, fetch_metadata = FALSE,
parameters = NULL, options = NULL,
envir = parent.frame(),
root = NULL) {
Expand All @@ -92,7 +92,7 @@ orderly_copy_files <- function(expr, files, dest, overwrite = TRUE,
## allow_remote later in error messages.
options <- build_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
fetch_metadata = fetch_metadata)

## Validate files and dest early; it gives a better error where this
## was not provided with names.
Expand All @@ -112,7 +112,7 @@ orderly_copy_files <- function(expr, files, dest, overwrite = TRUE,
parameters = parameters,
location = options$location,
allow_remote = options$allow_remote,
pull_metadata = options$pull_metadata,
fetch_metadata = options$fetch_metadata,
root = root)
if (length(id) > 1) {
cli::cli_abort(
Expand Down
4 changes: 2 additions & 2 deletions R/outpack_packet.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ outpack_packet_use_dependency <- function(packet, query, files,
envir = envir,
location = search_options$location,
allow_remote = search_options$allow_remote,
pull_metadata = search_options$pull_metadata,
fetch_metadata = search_options$fetch_metadata,
root = packet$root)
if (is.na(id)) {
explanation <- orderly_query_explain(
Expand All @@ -201,7 +201,7 @@ outpack_packet_use_dependency <- function(packet, query, files,
result <- orderly_copy_files(id, files = files, dest = packet$path,
location = search_options$location,
allow_remote = search_options$allow_remote,
pull_metadata = search_options$pull_metadata,
fetch_metadata = search_options$fetch_metadata,
overwrite = overwrite,
envir = envir,
root = packet$root)
Expand Down
5 changes: 3 additions & 2 deletions R/outpack_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@
##'
##' @export
orderly_metadata_extract <- function(expr = NULL, name = NULL, location = NULL,
allow_remote = NULL, pull_metadata = FALSE,
allow_remote = NULL,
fetch_metadata = FALSE,
extract = NULL, options = NULL,
root = NULL) {
root <- root_open(root, require_orderly = FALSE)
Expand All @@ -211,7 +212,7 @@ orderly_metadata_extract <- function(expr = NULL, name = NULL, location = NULL,
name = name,
location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata,
fetch_metadata = fetch_metadata,
root = root)
}
extract <- parse_extract(extract, environment())
Expand Down
4 changes: 2 additions & 2 deletions R/query_explain.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ orderly_query_explain <- function(expr, name = NULL, scope = NULL,
found <- orderly_search(query, parameters = parameters, envir = envir,
location = location,
allow_remote = allow_remote,
pull_metadata = FALSE,
fetch_metadata = FALSE,
root = root)
query_simplified <- query_simplify(query)
ret <- list(found = found,
Expand All @@ -40,7 +40,7 @@ orderly_query_explain <- function(expr, name = NULL, scope = NULL,
envir = envir,
location = location,
allow_remote = allow_remote,
pull_metadata = FALSE,
fetch_metadata = FALSE,
root = root)
ret$parts[[name]] <- list(
name = name,
Expand Down
2 changes: 1 addition & 1 deletion R/query_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ query_index <- R6::R6Class(
new_query_index <- function(root, options) {
root <- root_open(root, require_orderly = FALSE)

if (options$pull_metadata) {
if (options$fetch_metadata) {
orderly_location_fetch_metadata(options$location, root = root)
}
idx <- root$index$data()
Expand Down
26 changes: 14 additions & 12 deletions R/query_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
##'
##' @param options **DEPRECATED**. Please don't use this any more, and
##' instead use the arguments `location`, `allow_remote` and
##' `pull_metadata` directly.
##' `fetch_metadata` directly.
##'
##' @return A character vector of matching ids. In the case of no
##' match from a query returning a single value (e.g., `latest(...)`
Expand All @@ -32,14 +32,14 @@
orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL,
parameters = NULL, envir = parent.frame(),
location = NULL, allow_remote = NULL,
pull_metadata = FALSE, options = NULL,
fetch_metadata = FALSE, options = NULL,
root = NULL) {
root <- root_open(root, require_orderly = FALSE)
compatibility_fix_options(options, "orderly_search")
query <- as_orderly_query(expr, name, scope, subquery)
options <- build_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
fetch_metadata = fetch_metadata)
validate_parameters(parameters, environment())
orderly_query_eval(query, parameters, envir, options, root,
call = environment())
Expand All @@ -64,9 +64,9 @@ orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL,
##' you might pull a large quantity of data. The default is `NULL`. This is
##' `TRUE` if remote locations are listed explicitly as a character
##' vector in the `location` argument, or if you have specified
##' `pull_metadata = TRUE`, otherwise `FALSE`.
##' `fetch_metadata = TRUE`, otherwise `FALSE`.
##'
##' @param pull_metadata Logical, indicating if we should pull
##' @param fetch_metadata Logical, indicating if we should pull
##' metadata immediately before the search. If `location` is given,
##' then we will pass this through to
##' [orderly2::orderly_location_fetch_metadata] to filter locations
Expand All @@ -76,7 +76,7 @@ orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL,
##' needlessly slow.
##'
##' @return An object of class `orderly_search_options` which should
##' not be modified after creation (but see note about `pull_metadata`)
##' not be modified after creation (but see note about `fetch_metadata`)
##'
##' @export
orderly_search_options <- function(location = NULL,
Expand All @@ -85,7 +85,8 @@ orderly_search_options <- function(location = NULL,
cli::cli_warn(
c("Use of 'orderly_search_options' is deprecated",
i = paste("You should just pass these arguments directly into functions",
"that previously accepted 'options'")),
"that previously accepted 'options'"),
i = "Please note that 'pull_metadata' has become 'fetch_metadata'"),
.frequency = "regularly",
.frequency_id = "orderly_search_options")
build_search_options(location, allow_remote, pull_metadata)
Expand All @@ -99,7 +100,7 @@ compatibility_fix_options <- function(options, name,
cli::cli_warn(
c("Use of '{arg}' in '{name}()' is deprecated and will be removed soon",
i = paste("Please pass the arguments to options ('location',",
"'allow_remote' and 'pull_metadata') directly to '{name}'"),
"'allow_remote' and 'fetch_metadata') directly to '{name}'"),
"!" = paste("If you have {.strong also} passed these options in",
"to your function I am about to silently overwrite them")),
.frequency = "regularly",
Expand All @@ -111,22 +112,23 @@ compatibility_fix_options <- function(options, name,


build_search_options <- function(location = NULL, allow_remote = NULL,
pull_metadata = FALSE, call = parent.frame()) {
fetch_metadata = FALSE,
call = parent.frame()) {
if (!is.null(location)) {
assert_character(location, call = call)
}
has_remote_location <- !is.null(location) &&
length(setdiff(location, c("local", "orphan")) > 0)

assert_scalar_logical(pull_metadata, call = call)
assert_scalar_logical(fetch_metadata, call = call)
if (is.null(allow_remote)) {
allow_remote <- has_remote_location || pull_metadata
allow_remote <- has_remote_location || fetch_metadata
} else {
assert_scalar_logical(allow_remote, call = call)
}
ret <- list(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
fetch_metadata = fetch_metadata)
class(ret) <- "orderly_search_options"
ret
}
Expand Down
12 changes: 6 additions & 6 deletions R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
##'
##' @section Which packets might be selected from locations?:
##'
##' The arguments `location`, `allow_remote` and `pull_metadata`
##' The arguments `location`, `allow_remote` and `fetch_metadata`
##' control where outpack searches for packets with the given query
##' and if anything might be moved over the network (or from one
##' outpack archive to another). By default everything is resolved
Expand All @@ -48,7 +48,7 @@
##' same content anywhere else in an unpacked packet we will reuse
##' the same content without re-fetching.
##'
##' If `pull_metadata = TRUE`, then we will refresh location metadata
##' If `fetch_metadata = TRUE`, then we will refresh location metadata
##' before pulling, and the `location` argument controls which
##' locations are pulled from.
##'
Expand All @@ -68,7 +68,7 @@
##' as they currently exist on production right now with the options:
##'
##' ```
##' location = "production", pull_metadata = TRUE
##' location = "production", fetch_metadata = TRUE
##' ```
##'
##' which updates your current metadata from production, then runs
Expand Down Expand Up @@ -127,7 +127,7 @@
##'
##' @param search_options **DEPRECATED**. Please don't use this any
##' more, and instead use the arguments `location`, `allow_remote`
##' and `pull_metadata` directly.
##' and `fetch_metadata` directly.
##'
##' @param root The path to the root directory, or `NULL` (the
##' default) to search for one from the current working
Expand Down Expand Up @@ -155,7 +155,7 @@
##' fs::dir_delete(path)
orderly_run <- function(name, parameters = NULL, envir = NULL, echo = TRUE,
location = NULL, allow_remote = NULL,
pull_metadata = FALSE, search_options = NULL,
fetch_metadata = FALSE, search_options = NULL,
root = NULL) {
env_root_src <- Sys.getenv("ORDERLY_SRC_ROOT", NA_character_)
root <- root_open(root, require_orderly = is.na(env_root_src),
Expand All @@ -181,7 +181,7 @@ orderly_run <- function(name, parameters = NULL, envir = NULL, echo = TRUE,

search_options <- build_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
fetch_metadata = fetch_metadata)

id <- outpack_id()
path <- file.path(root_src, "draft", name, id)
Expand Down
2 changes: 1 addition & 1 deletion R/validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ orderly_validate_archive <- function(expr = NULL, name = NULL,
name = name,
location = "local",
allow_remote = FALSE,
pull_metadata = FALSE,
fetch_metadata = FALSE,
root = root)
}

Expand Down
6 changes: 3 additions & 3 deletions man/orderly_compare_packets.Rd

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

8 changes: 4 additions & 4 deletions man/orderly_copy_files.Rd

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

Loading

0 comments on commit edb6e2e

Please sign in to comment.