Skip to content

Commit

Permalink
Merge pull request #183 from mrc-ide/mrc-5111
Browse files Browse the repository at this point in the history
Drop `locate` argument everywhere public-facing
  • Loading branch information
richfitz authored Oct 18, 2024
2 parents 581a8e9 + be61222 commit 1b65946
Show file tree
Hide file tree
Showing 53 changed files with 215 additions and 374 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: orderly2
Title: Orderly Next Generation
Version: 1.99.42
Version: 1.99.43
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"),
email = "[email protected]"),
person("Robert", "Ashton", role = "aut"),
Expand Down
9 changes: 4 additions & 5 deletions R/cleanup.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@
##'
##' # Do the actual deletion:
##' orderly2::orderly_cleanup("data", root = path)
orderly_cleanup <- function(name = NULL, dry_run = FALSE, root = NULL,
locate = TRUE) {
status <- orderly_cleanup_status(name, root, locate)
orderly_cleanup <- function(name = NULL, dry_run = FALSE, root = NULL) {
status <- orderly_cleanup_status(name, root)
n <- length(status$delete)
if (n == 0) {
cli::cli_alert_success("Nothing to clean")
Expand All @@ -93,7 +92,7 @@ orderly_cleanup <- function(name = NULL, dry_run = FALSE, root = NULL,

##' @export
##' @rdname orderly_cleanup
orderly_cleanup_status <- function(name = NULL, root = NULL, locate = TRUE) {
orderly_cleanup_status <- function(name = NULL, root = NULL) {
p <- get_active_packet()
is_active <- !is.null(p)
if (is_active) {
Expand All @@ -107,7 +106,7 @@ orderly_cleanup_status <- function(name = NULL, root = NULL, locate = TRUE) {
root_path <- detect_orderly_interactive_path(path)
name <- basename(path)
} else {
root_path <- orderly_src_root(root, locate, call = environment())
root_path <- orderly_src_root(root)
if (is.null(name)) {
## This situation would be very odd, just disallow it
cli::cli_abort("If 'root' is given explicitly, 'name' is required")
Expand Down
2 changes: 1 addition & 1 deletion R/context.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ orderly_run_info <- function() {
id <- ctx$packet$id %||% NA_character_
name <- ctx$name

root <- root_open(ctx$root, FALSE, TRUE, environment())
root <- root_open(ctx$root, require_orderly = TRUE)

deps <- ctx$packet$depends
deps_n <- vnapply(deps, function(x) nrow(x$files))
Expand Down
4 changes: 2 additions & 2 deletions R/gitignore.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
##'
##' @return Nothing, called for its side effects
##' @export
orderly_gitignore_update <- function(name, root = NULL, locate = TRUE) {
root_path <- orderly_src_root(root, locate, call = environment())
orderly_gitignore_update <- function(name, root = NULL) {
root_path <- orderly_src_root(root)
do_orderly_gitignore_update(name, root_path, environment())
}

Expand Down
6 changes: 2 additions & 4 deletions R/graph.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
orderly_graph_packets <- function(from = NULL, to = NULL,
root = NULL, locate = FALSE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_graph_packets <- function(from = NULL, to = NULL, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
if (is.null(from) == is.null(to)) {
cli::cli_abort("Exactly one of 'from' and 'to' must be given")
}
Expand Down
39 changes: 15 additions & 24 deletions R/location.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@
##'
##' @return Nothing
##' @export
orderly_location_add <- function(name, type, args, root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_location_add <- function(name, type, args, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
assert_scalar_character(name, call = environment())

if (name %in% location_reserved_name) {
Expand All @@ -95,7 +94,7 @@ orderly_location_add <- function(name, type, args, root = NULL, locate = TRUE) {
loc <- new_location_entry(name, type, args, call = environment())
if (type == "path") {
assert_scalar_character(args$path, name = "path")
root_open(args$path, locate = FALSE, require_orderly = FALSE)
root_open(args$path, require_orderly = FALSE)
} else if (type == "http") {
assert_scalar_character(args$url, name = "url")
} else if (type == "packit") {
Expand Down Expand Up @@ -174,9 +173,8 @@ orderly_location_add_packit <- function(name, url, token = NULL,
##'
##' @return Nothing
##' @export
orderly_location_rename <- function(old, new, root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_location_rename <- function(old, new, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
assert_scalar_character(new, call = call)

if (old %in% location_reserved_name) {
Expand Down Expand Up @@ -205,9 +203,8 @@ orderly_location_rename <- function(old, new, root = NULL, locate = TRUE) {
##'
##' @return Nothing
##' @export
orderly_location_remove <- function(name, root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_location_remove <- function(name, root = NULL) {
root <- root_open(root, require_orderly = FALSE)

if (name %in% location_reserved_name) {
cli::cli_abort("Cannot remove default location '{name}'")
Expand Down Expand Up @@ -261,9 +258,8 @@ orderly_location_remove <- function(name, root = NULL, locate = TRUE) {
##' locations listed here.
##'
##' @export
orderly_location_list <- function(verbose = FALSE, root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_location_list <- function(verbose = FALSE, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
if (verbose) {
root$config$location
} else {
Expand All @@ -289,10 +285,8 @@ orderly_location_list <- function(verbose = FALSE, root = NULL, locate = TRUE) {
##' @return Nothing
##'
##' @export
orderly_location_pull_metadata <- function(location = NULL, root = NULL,
locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_location_pull_metadata <- function(location = NULL, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
location_name <- location_resolve_valid(location, root,
include_local = FALSE,
include_orphan = FALSE,
Expand Down Expand Up @@ -352,9 +346,8 @@ orderly_location_pull_metadata <- function(location = NULL, root = NULL,
##' @return Invisibly, the ids of packets that were pulled
##' @export
orderly_location_pull_packet <- function(..., options = NULL, recursive = NULL,
root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
root = NULL) {
root <- root_open(root, require_orderly = FALSE)
options <- as_orderly_search_options(options, list(allow_remote = TRUE))
if (!options$allow_remote) {
cli::cli_abort(
Expand Down Expand Up @@ -449,10 +442,8 @@ orderly_location_pull_packet <- function(..., options = NULL, recursive = NULL,
##' known on the other location).
##'
##' @export
orderly_location_push <- function(packet_id, location, root = NULL,
locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_location_push <- function(packet_id, location, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
location_name <- location_resolve_valid(location, root,
include_local = FALSE,
include_orphan = FALSE,
Expand Down
2 changes: 1 addition & 1 deletion R/location_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ orderly_location_path <- R6::R6Class(

public = list(
initialize = function(path) {
private$root <- root_open(path, locate = FALSE, require_orderly = FALSE)
private$root <- root_open(path, require_orderly = FALSE)
},

list = function() {
Expand Down
9 changes: 4 additions & 5 deletions R/orderly.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
##' @examples
##' path <- orderly2::orderly_example("default")
##' orderly2::orderly_list_src(root = path)
orderly_list_src <- function(root = NULL, locate = TRUE) {
root_path <- orderly_src_root(root, locate)
orderly_list_src <- function(root = NULL) {
root_path <- orderly_src_root(root)
if (!file.exists(file.path(root_path, "src"))) {
return(character())
}
Expand Down Expand Up @@ -51,9 +51,8 @@ orderly_list_src <- function(root = NULL, locate = TRUE) {
##'
##' @return Nothing, called for its side effects only
##' @export
orderly_new <- function(name, template = NULL, force = FALSE,
root = NULL, locate = TRUE) {
root <- root_open(root, locate, require_orderly = TRUE, call = environment())
orderly_new <- function(name, template = NULL, force = FALSE, root = NULL) {
root <- root_open(root, require_orderly = TRUE)
dest <- file.path(root$path, "src", name)
existing_entrypoint_filename <- find_entrypoint_filename(
dest, suppress_zero_files = TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/outpack_checksum.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## present. It might have been intended for the R-backed server, now
## defunct?
outpack_checksum <- function(hash_algorithm = NULL, root = NULL) {
root <- root_open(root, locate = TRUE, require_orderly = FALSE)
root <- root_open(root, require_orderly = FALSE)
hash_algorithm <- hash_algorithm %||% root$config$core$hash_algorithm

## Don't use the index ever here; we want to always read this from
Expand Down
11 changes: 4 additions & 7 deletions R/outpack_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
##' core.path_archive = NULL,
##' root = path)
##' fs::dir_tree(path, all = TRUE)
orderly_config_set <- function(..., options = list(...), root = NULL,
locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_config_set <- function(..., options = list(...), root = NULL) {
root <- root_open(root, require_orderly = FALSE)
if (!missing(options) && ...length() > 0) {
stop("If 'options' is given, no dot arguments are allowed")
}
Expand Down Expand Up @@ -111,9 +109,8 @@ orderly_config_set <- function(..., options = list(...), root = NULL,
##' path <- withr::local_tempdir()
##' orderly2::orderly_init(path)
##' orderly2::orderly_config(path)
orderly_config <- function(root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_config <- function(root = NULL) {
root <- root_open(root, require_orderly = FALSE)
root$config
}

Expand Down
12 changes: 4 additions & 8 deletions R/outpack_hash.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
##' @export
##' @examples
##' orderly2::orderly_hash_data("hello", "md5")
orderly_hash_file <- function(path, algorithm = NULL, root = NULL,
locate = TRUE) {
orderly_hash_file <- function(path, algorithm = NULL, root = NULL) {
if (is.null(algorithm)) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
root <- root_open(root, require_orderly = FALSE)
algorithm <- root$config$core$hash_algorithm
}
hash_file(path, algorithm, call = environment())
Expand All @@ -35,11 +33,9 @@ orderly_hash_file <- function(path, algorithm = NULL, root = NULL,
##' @param data A string to hash
##' @export
##' @rdname orderly_hash
orderly_hash_data <- function(data, algorithm = NULL, root = NULL,
locate = TRUE) {
orderly_hash_data <- function(data, algorithm = NULL, root = NULL) {
if (is.null(algorithm)) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
root <- root_open(root, require_orderly = FALSE)
algorithm <- root$config$core$hash_algorithm
}
hash_data(data, algorithm, call = call)
Expand Down
5 changes: 2 additions & 3 deletions R/outpack_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@
##' @export
orderly_copy_files <- function(..., files, dest, overwrite = TRUE,
envir = parent.frame(), options = NULL,
root = NULL, locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
root = NULL) {
root <- root_open(root, require_orderly = FALSE)

## Validate files and dest early; it gives a better error where this
## was not provided with names.
Expand Down
19 changes: 6 additions & 13 deletions R/outpack_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,18 @@
##' this id is not known
##'
##' @param root The path to the root directory, or `NULL` (the
##' default) to search for one from the current working directory if
##' `locate` is `TRUE`. This function does not require that the
##' directory is configured for orderly, and can be any `outpack`
##' root (see [orderly2::orderly_init] for details).
##'
##' @param locate Logical, indicating if the root should be searched
##' for. If `TRUE`, then we looks in the directory given for `root`
##' (or the working directory if `NULL`) and then up through its
##' parents until it finds an `.outpack` directory or
##' `orderly_config.yml`
##' default) to search for one from the current working
##' directory. This function does not require that the directory is
##' configured for orderly, and can be any `outpack` root (see
##' [orderly2::orderly_init] for details).
##'
##' @return A list of metadata. See the outpack schema for details
##' (https://github.com/mrc-ide/outpack)
##'
##' @export
orderly_metadata <- function(id, root = NULL, locate = FALSE) {
orderly_metadata <- function(id, root = NULL) {
validate_outpack_id(id, call = environment())
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
root <- root_open(root, require_orderly = FALSE)
path_metadata <- file.path(root$path, ".outpack", "metadata", id)
if (!file.exists(path_metadata)) {
cli::cli_abort("Packet '{id}' not found in outpack index")
Expand Down
2 changes: 1 addition & 1 deletion R/outpack_packet.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
##' @noRd
outpack_packet_start <- function(path, name, parameters = NULL, id = NULL,
root = NULL) {
root <- root_open(root, locate = FALSE, require_orderly = FALSE)
root <- root_open(root, require_orderly = FALSE)

assert_scalar_character(name)
assert_is_directory(path)
Expand Down
6 changes: 2 additions & 4 deletions R/outpack_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,8 @@
##' names of `extract`; see Details for more information.
##'
##' @export
orderly_metadata_extract <- function(..., extract = NULL, root = NULL,
locate = TRUE) {
root <- root_open(root, locate = locate, require_orderly = FALSE,
call = environment())
orderly_metadata_extract <- function(..., extract = NULL, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
if (dots_is_literal_id(...)) {
ids <- ..1
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/prune.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
##'
##' @return Invisibly, a character vector of orphaned packet ids
##' @export
orderly_prune_orphans <- function(root = NULL, locate = TRUE) {
root <- root_open(root, locate = TRUE, require_orderly = FALSE)
orderly_prune_orphans <- function(root = NULL) {
root <- root_open(root, require_orderly = FALSE)
id <- root$index$location("orphan")$packet
if (length(id) == 0) {
return(invisible(id))
Expand Down
2 changes: 1 addition & 1 deletion R/query_explain.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
orderly_query_explain <- function(..., parameters = NULL,
envir = parent.frame(),
options = NULL, root = NULL) {
root <- root_open(root, locate = TRUE, require_orderly = FALSE)
root <- root_open(root, require_orderly = FALSE)
query <- as_orderly_query(...)
options <- as_orderly_search_options(options)
found <- orderly_search(query, parameters = parameters, envir = envir,
Expand Down
2 changes: 1 addition & 1 deletion R/query_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ query_index <- R6::R6Class(
## help with the pulling metadata issue (as we could then control only
## pulling once in a session).
new_query_index <- function(root, options) {
root <- root_open(root, locate = FALSE, require_orderly = FALSE)
root <- root_open(root, require_orderly = FALSE)

if (options$pull_metadata) {
orderly_location_pull_metadata(options$location, root)
Expand Down
2 changes: 1 addition & 1 deletion R/query_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
##' @export
orderly_search <- function(..., parameters = NULL, envir = parent.frame(),
options = NULL, root = NULL) {
root <- root_open(root, locate = TRUE, require_orderly = FALSE)
root <- root_open(root, require_orderly = FALSE)
query <- as_orderly_query(...)
options <- as_orderly_search_options(options)
validate_parameters(parameters, environment())
Expand Down
Loading

0 comments on commit 1b65946

Please sign in to comment.