From ab260ec8544df743eee7585ca6512bdba5435fab Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 23 Oct 2024 16:15:52 +0100 Subject: [PATCH 1/8] Rename pull methods --- NAMESPACE | 2 + R/deprecated.R | 22 +++ R/location.R | 63 +++++--- R/outpack_config.R | 2 +- R/outpack_helpers.R | 4 +- R/outpack_packet.R | 2 +- R/query_index.R | 2 +- R/query_search.R | 2 +- R/root.R | 2 +- _pkgdown.yml | 4 +- man/orderly2-deprecated.Rd | 27 ++++ man/orderly_copy_files.Rd | 6 +- man/orderly_init.Rd | 2 +- man/orderly_interactive_set_search_options.Rd | 2 +- man/orderly_location_add.Rd | 2 +- man/orderly_location_list.Rd | 2 +- ....Rd => orderly_location_metadata_fetch.Rd} | 10 +- ...ull_packet.Rd => orderly_location_pull.Rd} | 8 +- man/orderly_metadata_extract.Rd | 2 +- man/orderly_run.Rd | 2 +- man/orderly_search.Rd | 2 +- man/orderly_search_options.Rd | 2 +- tests/testthat/test-location-path.R | 6 +- tests/testthat/test-location.R | 149 +++++++++--------- tests/testthat/test-outpack-config.R | 8 +- tests/testthat/test-outpack-helpers.R | 4 +- tests/testthat/test-outpack-packet.R | 8 +- tests/testthat/test-outpack-root.R | 2 +- tests/testthat/test-outpack-tools.R | 2 +- tests/testthat/test-query-index.R | 6 +- tests/testthat/test-query-search.R | 10 +- tests/testthat/test-run.R | 8 +- tests/testthat/test-zzz-location-http.R | 2 +- vignettes/collaboration.Rmd | 6 +- 34 files changed, 229 insertions(+), 154 deletions(-) create mode 100644 R/deprecated.R create mode 100644 man/orderly2-deprecated.Rd rename man/{orderly_location_pull_metadata.Rd => orderly_location_metadata_fetch.Rd} (76%) rename man/{orderly_location_pull_packet.Rd => orderly_location_pull.Rd} (93%) diff --git a/NAMESPACE b/NAMESPACE index 281f972c..83f06cd5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,6 +27,8 @@ export(orderly_location_add_http) export(orderly_location_add_packit) export(orderly_location_add_path) export(orderly_location_list) +export(orderly_location_metadata_fetch) +export(orderly_location_pull) export(orderly_location_pull_metadata) export(orderly_location_pull_packet) export(orderly_location_push) diff --git a/R/deprecated.R b/R/deprecated.R new file mode 100644 index 00000000..83a45285 --- /dev/null +++ b/R/deprecated.R @@ -0,0 +1,22 @@ +##' Deprecated functions in orderly2. These functions still work (*for +##' now*) but will be removed shortly. Please update your code. +##' +##' * `orderly_location_pull_packet`; please use [orderly_location_pull()] +##' * `orderly_location_pull_metadata`; please use +##' [orderly_location_metadata_fetch()] +##' +##' @param ... Arguments forwarded to the new version +##' @return See the linked pages above for the current return type. +##' @rdname orderly2-deprecated +##' @name orderly2-deprecated +NULL + + +deprecate_warn <- function(old, new, body = NULL) { + cli::cli_warn( + c(paste("'{old}()' is deprecated and will be removed soon, please", + "use '{new}()' instead"), + body), + .frequency = "regularly", + .frequency_id = paste0("orderly_deprecate:", old)) +} diff --git a/R/location.R b/R/location.R index a362a061..9b6b4f38 100644 --- a/R/location.R +++ b/R/location.R @@ -3,7 +3,7 @@ ##' based locations are supported, with limited support for custom ##' locations. Note that adding a location does *not* pull metadata ##' from it, you need to call -##' [orderly2::orderly_location_pull_metadata] first. The function +##' [orderly2::orderly_location_metadata_fetch] first. The function ##' `orderly_location_add` can add any sort of location, but the other ##' functions documented here (`orderly_location_add_path`, etc) will ##' typically be much easier to use in practice. @@ -290,7 +290,7 @@ orderly_location_remove <- function(name, root = NULL) { ##' `args`. The `args` column is a list column, with each element ##' being the key-value pair arguments to the location. ##' -##' @seealso [orderly2::orderly_location_pull_metadata], which can +##' @seealso [orderly2::orderly_location_metadata_fetch], which can ##' update your outpack index with metadata from any of the ##' locations listed here. ##' @@ -305,11 +305,11 @@ orderly_location_list <- function(verbose = FALSE, root = NULL) { } -##' Pull metadata from a location, updating the index. This should +##' Fetch metadata from a location, updating the index. This should ##' always be relatively quick as it updates only small files that ##' contain information about what can be found in remote packets. ##' -##' @title Pull metadata from a location +##' @title Fetch metadata from a location ##' ##' @param location The name of a location to pull from (see ##' [orderly2::orderly_location_list] for possible values). If not @@ -322,7 +322,7 @@ orderly_location_list <- function(verbose = FALSE, root = NULL) { ##' @return Nothing ##' ##' @export -orderly_location_pull_metadata <- function(location = NULL, root = NULL) { +orderly_location_metadata_fetch <- function(location = NULL, root = NULL) { root <- root_open(root, require_orderly = FALSE) location_name <- location_resolve_valid(location, root, include_local = FALSE, @@ -333,7 +333,7 @@ orderly_location_pull_metadata <- function(location = NULL, root = NULL) { "Fetching metadata from {length(location_name)} location{?s}:", "{squote({location_name})}")) for (name in location_name) { - res <- location_pull_metadata(name, root) + res <- location_metadata_fetch(name, root) if (res$total > 0) { cli_alert_success(paste( "Found {res$total} packet{?s} at '{name}', of which", @@ -357,6 +357,17 @@ orderly_location_pull_metadata <- function(location = NULL, root = NULL) { } +##' @rdname orderly2-deprecated +##' @keywords internal +##' @export +orderly_location_pull_metadata <- function(...) { + deprecate_warn( + "orderly_location_pull_metadata", + "orderly_location_metadata_fetch") + orderly_location_metadata_fetch(...) +} + + ##' Pull one or more packets (including all their files) into this ##' archive from one or more of your locations. This will make files ##' available for use as dependencies (e.g., with @@ -382,15 +393,15 @@ orderly_location_pull_metadata <- function(location = NULL, root = NULL) { ##' ##' @return Invisibly, the ids of packets that were pulled ##' @export -orderly_location_pull_packet <- function(expr, - name = NULL, - location = NULL, - pull_metadata = FALSE, - recursive = NULL, - options = NULL, - root = NULL) { +orderly_location_pull <- function(expr, + name = NULL, + location = NULL, + pull_metadata = FALSE, + recursive = NULL, + options = NULL, + root = NULL) { root <- root_open(root, require_orderly = FALSE) - compatibility_fix_options(options, "orderly_location_pull_packet") + compatibility_fix_options(options, "orderly_location_pull") if (expr_is_literal_id(expr, name)) { ids <- expr @@ -407,8 +418,8 @@ orderly_location_pull_packet <- function(expr, if (!pull_metadata) { hint <- c(i = paste("Did you forget to pull metadata? You can do this", "by using the argument {.code pull_metadata = TRUE}", - "in the call to 'orderly_location_pull_packet()', or", - "by running 'orderly_location_pull_metadata()'")) + "in the call to 'orderly_location_pull()', or", + "by running 'orderly_location_metadata_fetch()'")) } else { hint <- NULL } @@ -462,6 +473,19 @@ orderly_location_pull_packet <- function(expr, } +##' @rdname orderly2-deprecated +##' @keywords internal +##' @export +orderly_location_pull_packet <- function(...) { + deprecate_warn( + "orderly_location_pull_packet", + "orderly_location_pull", + c(i = paste("We like 'orderly_location_pull' as the inverse of", + "'orderly_location_push'"))) + orderly_location_pull(...) +} + + ##' Push tree to location. This function works out what packets are ##' not known at the location and then what files are required to ##' create them. It then pushes all the files required to build all @@ -525,7 +549,7 @@ orderly_location_push <- function(expr, location, name = NULL, dry_run = FALSE, driver <- location_driver(location_name, root) location_push_files(plan$files, driver, root) location_push_metadata(plan$packet_id, driver, root) - orderly_location_pull_metadata(location_name, root) + orderly_location_metadata_fetch(location_name, root) } } @@ -614,7 +638,7 @@ orderly_location_custom <- function(driver, ...) { } -location_pull_metadata <- function(location_name, root, call = parent.frame()) { +location_metadata_fetch <- function(location_name, root, call = parent.frame()) { index <- root$index$data() driver <- location_driver(location_name, root) @@ -825,7 +849,8 @@ location_build_pull_plan_location <- function(packets, location, root, call) { } else { ## In the case where the above is used, we probably have ## up-to-date metadata so we don't display this. - hint <- "Do you need to run 'orderly2::orderly_location_pull_metadata()'?" + hint <- paste("Do you need to run", + "{.run orderly2::orderly_location_metadata_fetch()}?") } cli::cli_abort(c("Failed to find packet{?s} {squote(missing)}", i = "Looked in location{?s} {squote(location_name)}", diff --git a/R/outpack_config.R b/R/outpack_config.R index e700441c..293440d3 100644 --- a/R/outpack_config.R +++ b/R/outpack_config.R @@ -126,7 +126,7 @@ config_set_require_complete_tree <- function(value, root, call) { if (value) { id <- root$index$unpacked() if (length(id) > 0) { - orderly_location_pull_packet(id, recursive = TRUE, root = root) + orderly_location_pull(id, recursive = TRUE, root = root) } } diff --git a/R/outpack_helpers.R b/R/outpack_helpers.R index f280fef2..21c55c21 100644 --- a/R/outpack_helpers.R +++ b/R/outpack_helpers.R @@ -22,7 +22,7 @@ ##' it's not unpacked but also not known to be present in some other ##' remote) then this will fail because it's impossible to resolve ##' the files. Consider refreshing the metadata with -##' [orderly2::orderly_location_pull_metadata] to refresh this. +##' [orderly2::orderly_location_metadata_fetch] to refresh this. ##' * if the `id` is not unpacked *and* no local copy of the files ##' referred to can be found, we error by default (but see the next ##' option). However, sometimes the file you refer to might also be @@ -32,7 +32,7 @@ ##' * if the `id` is not unpacked, there is no local copy of the file ##' and if `allow_remote` is `TRUE` we will try and request the file ##' from whatever remote would be selected by -##' [orderly2::orderly_location_pull_packet] for this packet. +##' [orderly2::orderly_location_pull] for this packet. ##' ##' Note that empty directories might be created on failure. ##' diff --git a/R/outpack_packet.R b/R/outpack_packet.R index 404eb96e..6a3026f9 100644 --- a/R/outpack_packet.R +++ b/R/outpack_packet.R @@ -195,7 +195,7 @@ outpack_packet_use_dependency <- function(packet, query, files, packet$root$config$core$require_complete_tree && !(id %in% packet$root$index$unpacked()) if (needs_pull) { - orderly_location_pull_packet(id, root = packet$root) + orderly_location_pull(id, root = packet$root) } result <- orderly_copy_files(id, files = files, dest = packet$path, diff --git a/R/query_index.R b/R/query_index.R index 0df2abab..26e4ab74 100644 --- a/R/query_index.R +++ b/R/query_index.R @@ -87,7 +87,7 @@ new_query_index <- function(root, options) { root <- root_open(root, require_orderly = FALSE) if (options$pull_metadata) { - orderly_location_pull_metadata(options$location, root = root) + orderly_location_metadata_fetch(options$location, root = root) } idx <- root$index$data() metadata <- idx$metadata diff --git a/R/query_search.R b/R/query_search.R index 3312810b..2ec9d8fa 100644 --- a/R/query_search.R +++ b/R/query_search.R @@ -69,7 +69,7 @@ orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL, ##' @param pull_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_pull_metadata] to filter locations +##' [orderly2::orderly_location_metadata_fetch] to filter locations ##' to update. If pulling many packets in sequence, you *will* want ##' to update this option to `FALSE` after the first pull, otherwise ##' it will update the metadata between every packet, which will be diff --git a/R/root.R b/R/root.R index 8e5c589a..bf7e2dc3 100644 --- a/R/root.R +++ b/R/root.R @@ -43,7 +43,7 @@ ##' ##' @param require_complete_tree Logical, indicating if we require a ##' complete tree of packets. This currently affects -##' [orderly2::orderly_location_pull_packet], by requiring that it +##' [orderly2::orderly_location_pull], by requiring that it ##' always operates in recursive mode. This is `FALSE` by default, ##' but set to `TRUE` if you want your archive to behave well as a ##' location; if `TRUE` you will always have all the packets that diff --git a/_pkgdown.yml b/_pkgdown.yml index 52b4e586..1d5d07a0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -57,8 +57,8 @@ reference: - title: Interact with locations - subtitle: Use locations contents: - - orderly_location_pull_metadata - - orderly_location_pull_packet + - orderly_location_metadata_fetch + - orderly_location_pull - orderly_location_push - subtitle: Manage locations contents: diff --git a/man/orderly2-deprecated.Rd b/man/orderly2-deprecated.Rd new file mode 100644 index 00000000..d9cc3cec --- /dev/null +++ b/man/orderly2-deprecated.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/deprecated.R, R/location.R +\name{orderly2-deprecated} +\alias{orderly2-deprecated} +\alias{orderly_location_pull_metadata} +\alias{orderly_location_pull_packet} +\title{Deprecated functions in orderly2. These functions still work (\emph{for +now}) but will be removed shortly. Please update your code.} +\usage{ +orderly_location_pull_metadata(...) + +orderly_location_pull_packet(...) +} +\arguments{ +\item{...}{Arguments forwarded to the new version} +} +\value{ +See the linked pages above for the current return type. +} +\description{ +\itemize{ +\item \code{orderly_location_pull_packet}; please use \code{\link[=orderly_location_pull]{orderly_location_pull()}} +\item \code{orderly_location_pull_metadata}; please use +\code{\link[=orderly_location_metadata_fetch]{orderly_location_metadata_fetch()}} +} +} +\keyword{internal} diff --git a/man/orderly_copy_files.Rd b/man/orderly_copy_files.Rd index bc8e9abe..0a56f610 100644 --- a/man/orderly_copy_files.Rd +++ b/man/orderly_copy_files.Rd @@ -75,7 +75,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be @@ -129,7 +129,7 @@ failure): it's not unpacked but also not known to be present in some other remote) then this will fail because it's impossible to resolve the files. Consider refreshing the metadata with -\link{orderly_location_pull_metadata} to refresh this. +\link{orderly_location_metadata_fetch} to refresh this. \item if the \code{id} is not unpacked \emph{and} no local copy of the files referred to can be found, we error by default (but see the next option). However, sometimes the file you refer to might also be @@ -139,7 +139,7 @@ some other packet version you have locally. \item if the \code{id} is not unpacked, there is no local copy of the file and if \code{allow_remote} is \code{TRUE} we will try and request the file from whatever remote would be selected by -\link{orderly_location_pull_packet} for this packet. +\link{orderly_location_pull} for this packet. } Note that empty directories might be created on failure. diff --git a/man/orderly_init.Rd b/man/orderly_init.Rd index a773c687..08924391 100644 --- a/man/orderly_init.Rd +++ b/man/orderly_init.Rd @@ -31,7 +31,7 @@ exist only for convenience.} \item{require_complete_tree}{Logical, indicating if we require a complete tree of packets. This currently affects -\link{orderly_location_pull_packet}, by requiring that it +\link{orderly_location_pull}, by requiring that it always operates in recursive mode. This is \code{FALSE} by default, but set to \code{TRUE} if you want your archive to behave well as a location; if \code{TRUE} you will always have all the packets that diff --git a/man/orderly_interactive_set_search_options.Rd b/man/orderly_interactive_set_search_options.Rd index 02290ba6..4ec31908 100644 --- a/man/orderly_interactive_set_search_options.Rd +++ b/man/orderly_interactive_set_search_options.Rd @@ -26,7 +26,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_location_add.Rd b/man/orderly_location_add.Rd index 6800476c..dc3ebb8e 100644 --- a/man/orderly_location_add.Rd +++ b/man/orderly_location_add.Rd @@ -77,7 +77,7 @@ and pulled into your local archive. Currently only file and http based locations are supported, with limited support for custom locations. Note that adding a location does \emph{not} pull metadata from it, you need to call -\link{orderly_location_pull_metadata} first. The function +\link{orderly_location_metadata_fetch} first. The function \code{orderly_location_add} can add any sort of location, but the other functions documented here (\code{orderly_location_add_path}, etc) will typically be much easier to use in practice. diff --git a/man/orderly_location_list.Rd b/man/orderly_location_list.Rd index 12c535b9..0cf0e0c8 100644 --- a/man/orderly_location_list.Rd +++ b/man/orderly_location_list.Rd @@ -33,7 +33,7 @@ known at the current root), though you will typically be interested in \emph{other} locations. } \seealso{ -\link{orderly_location_pull_metadata}, which can +\link{orderly_location_metadata_fetch}, which can update your outpack index with metadata from any of the locations listed here. } diff --git a/man/orderly_location_pull_metadata.Rd b/man/orderly_location_metadata_fetch.Rd similarity index 76% rename from man/orderly_location_pull_metadata.Rd rename to man/orderly_location_metadata_fetch.Rd index 9a403c2f..142f1390 100644 --- a/man/orderly_location_pull_metadata.Rd +++ b/man/orderly_location_metadata_fetch.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/location.R -\name{orderly_location_pull_metadata} -\alias{orderly_location_pull_metadata} -\title{Pull metadata from a location} +\name{orderly_location_metadata_fetch} +\alias{orderly_location_metadata_fetch} +\title{Fetch metadata from a location} \usage{ -orderly_location_pull_metadata(location = NULL, root = NULL) +orderly_location_metadata_fetch(location = NULL, root = NULL) } \arguments{ \item{location}{The name of a location to pull from (see @@ -23,7 +23,7 @@ configured for orderly, and can be any \code{outpack} root (see Nothing } \description{ -Pull metadata from a location, updating the index. This should +Fetch metadata from a location, updating the index. This should always be relatively quick as it updates only small files that contain information about what can be found in remote packets. } diff --git a/man/orderly_location_pull_packet.Rd b/man/orderly_location_pull.Rd similarity index 93% rename from man/orderly_location_pull_packet.Rd rename to man/orderly_location_pull.Rd index cc2a1f18..d59c138c 100644 --- a/man/orderly_location_pull_packet.Rd +++ b/man/orderly_location_pull.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/location.R -\name{orderly_location_pull_packet} -\alias{orderly_location_pull_packet} +\name{orderly_location_pull} +\alias{orderly_location_pull} \title{Pull one or more packets from a location} \usage{ -orderly_location_pull_packet( +orderly_location_pull( expr, name = NULL, location = NULL, @@ -27,7 +27,7 @@ might in future expand this to allow wildcards or exceptions.} \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_metadata_extract.Rd b/man/orderly_metadata_extract.Rd index a9c43c61..38819ecf 100644 --- a/man/orderly_metadata_extract.Rd +++ b/man/orderly_metadata_extract.Rd @@ -37,7 +37,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_run.Rd b/man/orderly_run.Rd index e9b157d5..445fcb2b 100644 --- a/man/orderly_run.Rd +++ b/man/orderly_run.Rd @@ -47,7 +47,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_search.Rd b/man/orderly_search.Rd index 0413e553..5665187f 100644 --- a/man/orderly_search.Rd +++ b/man/orderly_search.Rd @@ -54,7 +54,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_search_options.Rd b/man/orderly_search_options.Rd index 567d0083..34cf7bb3 100644 --- a/man/orderly_search_options.Rd +++ b/man/orderly_search_options.Rd @@ -26,7 +26,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_metadata_fetch} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/tests/testthat/test-location-path.R b/tests/testthat/test-location-path.R index 4efbe3f6..4fd37717 100644 --- a/tests/testthat/test-location-path.R +++ b/tests/testthat/test-location-path.R @@ -279,8 +279,8 @@ test_that("push overlapping tree", { orderly_location_add_path("server", path = server$path, root = client) id_base <- create_random_packet(server) - orderly_location_pull_metadata(root = client) - suppressMessages(orderly_location_pull_packet(id_base, root = client)) + orderly_location_metadata_fetch(root = client) + suppressMessages(orderly_location_pull(id_base, root = client)) ids <- create_random_packet_chain(client, 3, id_base) plan <- orderly_location_push(ids[[3]], "server", root = client) @@ -367,7 +367,7 @@ test_that("allow relative paths in path locations", { b <- suppressMessages(orderly_init(file.path(tmp, "b"))) ids <- vcapply(1:3, function(i) create_random_packet(b)) withr::with_dir(a, orderly_location_add_path("b", path = "../b")) - orderly_location_pull_metadata(root = a) + orderly_location_metadata_fetch(root = a) expect_equal(orderly_search(root = a, location = "b"), ids) }) diff --git a/tests/testthat/test-location.R b/tests/testthat/test-location.R index 17809600..ceed5a4c 100644 --- a/tests/testthat/test-location.R +++ b/tests/testthat/test-location.R @@ -132,7 +132,7 @@ test_that("Can remove a location", { expect_setequal(orderly_location_list(root = root$a), c("local", "b", "c")) id <- create_random_packet(root$b) - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) # remove a location without packets expect_silent(orderly_location_remove("c", root = root$a)) @@ -164,9 +164,9 @@ test_that("Removing a location orphans packets only from that location", { id1 <- create_random_packet(root$c) id2 <- create_random_packet(root$b) - orderly_location_pull_metadata(root = root$b) - suppressMessages(orderly_location_pull_packet(id1, root = root$b)) - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$b) + suppressMessages(orderly_location_pull(id1, root = root$b)) + orderly_location_metadata_fetch(root = root$a) # id1 should now be found in both b and c index <- root$a$index$data() @@ -203,7 +203,7 @@ test_that("re-adding a location de-orphans packets", { id_b <- replicate(2, create_random_packet(root$b)) id_c <- replicate(3, create_random_packet(root$c)) - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) expect_message(orderly_location_remove("b", root = root$a), "Orphaning 2 packets") @@ -213,7 +213,7 @@ test_that("re-adding a location de-orphans packets", { expect_equal(nrow(root_open(root$a)$index$location(orphan)), 5) orderly_location_add_path("b", path = root$b, root = root$a) - expect_message(orderly_location_pull_metadata(root = root$a), + expect_message(orderly_location_metadata_fetch(root = root$a), "De-orphaning 2 packets") expect_equal(nrow(root_open(root$a)$index$location(orphan)), 3) @@ -249,7 +249,7 @@ test_that("can pull metadata from a file base location", { expect_equal(orderly_location_list(root = root_downstream), c("local", "upstream")) - orderly_location_pull_metadata("upstream", root = root_downstream) + orderly_location_metadata_fetch("upstream", root = root_downstream) ## Sensible tests here will be much easier to write once we have a ## decent query interface. @@ -270,7 +270,7 @@ test_that("can pull empty metadata", { orderly_location_add_path("upstream", path = root_upstream$path, root = root_downstream) - orderly_location_pull_metadata("upstream", root = root_downstream) + orderly_location_metadata_fetch("upstream", root = root_downstream) index <- root_downstream$index$data() expect_length(index$metadata, 0) @@ -303,7 +303,7 @@ test_that("pull metadata from subset of locations", { location_name <- c("x", "y", "z") - orderly_location_pull_metadata(c("x", "y"), root = root$a) + orderly_location_metadata_fetch(c("x", "y"), root = root$a) index <- root$a$index$data() expect_setequal(names(index$metadata), c(ids$x, ids$y)) expect_equal(index$location$location, rep(location_name[1:2], each = 3)) @@ -312,7 +312,7 @@ test_that("pull metadata from subset of locations", { expect_equal(index$metadata[ids$y], root$y$index$data()$metadata) - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) index <- root$a$index$data() expect_setequal(names(index$metadata), c(ids$x, ids$y, ids$z)) expect_equal(index$location$location, rep(location_name, each = 3)) @@ -324,15 +324,15 @@ test_that("pull metadata from subset of locations", { test_that("Can't pull metadata from an unknown location", { root <- create_temporary_root() expect_error( - orderly_location_pull_metadata("upstream", root = root), + orderly_location_metadata_fetch("upstream", root = root), "Unknown location: 'upstream'") }) test_that("No-op to pull metadata from no locations", { root <- create_temporary_root() - expect_silent(orderly_location_pull_metadata("local", root = root)) - expect_silent(orderly_location_pull_metadata(root = root)) + expect_silent(orderly_location_metadata_fetch("local", root = root)) + expect_silent(orderly_location_metadata_fetch(root = root)) }) @@ -353,17 +353,17 @@ test_that("Can pull metadata through chain of locations", { ## Create a packet and make sure it's in both b and c id1 <- create_random_packet(root$a) - orderly_location_pull_metadata(root = root$b) - suppressMessages(orderly_location_pull_packet(id1, root = root$b)) - orderly_location_pull_metadata(root = root$c) - suppressMessages(orderly_location_pull_packet(id1, root = root$c)) + orderly_location_metadata_fetch(root = root$b) + suppressMessages(orderly_location_pull(id1, root = root$b)) + orderly_location_metadata_fetch(root = root$c) + suppressMessages(orderly_location_pull(id1, root = root$c)) ## And another in just 'c' id2 <- create_random_packet(root$c) ## Then when we pull from d it will simultaneously learn about the ## packet from both locations: - orderly_location_pull_metadata(root = root$d) + orderly_location_metadata_fetch(root = root$d) index <- root$d$index$data() ## Metadata is correct @@ -387,8 +387,8 @@ test_that("can pull a packet from one location to another, using file store", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) - suppressMessages(orderly_location_pull_packet(id, root = root$dst)) + orderly_location_metadata_fetch(root = root$dst) + suppressMessages(orderly_location_pull(id, root = root$dst)) index <- root$dst$index$data() expect_equal(index$unpacked, id) @@ -408,10 +408,10 @@ test_that("can error where a query returns no packets", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) expect_error( - orderly_location_pull_packet(NULL, name = "data", root = root$dst), + orderly_location_pull(NULL, name = "data", root = root$dst), "No packets found in query, so cannot pull anything") expect_error( - orderly_location_pull_packet("latest", name = "data", root = root$dst), + orderly_location_pull("latest", name = "data", root = root$dst), "No packets found in query, so cannot pull anything") }) @@ -424,8 +424,8 @@ test_that("can pull a packet from one location to another, archive only", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) - suppressMessages(orderly_location_pull_packet(id, root = root$dst)) + orderly_location_metadata_fetch(root = root$dst) + suppressMessages(orderly_location_pull(id, root = root$dst)) index <- root$dst$index$data() expect_equal(index$unpacked, id) @@ -452,7 +452,7 @@ test_that("detect and avoid modified files in source repository", { } orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) ## Corrupt the file in the first id by truncating it: forcibly_truncate_file( @@ -460,7 +460,7 @@ test_that("detect and avoid modified files in source repository", { ## Then pull res <- testthat::evaluate_promise( - orderly_location_pull_packet(id[[1]], root = root$dst)) + orderly_location_pull(id[[1]], root = root$dst)) expect_match(res$messages, "Rejecting file from archive 'a.rds' in 'data/", all = FALSE) @@ -482,13 +482,13 @@ test_that("Do not unpack a packet twice", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) expect_equal( - suppressMessages(orderly_location_pull_packet(id, root = root$dst)), + suppressMessages(orderly_location_pull(id, root = root$dst)), id) expect_equal( - suppressMessages(orderly_location_pull_packet(id, root = root$dst)), + suppressMessages(orderly_location_pull(id, root = root$dst)), character(0)) }) @@ -502,13 +502,12 @@ test_that("Sensible error if packet not known", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) err <- expect_error( - suppressMessages(orderly_location_pull_packet(id, root = root$dst)), + suppressMessages(orderly_location_pull(id, root = root$dst)), sprintf("Failed to find packet '%s'", id), fixed = TRUE) - expect_equal( - err$body, - c(i = "Looked in location 'src'", - i = "Do you need to run 'orderly2::orderly_location_pull_metadata()'?")) + expect_match(err$body[[1]], "Looked in location 'src'") + expect_match(err$body[[2]], + "Do you need to run.+orderly_location_metadata_fetch") }) @@ -520,15 +519,15 @@ test_that("Sensible error if dependent packet not known", { id <- create_random_packet_chain(root$a, 5) orderly_location_add_path("a", path = root$a$path, root = root$b) - orderly_location_pull_metadata(root = root$b) - suppressMessages(orderly_location_pull_packet(id[[5]], root = root$b)) + orderly_location_metadata_fetch(root = root$b) + suppressMessages(orderly_location_pull(id[[5]], root = root$b)) orderly_location_add_path("b", path = root$b$path, root = root$c) - orderly_location_pull_metadata(root = root$c) + orderly_location_metadata_fetch(root = root$c) err <- expect_error( - suppressMessages(orderly_location_pull_packet(id[[5]], root = root$c)), + suppressMessages(orderly_location_pull(id[[5]], root = root$c)), sprintf("Failed to find packet '%s'", id[[4]])) ## This needs work. The shoddy pluralisation is the least of the ## issue, see mrc-4513; however, this situation is rare in most @@ -551,9 +550,9 @@ test_that("Can pull a tree recursively", { id <- as.list(create_random_packet_chain(root$src, 3)) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) expect_equal(suppressMessages( - orderly_location_pull_packet(id$c, recursive = TRUE, root = root$dst)), + orderly_location_pull(id$c, recursive = TRUE, root = root$dst)), c(id$a, id$b, id$c)) index <- root$dst$index$data() @@ -561,7 +560,7 @@ test_that("Can pull a tree recursively", { root$src$index$data()$unpacked) expect_equal(suppressMessages( - orderly_location_pull_packet(id$c, recursive = TRUE, root = root$dst)), + orderly_location_pull(id$c, recursive = TRUE, root = root$dst)), character(0)) }) @@ -615,7 +614,7 @@ test_that("informative error message when no locations configured", { location_resolve_valid(NULL, root, FALSE, FALSE, FALSE), "No suitable location found") expect_error( - orderly_location_pull_packet(outpack_id(), root = root), + orderly_location_pull(outpack_id(), root = root), "No suitable location found") }) @@ -631,21 +630,21 @@ test_that("Can filter locations", { ids_a <- vcapply(1:3, function(i) create_random_packet(root$a$path)) orderly_location_add_path("a", path = root$a$path, root = root$b) - orderly_location_pull_metadata(root = root$b) - suppressMessages(orderly_location_pull_packet(ids_a, root = root$b)) + orderly_location_metadata_fetch(root = root$b) + suppressMessages(orderly_location_pull(ids_a, root = root$b)) ids_b <- c(ids_a, vcapply(1:3, function(i) create_random_packet(root$b$path))) ids_c <- vcapply(1:3, function(i) create_random_packet(root$c$path)) orderly_location_add_path("a", path = root$a$path, root = root$d) orderly_location_add_path("c", path = root$c$path, root = root$d) - orderly_location_pull_metadata(root = root$d) - suppressMessages(orderly_location_pull_packet(ids_a, root = root$d)) - suppressMessages(orderly_location_pull_packet(ids_c, root = root$d)) + orderly_location_metadata_fetch(root = root$d) + suppressMessages(orderly_location_pull(ids_a, root = root$d)) + suppressMessages(orderly_location_pull(ids_c, root = root$d)) ids_d <- c(ids_c, vcapply(1:3, function(i) create_random_packet(root$d$path))) - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) ids <- unique(c(ids_a, ids_b, ids_c, ids_d)) expected <- function(ids, location_name) { @@ -689,10 +688,9 @@ test_that("Can filter locations", { err <- expect_error( location_build_pull_plan(ids, c("a", "b", "c"), NULL, root = root$dst), "Failed to find packets") - expect_equal( - err$body, - c(i = "Looked in locations 'a', 'b', and 'c'", - i = "Do you need to run 'orderly2::orderly_location_pull_metadata()'?")) + expect_match(err$body[[1]], "Looked in locations 'a', 'b', and 'c'") + expect_match(err$body[[2]], + "Do you need to run.+orderly_location_metadata_fetch") }) @@ -708,9 +706,9 @@ test_that("can pull from multiple locations with multiple files", { ids_a <- create_random_packet(root$a$path, n_files = 1) ids_b <- create_random_packet(root$b$path, n_files = 2) - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) suppressMessages( - orderly_location_pull_packet(NULL, name = "data", root = root$dst)) + orderly_location_pull(NULL, name = "data", root = root$dst)) ## It has pulled both packets, and correct number of files expect_setequal( @@ -734,7 +732,7 @@ test_that("nonrecursive pulls are prevented by configuration", { id <- create_random_packet_chain(root$src, 3) expect_error( - orderly_location_pull_packet(id[["c"]], recursive = FALSE, root = root$dst), + orderly_location_pull(id[["c"]], recursive = FALSE, root = root$dst), "'recursive' must be TRUE (or NULL) with your configuration", fixed = TRUE) }) @@ -751,16 +749,16 @@ test_that("if recursive pulls are required, pulls are recursive by default", { for (r in root[c("shallow", "deep")]) { orderly_location_add_path("src", path = root$src$path, root = r) - orderly_location_pull_metadata(root = r) + orderly_location_metadata_fetch(root = r) } suppressMessages( - orderly_location_pull_packet(id[["c"]], recursive = NULL, + orderly_location_pull(id[["c"]], recursive = NULL, root = root$shallow)) expect_equal(root$shallow$index$data()$unpacked, id[["c"]]) suppressMessages( - orderly_location_pull_packet(id[["c"]], recursive = NULL, + orderly_location_pull(id[["c"]], recursive = NULL, root = root$deep)) expect_setequal(root$deep$index$data()$unpacked, id) }) @@ -971,7 +969,7 @@ test_that("can pull packets as a result of a query", { }) orderly_location_add_path("src", path = root$src$path, root = root$dst$path) ids_moved <- suppressMessages( - orderly_location_pull_packet( + orderly_location_pull( "parameter:i < 3", name = "data", pull_metadata = TRUE, @@ -991,7 +989,7 @@ test_that("handle metadata where the hash does not match reported", { writeLines(json, path_metadata) err <- expect_error( - orderly_location_pull_metadata(root = here), + orderly_location_metadata_fetch(root = here), "Hash of metadata for '.+' from 'server' does") expect_equal( unname(err$message), @@ -1015,9 +1013,9 @@ test_that("handle metadata where two locations differ in hash for same id", { orderly_location_add_path("a", path = root$a$path, root = root$us) orderly_location_add_path("b", path = root$b$path, root = root$us) - orderly_location_pull_metadata(location = "a", root = root$us) + orderly_location_metadata_fetch(location = "a", root = root$us) err <- expect_error( - orderly_location_pull_metadata(location = "b", root = root$us), + orderly_location_metadata_fetch(location = "b", root = root$us), "Location 'b' has conflicting metadata") expect_equal(names(err$body), c("x", "i", "i", "i")) expect_match(err$body[[1]], @@ -1039,9 +1037,10 @@ test_that("avoid duplicated metadata", { mock_driver <- list(list = function(x) rbind(driver$list(), driver$list())) mock_location_driver <- mockery::mock(mock_driver) - mockery::stub(location_pull_metadata, "location_driver", mock_location_driver) + mockery::stub(location_metadata_fetch, "location_driver", + mock_location_driver) err <- expect_error( - location_pull_metadata("server", root = here), + location_metadata_fetch("server", root = here), "Duplicate metadata reported from location 'server'") expect_equal(names(err$body), c("x", "i", "i")) expect_equal(err$body[[1]], @@ -1060,12 +1059,12 @@ test_that("skip files in the file store", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) - suppressMessages(orderly_location_pull_packet(id[[1]], root = root$dst)) + orderly_location_metadata_fetch(root = root$dst) + suppressMessages(orderly_location_pull(id[[1]], root = root$dst)) withr::with_options(list(orderly.quiet = FALSE), { res <- testthat::evaluate_promise( - orderly_location_pull_packet(id[[2]], root = root$dst)) + orderly_location_pull(id[[2]], root = root$dst)) expect_match(res$messages, "Found 1 file in the file store", all = FALSE) expect_match(res$messages, "Need to fetch 2 files.+from 1 location", all = FALSE) @@ -1081,12 +1080,12 @@ test_that("skip files known elsewhere on disk", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_pull_metadata(root = root$dst) - suppressMessages(orderly_location_pull_packet(id[[1]], root = root$dst)) + orderly_location_metadata_fetch(root = root$dst) + suppressMessages(orderly_location_pull(id[[1]], root = root$dst)) withr::with_options(list(orderly.quiet = FALSE), { res <- testthat::evaluate_promise( - orderly_location_pull_packet(id[[2]], root = root$dst)) + orderly_location_pull(id[[2]], root = root$dst)) expect_match(res$messages, "Found 1 file on disk", all = FALSE) expect_match(res$messages, "Need to fetch 2 files.+from 1 location", all = FALSE) @@ -1101,7 +1100,7 @@ test_that("can prune orphans from tree", { } orderly_location_add_path("there", path = root$there$path, root = root$here) id <- create_random_packet_chain(root$there, 5) - orderly_location_pull_metadata(root = root$here) + orderly_location_metadata_fetch(root = root$here) expect_message( orderly_location_remove("there", root = root$here), "Orphaning 5 packets") @@ -1171,7 +1170,7 @@ test_that("be chatty when pulling packets", { expect_match(res$messages[[3]], "Added location 'server' (path)", fixed = TRUE) - res <- evaluate_promise(orderly_location_pull_metadata(root = here)) + res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[1]], "Fetching metadata from 1 location: 'server'") @@ -1181,20 +1180,20 @@ test_that("be chatty when pulling packets", { id1 <- create_random_packet(there) id2 <- create_random_packet(there) - res <- evaluate_promise(orderly_location_pull_metadata(root = here)) + res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[1]], "Fetching metadata from 1 location: 'server'") expect_match(res$messages[[2]], "Found 2 packets at 'server', of which 2 are new") - res <- evaluate_promise(orderly_location_pull_metadata(root = here)) + res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[2]], "Found 2 packets at 'server', of which 0 are new") id3 <- create_random_packet(there) - res <- evaluate_promise(orderly_location_pull_metadata(root = here)) + res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[2]], "Found 3 packets at 'server', of which 1 is new") diff --git a/tests/testthat/test-outpack-config.R b/tests/testthat/test-outpack-config.R index 3f21c6a1..3cbbfb5f 100644 --- a/tests/testthat/test-outpack-config.R +++ b/tests/testthat/test-outpack-config.R @@ -81,9 +81,9 @@ test_that("Can add file_store", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst$path) - orderly_location_pull_metadata(root = root$dst$path) + orderly_location_metadata_fetch(root = root$dst$path) suppressMessages( - orderly_location_pull_packet(id[["c"]], root = root$dst$path)) + orderly_location_pull(id[["c"]], root = root$dst$path)) expect_equal(root$dst$index$data()$unpacked, id[["c"]]) orderly_config_set(core.use_file_store = TRUE, root = root$dst) @@ -294,9 +294,9 @@ test_that("Enabling recursive pulls forces pulling missing packets", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst$path) - orderly_location_pull_metadata(root = root$dst$path) + orderly_location_metadata_fetch(root = root$dst$path) suppressMessages( - orderly_location_pull_packet(id[["c"]], root = root$dst$path)) + orderly_location_pull(id[["c"]], root = root$dst$path)) expect_equal(root$dst$index$unpacked(), id[["c"]]) suppressMessages( diff --git a/tests/testthat/test-outpack-helpers.R b/tests/testthat/test-outpack-helpers.R index 999c0e93..e553a2cf 100644 --- a/tests/testthat/test-outpack-helpers.R +++ b/tests/testthat/test-outpack-helpers.R @@ -23,7 +23,7 @@ test_that("can copy files from location, using store", { orderly_copy_files(id, files = c("data.rds" = "data.rds"), dest = tmp, root = here), "Packet '.+' not found in outpack index") - orderly_location_pull_metadata(root = here) + orderly_location_metadata_fetch(root = here) expect_error( orderly_copy_files(id, files = c("data.rds" = "data.rds"), dest = tmp, @@ -49,7 +49,7 @@ test_that("can copy files from location, using archive", { id <- create_random_packet(there) tmp <- withr::local_tempdir() - orderly_location_pull_metadata(root = here) + orderly_location_metadata_fetch(root = here) expect_error( orderly_copy_files(id, files = c("data.rds" = "data.rds"), dest = tmp, root = here), diff --git a/tests/testthat/test-outpack-packet.R b/tests/testthat/test-outpack-packet.R index 0da4cc38..1629f6f4 100644 --- a/tests/testthat/test-outpack-packet.R +++ b/tests/testthat/test-outpack-packet.R @@ -679,9 +679,9 @@ test_that("can pull in dependency from specific location", { }) orderly_location_add_path(name, path = root[[name]]$path, root = root$a) } - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) for (id in ids$z) { - suppressMessages(orderly_location_pull_packet(id, root = root$a)) + suppressMessages(orderly_location_pull(id, root = root$a)) } path_src <- temp_file() @@ -698,14 +698,14 @@ test_that("can pull in dependency from specific location", { fixed = TRUE) for (id in ids$x) { - suppressMessages(orderly_location_pull_packet(id, root = root$a)) + suppressMessages(orderly_location_pull(id, root = root$a)) } outpack_packet_use_dependency(p, query, c("data1.rds" = "data.rds"), search_options = options) expect_equal(p$depends[[1]]$packet, ids$x[[3]]) for (id in ids$y) { - suppressMessages(orderly_location_pull_packet(id, root = root$a)) + suppressMessages(orderly_location_pull(id, root = root$a)) } outpack_packet_use_dependency(p, query, c("data2.rds" = "data.rds"), search_options = options) diff --git a/tests/testthat/test-outpack-root.R b/tests/testthat/test-outpack-root.R index 2a975177..bf7c364e 100644 --- a/tests/testthat/test-outpack-root.R +++ b/tests/testthat/test-outpack-root.R @@ -99,7 +99,7 @@ test_that("Can work out what packets are missing", { } ids <- unname(create_random_packet_chain(root$a, 3)) orderly_location_add_path("a", path = root$a$path, root = root$b) - orderly_location_pull_metadata(root = root$b) + orderly_location_metadata_fetch(root = root$b) ## Nothing missing in this case: expect_equal(root_list_unknown_packets(ids, root$a), diff --git a/tests/testthat/test-outpack-tools.R b/tests/testthat/test-outpack-tools.R index 28c14d71..588201e9 100644 --- a/tests/testthat/test-outpack-tools.R +++ b/tests/testthat/test-outpack-tools.R @@ -378,7 +378,7 @@ test_that("can differentiate remote metadata", { expect_equal(d4$local, rep(c(TRUE, FALSE), c(5, 3))) expect_equal(d4$location, I(rep(list("local", "upstream"), c(5, 3)))) - suppressMessages(orderly_location_pull_packet(ids2[[2]], root = root)) + suppressMessages(orderly_location_pull(ids2[[2]], root = root)) d5 <- orderly_metadata_extract(root = root, allow_remote = TRUE) expect_equal(d5[names(d1)], d4[names(d1)]) diff --git a/tests/testthat/test-query-index.R b/tests/testthat/test-query-index.R index 2da2dd41..60c6ca43 100644 --- a/tests/testthat/test-query-index.R +++ b/tests/testthat/test-query-index.R @@ -7,7 +7,7 @@ test_that("index can include only unpacked packets", { x1 <- create_random_packet(root$src, "x") x2 <- create_random_packet(root$src, "x") - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) opts_all <- build_search_options(allow_remote = TRUE) opts_unpacked <- build_search_options(allow_remote = FALSE) @@ -18,7 +18,7 @@ test_that("index can include only unpacked packets", { expect_equal(index_unpacked$index$id, character(0)) for (i in c(x1, x2)) { - suppressMessages(orderly_location_pull_packet(i, root = root$dst)) + suppressMessages(orderly_location_pull(i, root = root$dst)) } index <- new_query_index(root$dst, opts_all) @@ -85,7 +85,7 @@ test_that("can apply a location filter to index", { create_random_packet(root[[name]], "data", list(p = i)) }) } - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) idx_with_location <- function(location) { options <- build_search_options(location = location, allow_remote = TRUE) diff --git a/tests/testthat/test-query-search.R b/tests/testthat/test-query-search.R index 3f20858e..5dc1fecf 100644 --- a/tests/testthat/test-query-search.R +++ b/tests/testthat/test-query-search.R @@ -213,7 +213,7 @@ test_that("Can filter query to packets that are locally available (unpacked)", { create_random_packet(root[[name]], "data", list(p = i)) }) } - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) expect_equal( orderly_search(quote(name == "data"), location = c("x", "y"), @@ -225,7 +225,7 @@ test_that("Can filter query to packets that are locally available (unpacked)", { character()) for (i in ids$x) { - suppressMessages(orderly_location_pull_packet(i, root = root$a)) + suppressMessages(orderly_location_pull(i, root = root$a)) } expect_equal( @@ -250,7 +250,7 @@ test_that("scope and allow_local can be used together to filter query", { x2 <- create_random_packet(root$src, "x", list(p = 1)) y1 <- create_random_packet(root$src, "y", list(p = 1)) y2 <- create_random_packet(root$src, "y", list(p = 1)) - orderly_location_pull_metadata(root = root$dst) + orderly_location_metadata_fetch(root = root$dst) options_local <- build_search_options(allow_remote = FALSE) options_remote <- build_search_options(allow_remote = TRUE) @@ -267,7 +267,7 @@ test_that("scope and allow_local can be used together to filter query", { NA_character_) for (i in c(x1, y1)) { - suppressMessages(orderly_location_pull_packet(i, root = root$dst)) + suppressMessages(orderly_location_pull(i, root = root$dst)) } expect_equal( @@ -1025,7 +1025,7 @@ test_that("Warn, but honour, on use of search options to search", { ids <- vcapply(1:3, function(i) { create_random_packet(root$b, "data", list(p = i)) }) - orderly_location_pull_metadata(root = root$a) + orderly_location_metadata_fetch(root = root$a) expect_equal(orderly_search(NULL, root = root$a), character()) diff --git a/tests/testthat/test-run.R b/tests/testthat/test-run.R index 8bd2fc48..e13b4bc7 100644 --- a/tests/testthat/test-run.R +++ b/tests/testthat/test-run.R @@ -764,9 +764,9 @@ test_that("Can select location when querying dependencies for a report", { envir = new.env()) orderly_location_add_path(nm, path = path[[nm]], root = path[["us"]]) - orderly_location_pull_metadata(nm, root = path[["us"]]) + orderly_location_metadata_fetch(nm, root = path[["us"]]) for (i in ids[[nm]]) { - suppressMessages(orderly_location_pull_packet(i, root = path[["us"]])) + suppressMessages(orderly_location_pull(i, root = path[["us"]])) } } } @@ -810,9 +810,9 @@ test_that("can select location when querying dependencies interactively", { ids[[nm]] <- orderly_run_quietly("data", envir = envir1, root = path[[nm]]) orderly_location_add_path(nm, path = path[[nm]], root = path[["us"]]) - orderly_location_pull_metadata(nm, root = path[["us"]]) + orderly_location_metadata_fetch(nm, root = path[["us"]]) for (i in ids[[nm]]) { - suppressMessages(orderly_location_pull_packet(i, root = path[["us"]])) + suppressMessages(orderly_location_pull(i, root = path[["us"]])) } } } diff --git a/tests/testthat/test-zzz-location-http.R b/tests/testthat/test-zzz-location-http.R index 5d571c9c..e8a2870d 100644 --- a/tests/testthat/test-zzz-location-http.R +++ b/tests/testthat/test-zzz-location-http.R @@ -86,7 +86,7 @@ describe("http location integration tests", { orderly_location_add_http("upstream", url = url, root = root_downstream) expect_equal(orderly_location_list(root = root_downstream), c("local", "upstream")) - orderly_location_pull_metadata("upstream", root = root_downstream) + orderly_location_metadata_fetch("upstream", root = root_downstream) idx <- root_downstream$index$data() expect_equal(names(idx$metadata), ids) diff --git a/vignettes/collaboration.Rmd b/vignettes/collaboration.Rmd index 9d698f70..1d4faeec 100644 --- a/vignettes/collaboration.Rmd +++ b/vignettes/collaboration.Rmd @@ -182,7 +182,7 @@ orderly2::orderly_metadata_extract( Having seen there is a new "data" packet here, he can pull this down locally (TODO: mrc-4414 makes this nicer): ```{r, as = "bob", orderly_root = path_bob} -orderly2::orderly_location_pull_packet(id) +orderly2::orderly_location_pull(id) ``` Now Bob is in a position to develop against the same packet that Alice ran (`r id`) @@ -209,7 +209,7 @@ and then pass this in to `orderly2::orderly_run` when running a report. In devel # Pulling complete trees, or not -When you pull packets from a server (with `orderly2::orderly_location_pull_packet()`), depending on your settings you will either end up with just the packet that you request, or that packet **plus** all of its recursive dependencies. This is controlled by the configuration option `core.require_complete_tree`, which is `FALSE` by default; this is suitable for most users, but servers should be set with `core.require_complete_tree = TRUE`. +When you pull packets from a server (with `orderly2::orderly_location_pull()`), depending on your settings you will either end up with just the packet that you request, or that packet **plus** all of its recursive dependencies. This is controlled by the configuration option `core.require_complete_tree`, which is `FALSE` by default; this is suitable for most users, but servers should be set with `core.require_complete_tree = TRUE`. In most of the situations above, the users are never holding the canonical source of the packets - so it does not matter if they don't have all if their dependencies. They do hold all the metadata for all packets (again, recursively) and could download the dependencies later if they wanted to inspect them. Typically though, this would just be extra space used up on disk. @@ -282,5 +282,5 @@ orderly2::orderly_location_add_path("alices_orderly", path_sharepoint_bob) 1. Pull the metadata and use the packets as desired ```{r, as="bob", orderly_root = path_bob} -orderly2::orderly_location_pull_metadata("alices_orderly") +orderly2::orderly_location_metadata_fetch("alices_orderly") ``` From 62226f3d72736bec132cd6ca17168818f2bdb3f9 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 23 Oct 2024 16:34:59 +0100 Subject: [PATCH 2/8] Add test of deprecations --- tests/testthat/test-deprecated.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/testthat/test-deprecated.R diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R new file mode 100644 index 00000000..bbe546cf --- /dev/null +++ b/tests/testthat/test-deprecated.R @@ -0,0 +1,31 @@ +test_that("can use deprecated pull_metadata with warning", { + withr::local_options(orderly.quiet = FALSE) + rlang::reset_warning_verbosity( + "orderly_deprecate:orderly_location_pull_metadata") + root <- create_temporary_root() + res <- evaluate_promise(orderly_location_pull_metadata(root = root)) + expect_match(res$warnings, + "'orderly_location_pull_metadata()' is deprecated", + fixed = TRUE) + expect_match(res$messages, "Fetching metadata from 0 locations") +}) + + +test_that("can use deprecated pull_packet with warning", { + rlang::reset_warning_verbosity( + "orderly_deprecate:orderly_location_pull_packet") + + root <- list() + for (name in c("src", "dst")) { + root[[name]] <- create_temporary_root(use_file_store = TRUE) + } + + id <- create_random_packet(root$src) + orderly_location_add_path("src", path = root$src$path, root = root$dst) + orderly_location_metadata_fetch(root = root$dst) + res <- evaluate_promise(orderly_location_pull_packet(id, root = root$dst)) + expect_equal(res$result, id) + expect_match(res$warnings, + "'orderly_location_pull_packet()' is deprecated", + fixed = TRUE) +}) From e9b1592c1fcda512b97e8318e5d8be7f69046067 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 23 Oct 2024 16:39:21 +0100 Subject: [PATCH 3/8] Fix lint --- R/location.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/location.R b/R/location.R index 9b6b4f38..5cf56877 100644 --- a/R/location.R +++ b/R/location.R @@ -638,7 +638,8 @@ orderly_location_custom <- function(driver, ...) { } -location_metadata_fetch <- function(location_name, root, call = parent.frame()) { +location_metadata_fetch <- function(location_name, root, + call = parent.frame()) { index <- root$index$data() driver <- location_driver(location_name, root) From b983f7be34f26333cca4b432b5a0e9f5427e392d Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 24 Oct 2024 09:37:44 +0100 Subject: [PATCH 4/8] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index afc179c2..055ce310 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orderly2 Title: Orderly Next Generation -Version: 1.99.52 +Version: 1.99.53 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Robert", "Ashton", role = "aut"), From 67ee5f8a003acc14c9530f838d33cf0a8e0519d1 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 24 Oct 2024 09:57:21 +0100 Subject: [PATCH 5/8] Update name --- R/compare.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/compare.R b/R/compare.R index 730349d0..22dd8e87 100644 --- a/R/compare.R +++ b/R/compare.R @@ -52,7 +52,7 @@ orderly_compare_packets <- function(target, current, pull_metadata = pull_metadata) if (options$pull_metadata) { - orderly_location_pull_metadata(options$location, root = root) + orderly_location_metadata_fetch(options$location, root = root) } target_metadata <- orderly_metadata(target, root = root) From 9ddcc1d9599e8272e41f98827cec2530367b06e5 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 24 Oct 2024 10:00:54 +0100 Subject: [PATCH 6/8] Rename again --- NAMESPACE | 2 +- R/compare.R | 2 +- R/deprecated.R | 2 +- R/location.R | 20 ++--- R/outpack_helpers.R | 2 +- R/query_index.R | 2 +- R/query_search.R | 2 +- _pkgdown.yml | 2 +- man/orderly2-deprecated.Rd | 2 +- man/orderly_compare_packets.Rd | 2 +- man/orderly_copy_files.Rd | 4 +- man/orderly_interactive_set_search_options.Rd | 2 +- man/orderly_location_add.Rd | 2 +- man/orderly_location_list.Rd | 2 +- man/orderly_location_metadata_fetch.Rd | 29 ------- man/orderly_location_pull.Rd | 2 +- man/orderly_metadata_extract.Rd | 2 +- man/orderly_run.Rd | 2 +- man/orderly_search.Rd | 2 +- man/orderly_search_options.Rd | 2 +- tests/testthat/test-deprecated.R | 2 +- tests/testthat/test-location-path.R | 4 +- tests/testthat/test-location.R | 82 +++++++++---------- tests/testthat/test-outpack-config.R | 4 +- tests/testthat/test-outpack-helpers.R | 4 +- tests/testthat/test-outpack-packet.R | 2 +- tests/testthat/test-outpack-root.R | 2 +- tests/testthat/test-query-index.R | 4 +- tests/testthat/test-query-search.R | 6 +- tests/testthat/test-run.R | 4 +- tests/testthat/test-zzz-location-http.R | 2 +- vignettes/collaboration.Rmd | 2 +- 32 files changed, 88 insertions(+), 117 deletions(-) delete mode 100644 man/orderly_location_metadata_fetch.Rd diff --git a/NAMESPACE b/NAMESPACE index 83f06cd5..38d6323a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,8 +26,8 @@ export(orderly_location_add) export(orderly_location_add_http) export(orderly_location_add_packit) export(orderly_location_add_path) +export(orderly_location_fetch_metadata) export(orderly_location_list) -export(orderly_location_metadata_fetch) export(orderly_location_pull) export(orderly_location_pull_metadata) export(orderly_location_pull_packet) diff --git a/R/compare.R b/R/compare.R index 22dd8e87..ffbcbea7 100644 --- a/R/compare.R +++ b/R/compare.R @@ -52,7 +52,7 @@ orderly_compare_packets <- function(target, current, pull_metadata = pull_metadata) if (options$pull_metadata) { - orderly_location_metadata_fetch(options$location, root = root) + orderly_location_fetch_metadata(options$location, root = root) } target_metadata <- orderly_metadata(target, root = root) diff --git a/R/deprecated.R b/R/deprecated.R index 83a45285..3316624f 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -3,7 +3,7 @@ ##' ##' * `orderly_location_pull_packet`; please use [orderly_location_pull()] ##' * `orderly_location_pull_metadata`; please use -##' [orderly_location_metadata_fetch()] +##' [orderly_location_fetch_metadata()] ##' ##' @param ... Arguments forwarded to the new version ##' @return See the linked pages above for the current return type. diff --git a/R/location.R b/R/location.R index 5cf56877..628ada1f 100644 --- a/R/location.R +++ b/R/location.R @@ -3,7 +3,7 @@ ##' based locations are supported, with limited support for custom ##' locations. Note that adding a location does *not* pull metadata ##' from it, you need to call -##' [orderly2::orderly_location_metadata_fetch] first. The function +##' [orderly2::orderly_location_fetch_metadata] first. The function ##' `orderly_location_add` can add any sort of location, but the other ##' functions documented here (`orderly_location_add_path`, etc) will ##' typically be much easier to use in practice. @@ -290,7 +290,7 @@ orderly_location_remove <- function(name, root = NULL) { ##' `args`. The `args` column is a list column, with each element ##' being the key-value pair arguments to the location. ##' -##' @seealso [orderly2::orderly_location_metadata_fetch], which can +##' @seealso [orderly2::orderly_location_fetch_metadata], which can ##' update your outpack index with metadata from any of the ##' locations listed here. ##' @@ -322,7 +322,7 @@ orderly_location_list <- function(verbose = FALSE, root = NULL) { ##' @return Nothing ##' ##' @export -orderly_location_metadata_fetch <- function(location = NULL, root = NULL) { +orderly_location_fetch_metadata <- function(location = NULL, root = NULL) { root <- root_open(root, require_orderly = FALSE) location_name <- location_resolve_valid(location, root, include_local = FALSE, @@ -333,7 +333,7 @@ orderly_location_metadata_fetch <- function(location = NULL, root = NULL) { "Fetching metadata from {length(location_name)} location{?s}:", "{squote({location_name})}")) for (name in location_name) { - res <- location_metadata_fetch(name, root) + res <- location_fetch_metadata(name, root) if (res$total > 0) { cli_alert_success(paste( "Found {res$total} packet{?s} at '{name}', of which", @@ -363,8 +363,8 @@ orderly_location_metadata_fetch <- function(location = NULL, root = NULL) { orderly_location_pull_metadata <- function(...) { deprecate_warn( "orderly_location_pull_metadata", - "orderly_location_metadata_fetch") - orderly_location_metadata_fetch(...) + "orderly_location_fetch_metadata") + orderly_location_fetch_metadata(...) } @@ -419,7 +419,7 @@ orderly_location_pull <- function(expr, hint <- c(i = paste("Did you forget to pull metadata? You can do this", "by using the argument {.code pull_metadata = TRUE}", "in the call to 'orderly_location_pull()', or", - "by running 'orderly_location_metadata_fetch()'")) + "by running 'orderly_location_fetch_metadata()'")) } else { hint <- NULL } @@ -549,7 +549,7 @@ orderly_location_push <- function(expr, location, name = NULL, dry_run = FALSE, driver <- location_driver(location_name, root) location_push_files(plan$files, driver, root) location_push_metadata(plan$packet_id, driver, root) - orderly_location_metadata_fetch(location_name, root) + orderly_location_fetch_metadata(location_name, root) } } @@ -638,7 +638,7 @@ orderly_location_custom <- function(driver, ...) { } -location_metadata_fetch <- function(location_name, root, +location_fetch_metadata <- function(location_name, root, call = parent.frame()) { index <- root$index$data() driver <- location_driver(location_name, root) @@ -851,7 +851,7 @@ location_build_pull_plan_location <- function(packets, location, root, call) { ## In the case where the above is used, we probably have ## up-to-date metadata so we don't display this. hint <- paste("Do you need to run", - "{.run orderly2::orderly_location_metadata_fetch()}?") + "{.run orderly2::orderly_location_fetch_metadata()}?") } cli::cli_abort(c("Failed to find packet{?s} {squote(missing)}", i = "Looked in location{?s} {squote(location_name)}", diff --git a/R/outpack_helpers.R b/R/outpack_helpers.R index 21c55c21..533500a3 100644 --- a/R/outpack_helpers.R +++ b/R/outpack_helpers.R @@ -22,7 +22,7 @@ ##' it's not unpacked but also not known to be present in some other ##' remote) then this will fail because it's impossible to resolve ##' the files. Consider refreshing the metadata with -##' [orderly2::orderly_location_metadata_fetch] to refresh this. +##' [orderly2::orderly_location_fetch_metadata] to refresh this. ##' * if the `id` is not unpacked *and* no local copy of the files ##' referred to can be found, we error by default (but see the next ##' option). However, sometimes the file you refer to might also be diff --git a/R/query_index.R b/R/query_index.R index 26e4ab74..ac287698 100644 --- a/R/query_index.R +++ b/R/query_index.R @@ -87,7 +87,7 @@ new_query_index <- function(root, options) { root <- root_open(root, require_orderly = FALSE) if (options$pull_metadata) { - orderly_location_metadata_fetch(options$location, root = root) + orderly_location_fetch_metadata(options$location, root = root) } idx <- root$index$data() metadata <- idx$metadata diff --git a/R/query_search.R b/R/query_search.R index 2ec9d8fa..31fbaf25 100644 --- a/R/query_search.R +++ b/R/query_search.R @@ -69,7 +69,7 @@ orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL, ##' @param pull_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_metadata_fetch] to filter locations +##' [orderly2::orderly_location_fetch_metadata] to filter locations ##' to update. If pulling many packets in sequence, you *will* want ##' to update this option to `FALSE` after the first pull, otherwise ##' it will update the metadata between every packet, which will be diff --git a/_pkgdown.yml b/_pkgdown.yml index 1d5d07a0..c56466b2 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -57,7 +57,7 @@ reference: - title: Interact with locations - subtitle: Use locations contents: - - orderly_location_metadata_fetch + - orderly_location_fetch_metadata - orderly_location_pull - orderly_location_push - subtitle: Manage locations diff --git a/man/orderly2-deprecated.Rd b/man/orderly2-deprecated.Rd index d9cc3cec..112a02bc 100644 --- a/man/orderly2-deprecated.Rd +++ b/man/orderly2-deprecated.Rd @@ -21,7 +21,7 @@ See the linked pages above for the current return type. \itemize{ \item \code{orderly_location_pull_packet}; please use \code{\link[=orderly_location_pull]{orderly_location_pull()}} \item \code{orderly_location_pull_metadata}; please use -\code{\link[=orderly_location_metadata_fetch]{orderly_location_metadata_fetch()}} +\code{\link[=orderly_location_fetch_metadata]{orderly_location_fetch_metadata()}} } } \keyword{internal} diff --git a/man/orderly_compare_packets.Rd b/man/orderly_compare_packets.Rd index 84e427c9..c1cb8abf 100644 --- a/man/orderly_compare_packets.Rd +++ b/man/orderly_compare_packets.Rd @@ -33,7 +33,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_pull_metadata} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_copy_files.Rd b/man/orderly_copy_files.Rd index 0a56f610..2f786406 100644 --- a/man/orderly_copy_files.Rd +++ b/man/orderly_copy_files.Rd @@ -75,7 +75,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be @@ -129,7 +129,7 @@ failure): it's not unpacked but also not known to be present in some other remote) then this will fail because it's impossible to resolve the files. Consider refreshing the metadata with -\link{orderly_location_metadata_fetch} to refresh this. +\link{orderly_location_fetch_metadata} to refresh this. \item if the \code{id} is not unpacked \emph{and} no local copy of the files referred to can be found, we error by default (but see the next option). However, sometimes the file you refer to might also be diff --git a/man/orderly_interactive_set_search_options.Rd b/man/orderly_interactive_set_search_options.Rd index 4ec31908..bc848049 100644 --- a/man/orderly_interactive_set_search_options.Rd +++ b/man/orderly_interactive_set_search_options.Rd @@ -26,7 +26,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_location_add.Rd b/man/orderly_location_add.Rd index dc3ebb8e..334bf6fe 100644 --- a/man/orderly_location_add.Rd +++ b/man/orderly_location_add.Rd @@ -77,7 +77,7 @@ and pulled into your local archive. Currently only file and http based locations are supported, with limited support for custom locations. Note that adding a location does \emph{not} pull metadata from it, you need to call -\link{orderly_location_metadata_fetch} first. The function +\link{orderly_location_fetch_metadata} first. The function \code{orderly_location_add} can add any sort of location, but the other functions documented here (\code{orderly_location_add_path}, etc) will typically be much easier to use in practice. diff --git a/man/orderly_location_list.Rd b/man/orderly_location_list.Rd index 0cf0e0c8..0efe1456 100644 --- a/man/orderly_location_list.Rd +++ b/man/orderly_location_list.Rd @@ -33,7 +33,7 @@ known at the current root), though you will typically be interested in \emph{other} locations. } \seealso{ -\link{orderly_location_metadata_fetch}, which can +\link{orderly_location_fetch_metadata}, which can update your outpack index with metadata from any of the locations listed here. } diff --git a/man/orderly_location_metadata_fetch.Rd b/man/orderly_location_metadata_fetch.Rd deleted file mode 100644 index 142f1390..00000000 --- a/man/orderly_location_metadata_fetch.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/location.R -\name{orderly_location_metadata_fetch} -\alias{orderly_location_metadata_fetch} -\title{Fetch metadata from a location} -\usage{ -orderly_location_metadata_fetch(location = NULL, root = NULL) -} -\arguments{ -\item{location}{The name of a location to pull from (see -\link{orderly_location_list} for possible values). If not -given, pulls from all locations. The "local" and "orphan" -locations are always up to date and pulling metadata from them -does nothing.} - -\item{root}{The path to the root directory, or \code{NULL} (the -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 \code{outpack} root (see -\link{orderly_init} for details).} -} -\value{ -Nothing -} -\description{ -Fetch metadata from a location, updating the index. This should -always be relatively quick as it updates only small files that -contain information about what can be found in remote packets. -} diff --git a/man/orderly_location_pull.Rd b/man/orderly_location_pull.Rd index d59c138c..7352a7ba 100644 --- a/man/orderly_location_pull.Rd +++ b/man/orderly_location_pull.Rd @@ -27,7 +27,7 @@ might in future expand this to allow wildcards or exceptions.} \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_metadata_extract.Rd b/man/orderly_metadata_extract.Rd index 38819ecf..696a075c 100644 --- a/man/orderly_metadata_extract.Rd +++ b/man/orderly_metadata_extract.Rd @@ -37,7 +37,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_run.Rd b/man/orderly_run.Rd index 445fcb2b..d0f79c3d 100644 --- a/man/orderly_run.Rd +++ b/man/orderly_run.Rd @@ -47,7 +47,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_search.Rd b/man/orderly_search.Rd index 5665187f..d43c9421 100644 --- a/man/orderly_search.Rd +++ b/man/orderly_search.Rd @@ -54,7 +54,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/man/orderly_search_options.Rd b/man/orderly_search_options.Rd index 34cf7bb3..1c5997a2 100644 --- a/man/orderly_search_options.Rd +++ b/man/orderly_search_options.Rd @@ -26,7 +26,7 @@ vector in the \code{location} argument, or if you have specified \item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to -\link{orderly_location_metadata_fetch} to filter locations +\link{orderly_location_fetch_metadata} to filter locations to update. If pulling many packets in sequence, you \emph{will} want to update this option to \code{FALSE} after the first pull, otherwise it will update the metadata between every packet, which will be diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index bbe546cf..317daf4d 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -22,7 +22,7 @@ test_that("can use deprecated pull_packet with warning", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) res <- evaluate_promise(orderly_location_pull_packet(id, root = root$dst)) expect_equal(res$result, id) expect_match(res$warnings, diff --git a/tests/testthat/test-location-path.R b/tests/testthat/test-location-path.R index 4fd37717..589f37b2 100644 --- a/tests/testthat/test-location-path.R +++ b/tests/testthat/test-location-path.R @@ -279,7 +279,7 @@ test_that("push overlapping tree", { orderly_location_add_path("server", path = server$path, root = client) id_base <- create_random_packet(server) - orderly_location_metadata_fetch(root = client) + orderly_location_fetch_metadata(root = client) suppressMessages(orderly_location_pull(id_base, root = client)) ids <- create_random_packet_chain(client, 3, id_base) @@ -367,7 +367,7 @@ test_that("allow relative paths in path locations", { b <- suppressMessages(orderly_init(file.path(tmp, "b"))) ids <- vcapply(1:3, function(i) create_random_packet(b)) withr::with_dir(a, orderly_location_add_path("b", path = "../b")) - orderly_location_metadata_fetch(root = a) + orderly_location_fetch_metadata(root = a) expect_equal(orderly_search(root = a, location = "b"), ids) }) diff --git a/tests/testthat/test-location.R b/tests/testthat/test-location.R index ceed5a4c..4a97991b 100644 --- a/tests/testthat/test-location.R +++ b/tests/testthat/test-location.R @@ -132,7 +132,7 @@ test_that("Can remove a location", { expect_setequal(orderly_location_list(root = root$a), c("local", "b", "c")) id <- create_random_packet(root$b) - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) # remove a location without packets expect_silent(orderly_location_remove("c", root = root$a)) @@ -164,9 +164,9 @@ test_that("Removing a location orphans packets only from that location", { id1 <- create_random_packet(root$c) id2 <- create_random_packet(root$b) - orderly_location_metadata_fetch(root = root$b) + orderly_location_fetch_metadata(root = root$b) suppressMessages(orderly_location_pull(id1, root = root$b)) - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) # id1 should now be found in both b and c index <- root$a$index$data() @@ -203,7 +203,7 @@ test_that("re-adding a location de-orphans packets", { id_b <- replicate(2, create_random_packet(root$b)) id_c <- replicate(3, create_random_packet(root$c)) - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) expect_message(orderly_location_remove("b", root = root$a), "Orphaning 2 packets") @@ -213,7 +213,7 @@ test_that("re-adding a location de-orphans packets", { expect_equal(nrow(root_open(root$a)$index$location(orphan)), 5) orderly_location_add_path("b", path = root$b, root = root$a) - expect_message(orderly_location_metadata_fetch(root = root$a), + expect_message(orderly_location_fetch_metadata(root = root$a), "De-orphaning 2 packets") expect_equal(nrow(root_open(root$a)$index$location(orphan)), 3) @@ -249,7 +249,7 @@ test_that("can pull metadata from a file base location", { expect_equal(orderly_location_list(root = root_downstream), c("local", "upstream")) - orderly_location_metadata_fetch("upstream", root = root_downstream) + orderly_location_fetch_metadata("upstream", root = root_downstream) ## Sensible tests here will be much easier to write once we have a ## decent query interface. @@ -270,7 +270,7 @@ test_that("can pull empty metadata", { orderly_location_add_path("upstream", path = root_upstream$path, root = root_downstream) - orderly_location_metadata_fetch("upstream", root = root_downstream) + orderly_location_fetch_metadata("upstream", root = root_downstream) index <- root_downstream$index$data() expect_length(index$metadata, 0) @@ -303,7 +303,7 @@ test_that("pull metadata from subset of locations", { location_name <- c("x", "y", "z") - orderly_location_metadata_fetch(c("x", "y"), root = root$a) + orderly_location_fetch_metadata(c("x", "y"), root = root$a) index <- root$a$index$data() expect_setequal(names(index$metadata), c(ids$x, ids$y)) expect_equal(index$location$location, rep(location_name[1:2], each = 3)) @@ -312,7 +312,7 @@ test_that("pull metadata from subset of locations", { expect_equal(index$metadata[ids$y], root$y$index$data()$metadata) - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) index <- root$a$index$data() expect_setequal(names(index$metadata), c(ids$x, ids$y, ids$z)) expect_equal(index$location$location, rep(location_name, each = 3)) @@ -324,15 +324,15 @@ test_that("pull metadata from subset of locations", { test_that("Can't pull metadata from an unknown location", { root <- create_temporary_root() expect_error( - orderly_location_metadata_fetch("upstream", root = root), + orderly_location_fetch_metadata("upstream", root = root), "Unknown location: 'upstream'") }) test_that("No-op to pull metadata from no locations", { root <- create_temporary_root() - expect_silent(orderly_location_metadata_fetch("local", root = root)) - expect_silent(orderly_location_metadata_fetch(root = root)) + expect_silent(orderly_location_fetch_metadata("local", root = root)) + expect_silent(orderly_location_fetch_metadata(root = root)) }) @@ -353,9 +353,9 @@ test_that("Can pull metadata through chain of locations", { ## Create a packet and make sure it's in both b and c id1 <- create_random_packet(root$a) - orderly_location_metadata_fetch(root = root$b) + orderly_location_fetch_metadata(root = root$b) suppressMessages(orderly_location_pull(id1, root = root$b)) - orderly_location_metadata_fetch(root = root$c) + orderly_location_fetch_metadata(root = root$c) suppressMessages(orderly_location_pull(id1, root = root$c)) ## And another in just 'c' @@ -363,7 +363,7 @@ test_that("Can pull metadata through chain of locations", { ## Then when we pull from d it will simultaneously learn about the ## packet from both locations: - orderly_location_metadata_fetch(root = root$d) + orderly_location_fetch_metadata(root = root$d) index <- root$d$index$data() ## Metadata is correct @@ -387,7 +387,7 @@ test_that("can pull a packet from one location to another, using file store", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) suppressMessages(orderly_location_pull(id, root = root$dst)) index <- root$dst$index$data() @@ -424,7 +424,7 @@ test_that("can pull a packet from one location to another, archive only", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) suppressMessages(orderly_location_pull(id, root = root$dst)) index <- root$dst$index$data() @@ -452,7 +452,7 @@ test_that("detect and avoid modified files in source repository", { } orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) ## Corrupt the file in the first id by truncating it: forcibly_truncate_file( @@ -482,7 +482,7 @@ test_that("Do not unpack a packet twice", { id <- create_random_packet(root$src) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) expect_equal( suppressMessages(orderly_location_pull(id, root = root$dst)), id) @@ -507,7 +507,7 @@ test_that("Sensible error if packet not known", { fixed = TRUE) expect_match(err$body[[1]], "Looked in location 'src'") expect_match(err$body[[2]], - "Do you need to run.+orderly_location_metadata_fetch") + "Do you need to run.+orderly_location_fetch_metadata") }) @@ -519,12 +519,12 @@ test_that("Sensible error if dependent packet not known", { id <- create_random_packet_chain(root$a, 5) orderly_location_add_path("a", path = root$a$path, root = root$b) - orderly_location_metadata_fetch(root = root$b) + orderly_location_fetch_metadata(root = root$b) suppressMessages(orderly_location_pull(id[[5]], root = root$b)) orderly_location_add_path("b", path = root$b$path, root = root$c) - orderly_location_metadata_fetch(root = root$c) + orderly_location_fetch_metadata(root = root$c) err <- expect_error( suppressMessages(orderly_location_pull(id[[5]], root = root$c)), @@ -550,7 +550,7 @@ test_that("Can pull a tree recursively", { id <- as.list(create_random_packet_chain(root$src, 3)) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) expect_equal(suppressMessages( orderly_location_pull(id$c, recursive = TRUE, root = root$dst)), c(id$a, id$b, id$c)) @@ -630,7 +630,7 @@ test_that("Can filter locations", { ids_a <- vcapply(1:3, function(i) create_random_packet(root$a$path)) orderly_location_add_path("a", path = root$a$path, root = root$b) - orderly_location_metadata_fetch(root = root$b) + orderly_location_fetch_metadata(root = root$b) suppressMessages(orderly_location_pull(ids_a, root = root$b)) ids_b <- c(ids_a, @@ -638,13 +638,13 @@ test_that("Can filter locations", { ids_c <- vcapply(1:3, function(i) create_random_packet(root$c$path)) orderly_location_add_path("a", path = root$a$path, root = root$d) orderly_location_add_path("c", path = root$c$path, root = root$d) - orderly_location_metadata_fetch(root = root$d) + orderly_location_fetch_metadata(root = root$d) suppressMessages(orderly_location_pull(ids_a, root = root$d)) suppressMessages(orderly_location_pull(ids_c, root = root$d)) ids_d <- c(ids_c, vcapply(1:3, function(i) create_random_packet(root$d$path))) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) ids <- unique(c(ids_a, ids_b, ids_c, ids_d)) expected <- function(ids, location_name) { @@ -690,7 +690,7 @@ test_that("Can filter locations", { "Failed to find packets") expect_match(err$body[[1]], "Looked in locations 'a', 'b', and 'c'") expect_match(err$body[[2]], - "Do you need to run.+orderly_location_metadata_fetch") + "Do you need to run.+orderly_location_fetch_metadata") }) @@ -706,7 +706,7 @@ test_that("can pull from multiple locations with multiple files", { ids_a <- create_random_packet(root$a$path, n_files = 1) ids_b <- create_random_packet(root$b$path, n_files = 2) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) suppressMessages( orderly_location_pull(NULL, name = "data", root = root$dst)) @@ -749,7 +749,7 @@ test_that("if recursive pulls are required, pulls are recursive by default", { for (r in root[c("shallow", "deep")]) { orderly_location_add_path("src", path = root$src$path, root = r) - orderly_location_metadata_fetch(root = r) + orderly_location_fetch_metadata(root = r) } suppressMessages( @@ -989,7 +989,7 @@ test_that("handle metadata where the hash does not match reported", { writeLines(json, path_metadata) err <- expect_error( - orderly_location_metadata_fetch(root = here), + orderly_location_fetch_metadata(root = here), "Hash of metadata for '.+' from 'server' does") expect_equal( unname(err$message), @@ -1013,9 +1013,9 @@ test_that("handle metadata where two locations differ in hash for same id", { orderly_location_add_path("a", path = root$a$path, root = root$us) orderly_location_add_path("b", path = root$b$path, root = root$us) - orderly_location_metadata_fetch(location = "a", root = root$us) + orderly_location_fetch_metadata(location = "a", root = root$us) err <- expect_error( - orderly_location_metadata_fetch(location = "b", root = root$us), + orderly_location_fetch_metadata(location = "b", root = root$us), "Location 'b' has conflicting metadata") expect_equal(names(err$body), c("x", "i", "i", "i")) expect_match(err$body[[1]], @@ -1037,10 +1037,10 @@ test_that("avoid duplicated metadata", { mock_driver <- list(list = function(x) rbind(driver$list(), driver$list())) mock_location_driver <- mockery::mock(mock_driver) - mockery::stub(location_metadata_fetch, "location_driver", + mockery::stub(location_fetch_metadata, "location_driver", mock_location_driver) err <- expect_error( - location_metadata_fetch("server", root = here), + location_fetch_metadata("server", root = here), "Duplicate metadata reported from location 'server'") expect_equal(names(err$body), c("x", "i", "i")) expect_equal(err$body[[1]], @@ -1059,7 +1059,7 @@ test_that("skip files in the file store", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) suppressMessages(orderly_location_pull(id[[1]], root = root$dst)) withr::with_options(list(orderly.quiet = FALSE), { @@ -1080,7 +1080,7 @@ test_that("skip files known elsewhere on disk", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) suppressMessages(orderly_location_pull(id[[1]], root = root$dst)) withr::with_options(list(orderly.quiet = FALSE), { @@ -1100,7 +1100,7 @@ test_that("can prune orphans from tree", { } orderly_location_add_path("there", path = root$there$path, root = root$here) id <- create_random_packet_chain(root$there, 5) - orderly_location_metadata_fetch(root = root$here) + orderly_location_fetch_metadata(root = root$here) expect_message( orderly_location_remove("there", root = root$here), "Orphaning 5 packets") @@ -1170,7 +1170,7 @@ test_that("be chatty when pulling packets", { expect_match(res$messages[[3]], "Added location 'server' (path)", fixed = TRUE) - res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) + res <- evaluate_promise(orderly_location_fetch_metadata(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[1]], "Fetching metadata from 1 location: 'server'") @@ -1180,20 +1180,20 @@ test_that("be chatty when pulling packets", { id1 <- create_random_packet(there) id2 <- create_random_packet(there) - res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) + res <- evaluate_promise(orderly_location_fetch_metadata(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[1]], "Fetching metadata from 1 location: 'server'") expect_match(res$messages[[2]], "Found 2 packets at 'server', of which 2 are new") - res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) + res <- evaluate_promise(orderly_location_fetch_metadata(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[2]], "Found 2 packets at 'server', of which 0 are new") id3 <- create_random_packet(there) - res <- evaluate_promise(orderly_location_metadata_fetch(root = here)) + res <- evaluate_promise(orderly_location_fetch_metadata(root = here)) expect_length(res$messages, 2) expect_match(res$messages[[2]], "Found 3 packets at 'server', of which 1 is new") diff --git a/tests/testthat/test-outpack-config.R b/tests/testthat/test-outpack-config.R index 3cbbfb5f..e9f7f74f 100644 --- a/tests/testthat/test-outpack-config.R +++ b/tests/testthat/test-outpack-config.R @@ -81,7 +81,7 @@ test_that("Can add file_store", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst$path) - orderly_location_metadata_fetch(root = root$dst$path) + orderly_location_fetch_metadata(root = root$dst$path) suppressMessages( orderly_location_pull(id[["c"]], root = root$dst$path)) @@ -294,7 +294,7 @@ test_that("Enabling recursive pulls forces pulling missing packets", { id <- create_random_packet_chain(root$src, 3) orderly_location_add_path("src", path = root$src$path, root = root$dst$path) - orderly_location_metadata_fetch(root = root$dst$path) + orderly_location_fetch_metadata(root = root$dst$path) suppressMessages( orderly_location_pull(id[["c"]], root = root$dst$path)) expect_equal(root$dst$index$unpacked(), id[["c"]]) diff --git a/tests/testthat/test-outpack-helpers.R b/tests/testthat/test-outpack-helpers.R index e553a2cf..079a1646 100644 --- a/tests/testthat/test-outpack-helpers.R +++ b/tests/testthat/test-outpack-helpers.R @@ -23,7 +23,7 @@ test_that("can copy files from location, using store", { orderly_copy_files(id, files = c("data.rds" = "data.rds"), dest = tmp, root = here), "Packet '.+' not found in outpack index") - orderly_location_metadata_fetch(root = here) + orderly_location_fetch_metadata(root = here) expect_error( orderly_copy_files(id, files = c("data.rds" = "data.rds"), dest = tmp, @@ -49,7 +49,7 @@ test_that("can copy files from location, using archive", { id <- create_random_packet(there) tmp <- withr::local_tempdir() - orderly_location_metadata_fetch(root = here) + orderly_location_fetch_metadata(root = here) expect_error( orderly_copy_files(id, files = c("data.rds" = "data.rds"), dest = tmp, root = here), diff --git a/tests/testthat/test-outpack-packet.R b/tests/testthat/test-outpack-packet.R index 1629f6f4..23bd338f 100644 --- a/tests/testthat/test-outpack-packet.R +++ b/tests/testthat/test-outpack-packet.R @@ -679,7 +679,7 @@ test_that("can pull in dependency from specific location", { }) orderly_location_add_path(name, path = root[[name]]$path, root = root$a) } - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) for (id in ids$z) { suppressMessages(orderly_location_pull(id, root = root$a)) } diff --git a/tests/testthat/test-outpack-root.R b/tests/testthat/test-outpack-root.R index bf7c364e..4d60f4ac 100644 --- a/tests/testthat/test-outpack-root.R +++ b/tests/testthat/test-outpack-root.R @@ -99,7 +99,7 @@ test_that("Can work out what packets are missing", { } ids <- unname(create_random_packet_chain(root$a, 3)) orderly_location_add_path("a", path = root$a$path, root = root$b) - orderly_location_metadata_fetch(root = root$b) + orderly_location_fetch_metadata(root = root$b) ## Nothing missing in this case: expect_equal(root_list_unknown_packets(ids, root$a), diff --git a/tests/testthat/test-query-index.R b/tests/testthat/test-query-index.R index 60c6ca43..697a1ca6 100644 --- a/tests/testthat/test-query-index.R +++ b/tests/testthat/test-query-index.R @@ -7,7 +7,7 @@ test_that("index can include only unpacked packets", { x1 <- create_random_packet(root$src, "x") x2 <- create_random_packet(root$src, "x") - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) opts_all <- build_search_options(allow_remote = TRUE) opts_unpacked <- build_search_options(allow_remote = FALSE) @@ -85,7 +85,7 @@ test_that("can apply a location filter to index", { create_random_packet(root[[name]], "data", list(p = i)) }) } - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) idx_with_location <- function(location) { options <- build_search_options(location = location, allow_remote = TRUE) diff --git a/tests/testthat/test-query-search.R b/tests/testthat/test-query-search.R index 5dc1fecf..f112dc86 100644 --- a/tests/testthat/test-query-search.R +++ b/tests/testthat/test-query-search.R @@ -213,7 +213,7 @@ test_that("Can filter query to packets that are locally available (unpacked)", { create_random_packet(root[[name]], "data", list(p = i)) }) } - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) expect_equal( orderly_search(quote(name == "data"), location = c("x", "y"), @@ -250,7 +250,7 @@ test_that("scope and allow_local can be used together to filter query", { x2 <- create_random_packet(root$src, "x", list(p = 1)) y1 <- create_random_packet(root$src, "y", list(p = 1)) y2 <- create_random_packet(root$src, "y", list(p = 1)) - orderly_location_metadata_fetch(root = root$dst) + orderly_location_fetch_metadata(root = root$dst) options_local <- build_search_options(allow_remote = FALSE) options_remote <- build_search_options(allow_remote = TRUE) @@ -1025,7 +1025,7 @@ test_that("Warn, but honour, on use of search options to search", { ids <- vcapply(1:3, function(i) { create_random_packet(root$b, "data", list(p = i)) }) - orderly_location_metadata_fetch(root = root$a) + orderly_location_fetch_metadata(root = root$a) expect_equal(orderly_search(NULL, root = root$a), character()) diff --git a/tests/testthat/test-run.R b/tests/testthat/test-run.R index e13b4bc7..1a55dd06 100644 --- a/tests/testthat/test-run.R +++ b/tests/testthat/test-run.R @@ -764,7 +764,7 @@ test_that("Can select location when querying dependencies for a report", { envir = new.env()) orderly_location_add_path(nm, path = path[[nm]], root = path[["us"]]) - orderly_location_metadata_fetch(nm, root = path[["us"]]) + orderly_location_fetch_metadata(nm, root = path[["us"]]) for (i in ids[[nm]]) { suppressMessages(orderly_location_pull(i, root = path[["us"]])) } @@ -810,7 +810,7 @@ test_that("can select location when querying dependencies interactively", { ids[[nm]] <- orderly_run_quietly("data", envir = envir1, root = path[[nm]]) orderly_location_add_path(nm, path = path[[nm]], root = path[["us"]]) - orderly_location_metadata_fetch(nm, root = path[["us"]]) + orderly_location_fetch_metadata(nm, root = path[["us"]]) for (i in ids[[nm]]) { suppressMessages(orderly_location_pull(i, root = path[["us"]])) } diff --git a/tests/testthat/test-zzz-location-http.R b/tests/testthat/test-zzz-location-http.R index e8a2870d..eff38d89 100644 --- a/tests/testthat/test-zzz-location-http.R +++ b/tests/testthat/test-zzz-location-http.R @@ -86,7 +86,7 @@ describe("http location integration tests", { orderly_location_add_http("upstream", url = url, root = root_downstream) expect_equal(orderly_location_list(root = root_downstream), c("local", "upstream")) - orderly_location_metadata_fetch("upstream", root = root_downstream) + orderly_location_fetch_metadata("upstream", root = root_downstream) idx <- root_downstream$index$data() expect_equal(names(idx$metadata), ids) diff --git a/vignettes/collaboration.Rmd b/vignettes/collaboration.Rmd index 1d4faeec..1f614145 100644 --- a/vignettes/collaboration.Rmd +++ b/vignettes/collaboration.Rmd @@ -282,5 +282,5 @@ orderly2::orderly_location_add_path("alices_orderly", path_sharepoint_bob) 1. Pull the metadata and use the packets as desired ```{r, as="bob", orderly_root = path_bob} -orderly2::orderly_location_metadata_fetch("alices_orderly") +orderly2::orderly_location_fetch_metadata("alices_orderly") ``` From edb6e2e6116870b0e8c4f0568ef10ea2c0d2c0d5 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 24 Oct 2024 10:07:44 +0100 Subject: [PATCH 7/8] Rename arguments --- R/compare.R | 12 ++++---- R/interactive.R | 4 +-- R/location.R | 8 ++--- R/metadata.R | 2 +- R/outpack_helpers.R | 6 ++-- R/outpack_packet.R | 4 +-- R/outpack_tools.R | 5 ++-- R/query_explain.R | 4 +-- R/query_index.R | 2 +- R/query_search.R | 26 +++++++++-------- R/run.R | 12 ++++---- R/validate.R | 2 +- man/orderly_compare_packets.Rd | 6 ++-- man/orderly_copy_files.Rd | 8 ++--- man/orderly_interactive_set_search_options.Rd | 6 ++-- man/orderly_location_fetch_metadata.Rd | 29 +++++++++++++++++++ man/orderly_location_pull.Rd | 6 ++-- man/orderly_metadata_extract.Rd | 8 ++--- man/orderly_query_explain.Rd | 2 +- man/orderly_run.Rd | 14 ++++----- man/orderly_search.Rd | 8 ++--- man/orderly_search_options.Rd | 6 ++-- tests/testthat/test-compare.R | 2 +- tests/testthat/test-location.R | 2 +- tests/testthat/test-outpack-packet.R | 2 +- tests/testthat/test-outpack-tools.R | 2 +- tests/testthat/test-query-search.R | 14 ++++----- vignettes/collaboration.Rmd | 2 +- vignettes/dependencies.Rmd | 2 +- 29 files changed, 119 insertions(+), 87 deletions(-) create mode 100644 man/orderly_location_fetch_metadata.Rd diff --git a/R/compare.R b/R/compare.R index ffbcbea7..4ae3e588 100644 --- a/R/compare.R +++ b/R/compare.R @@ -41,7 +41,7 @@ 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()) @@ -49,9 +49,9 @@ orderly_compare_packets <- function(target, current, 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) } @@ -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. @@ -124,7 +124,7 @@ 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, @@ -132,7 +132,7 @@ 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) diff --git a/R/interactive.R b/R/interactive.R index 00ba070d..846272fa 100644 --- a/R/interactive.R +++ b/R/interactive.R @@ -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 } diff --git a/R/location.R b/R/location.R index 628ada1f..2bc55e2f 100644 --- a/R/location.R +++ b/R/location.R @@ -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) { @@ -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 { diff --git a/R/metadata.R b/R/metadata.R index 8b06c757..2fcc425f 100644 --- a/R/metadata.R +++ b/R/metadata.R @@ -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) } diff --git a/R/outpack_helpers.R b/R/outpack_helpers.R index 533500a3..32d97ae4 100644 --- a/R/outpack_helpers.R +++ b/R/outpack_helpers.R @@ -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) { @@ -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. @@ -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( diff --git a/R/outpack_packet.R b/R/outpack_packet.R index 6a3026f9..2669c089 100644 --- a/R/outpack_packet.R +++ b/R/outpack_packet.R @@ -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( @@ -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) diff --git a/R/outpack_tools.R b/R/outpack_tools.R index f6424fdc..c15036e4 100644 --- a/R/outpack_tools.R +++ b/R/outpack_tools.R @@ -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) @@ -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()) diff --git a/R/query_explain.R b/R/query_explain.R index 8c20d02b..476a079f 100644 --- a/R/query_explain.R +++ b/R/query_explain.R @@ -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, @@ -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, diff --git a/R/query_index.R b/R/query_index.R index ac287698..5fb6abbb 100644 --- a/R/query_index.R +++ b/R/query_index.R @@ -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() diff --git a/R/query_search.R b/R/query_search.R index 31fbaf25..e28dcc13 100644 --- a/R/query_search.R +++ b/R/query_search.R @@ -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(...)` @@ -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()) @@ -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 @@ -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, @@ -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) @@ -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", @@ -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 } diff --git a/R/run.R b/R/run.R index 1eebb233..15b20662 100644 --- a/R/run.R +++ b/R/run.R @@ -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 @@ -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. ##' @@ -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 @@ -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 @@ -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), @@ -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) diff --git a/R/validate.R b/R/validate.R index 3f1aa861..e67f0cb0 100644 --- a/R/validate.R +++ b/R/validate.R @@ -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) } diff --git a/man/orderly_compare_packets.Rd b/man/orderly_compare_packets.Rd index c1cb8abf..7e407528 100644 --- a/man/orderly_compare_packets.Rd +++ b/man/orderly_compare_packets.Rd @@ -9,7 +9,7 @@ orderly_compare_packets( current, location = NULL, allow_remote = NULL, - pull_metadata = FALSE, + fetch_metadata = FALSE, root = NULL ) } @@ -28,9 +28,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations diff --git a/man/orderly_copy_files.Rd b/man/orderly_copy_files.Rd index 2f786406..e2c0f73c 100644 --- a/man/orderly_copy_files.Rd +++ b/man/orderly_copy_files.Rd @@ -12,7 +12,7 @@ orderly_copy_files( name = NULL, location = NULL, allow_remote = NULL, - pull_metadata = FALSE, + fetch_metadata = FALSE, parameters = NULL, options = NULL, envir = parent.frame(), @@ -70,9 +70,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations @@ -86,7 +86,7 @@ into the query (using the \verb{this:} prefix)} \item{options}{\strong{DEPRECATED}. Please don't use this any more, and instead use the arguments \code{location}, \code{allow_remote} and -\code{pull_metadata} directly.} +\code{fetch_metadata} directly.} \item{envir}{Optionally, an environment to substitute into the query (using the \verb{environment:} prefix). The default here is to diff --git a/man/orderly_interactive_set_search_options.Rd b/man/orderly_interactive_set_search_options.Rd index bc848049..13996fbb 100644 --- a/man/orderly_interactive_set_search_options.Rd +++ b/man/orderly_interactive_set_search_options.Rd @@ -7,7 +7,7 @@ orderly_interactive_set_search_options( location = NULL, allow_remote = NULL, - pull_metadata = FALSE + fetch_metadata = FALSE ) } \arguments{ @@ -21,9 +21,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations diff --git a/man/orderly_location_fetch_metadata.Rd b/man/orderly_location_fetch_metadata.Rd new file mode 100644 index 00000000..fddf77f0 --- /dev/null +++ b/man/orderly_location_fetch_metadata.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/location.R +\name{orderly_location_fetch_metadata} +\alias{orderly_location_fetch_metadata} +\title{Fetch metadata from a location} +\usage{ +orderly_location_fetch_metadata(location = NULL, root = NULL) +} +\arguments{ +\item{location}{The name of a location to pull from (see +\link{orderly_location_list} for possible values). If not +given, pulls from all locations. The "local" and "orphan" +locations are always up to date and pulling metadata from them +does nothing.} + +\item{root}{The path to the root directory, or \code{NULL} (the +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 \code{outpack} root (see +\link{orderly_init} for details).} +} +\value{ +Nothing +} +\description{ +Fetch metadata from a location, updating the index. This should +always be relatively quick as it updates only small files that +contain information about what can be found in remote packets. +} diff --git a/man/orderly_location_pull.Rd b/man/orderly_location_pull.Rd index 7352a7ba..5c43fb92 100644 --- a/man/orderly_location_pull.Rd +++ b/man/orderly_location_pull.Rd @@ -8,7 +8,7 @@ orderly_location_pull( expr, name = NULL, location = NULL, - pull_metadata = FALSE, + fetch_metadata = FALSE, recursive = NULL, options = NULL, root = NULL @@ -24,7 +24,7 @@ will be intersected with \code{scope} arg and is a shorthand way of running \item{location}{Optional vector of locations to pull from. We might in future expand this to allow wildcards or exceptions.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations @@ -41,7 +41,7 @@ we default to the value given by the the configuration option \item{options}{\strong{DEPRECATED}. Please don't use this any more, and instead use the arguments \code{location}, \code{allow_remote} and -\code{pull_metadata} directly.} +\code{fetch_metadata} directly.} \item{root}{The path to the root directory, or \code{NULL} (the default) to search for one from the current working diff --git a/man/orderly_metadata_extract.Rd b/man/orderly_metadata_extract.Rd index 696a075c..a0fd1ff4 100644 --- a/man/orderly_metadata_extract.Rd +++ b/man/orderly_metadata_extract.Rd @@ -9,7 +9,7 @@ orderly_metadata_extract( name = NULL, location = NULL, allow_remote = NULL, - pull_metadata = FALSE, + fetch_metadata = FALSE, extract = NULL, options = NULL, root = NULL @@ -32,9 +32,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations @@ -48,7 +48,7 @@ named. See Details for the format.} \item{options}{\strong{DEPRECATED}. Please don't use this any more, and instead use the arguments \code{location}, \code{allow_remote} and -\code{pull_metadata} directly.} +\code{fetch_metadata} directly.} \item{root}{The path to the root directory, or \code{NULL} (the default) to search for one from the current working diff --git a/man/orderly_query_explain.Rd b/man/orderly_query_explain.Rd index a1fb9a7b..0814a7da 100644 --- a/man/orderly_query_explain.Rd +++ b/man/orderly_query_explain.Rd @@ -47,7 +47,7 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} \item{root}{The path to the root directory, or \code{NULL} (the default) to search for one from the current working diff --git a/man/orderly_run.Rd b/man/orderly_run.Rd index d0f79c3d..d49a2bfe 100644 --- a/man/orderly_run.Rd +++ b/man/orderly_run.Rd @@ -11,7 +11,7 @@ orderly_run( echo = TRUE, location = NULL, allow_remote = NULL, - pull_metadata = FALSE, + fetch_metadata = FALSE, search_options = NULL, root = NULL ) @@ -42,9 +42,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations @@ -55,7 +55,7 @@ needlessly slow.} \item{search_options}{\strong{DEPRECATED}. Please don't use this any more, and instead use the arguments \code{location}, \code{allow_remote} -and \code{pull_metadata} directly.} +and \code{fetch_metadata} directly.} \item{root}{The path to the root directory, or \code{NULL} (the default) to search for one from the current working @@ -107,7 +107,7 @@ can specify the search options (root specific) with \section{Which packets might be selected from locations?}{ -The arguments \code{location}, \code{allow_remote} and \code{pull_metadata} +The arguments \code{location}, \code{allow_remote} and \code{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 @@ -119,7 +119,7 @@ not locally present this might not be needed - if you have the same content anywhere else in an unpacked packet we will reuse the same content without re-fetching. -If \code{pull_metadata = TRUE}, then we will refresh location metadata +If \code{fetch_metadata = TRUE}, then we will refresh location metadata before pulling, and the \code{location} argument controls which locations are pulled from. } @@ -141,7 +141,7 @@ all locations \emph{except} local default behaviour). In addition, you could resolve dependencies as they currently exist on production right now with the options: -\if{html}{\out{
}}\preformatted{location = "production", pull_metadata = TRUE +\if{html}{\out{
}}\preformatted{location = "production", fetch_metadata = TRUE }\if{html}{\out{
}} which updates your current metadata from production, then runs diff --git a/man/orderly_search.Rd b/man/orderly_search.Rd index d43c9421..00653b94 100644 --- a/man/orderly_search.Rd +++ b/man/orderly_search.Rd @@ -13,7 +13,7 @@ orderly_search( envir = parent.frame(), location = NULL, allow_remote = NULL, - pull_metadata = FALSE, + fetch_metadata = FALSE, options = NULL, root = NULL ) @@ -49,9 +49,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations @@ -62,7 +62,7 @@ needlessly slow.} \item{options}{\strong{DEPRECATED}. Please don't use this any more, and instead use the arguments \code{location}, \code{allow_remote} and -\code{pull_metadata} directly.} +\code{fetch_metadata} directly.} \item{root}{The path to the root directory, or \code{NULL} (the default) to search for one from the current working diff --git a/man/orderly_search_options.Rd b/man/orderly_search_options.Rd index 1c5997a2..a0bea1b0 100644 --- a/man/orderly_search_options.Rd +++ b/man/orderly_search_options.Rd @@ -21,9 +21,9 @@ only to a location that we have metadata from). If this is you might pull a large quantity of data. The default is \code{NULL}. This is \code{TRUE} if remote locations are listed explicitly as a character vector in the \code{location} argument, or if you have specified -\code{pull_metadata = TRUE}, otherwise \code{FALSE}.} +\code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{pull_metadata}{Logical, indicating if we should pull +\item{fetch_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations @@ -34,7 +34,7 @@ needlessly slow.} } \value{ An object of class \code{orderly_search_options} which should -not be modified after creation (but see note about \code{pull_metadata}) +not be modified after creation (but see note about \code{fetch_metadata}) } \description{ Options for controlling how packet searches are carried out, for diff --git a/tests/testthat/test-compare.R b/tests/testthat/test-compare.R index 09a3ad1c..b6deea64 100644 --- a/tests/testthat/test-compare.R +++ b/tests/testthat/test-compare.R @@ -118,7 +118,7 @@ test_that("Can compare packets from remote", { "Packet .* not found in outpack index") result <- orderly_compare_packets(id1, id2, root = here, - pull_metadata = TRUE) + fetch_metadata = TRUE) expect_snapshot(orderly_comparison_explain(result, "files"), transform = scrub_packets(id1, id2)) diff --git a/tests/testthat/test-location.R b/tests/testthat/test-location.R index 4a97991b..49c90f65 100644 --- a/tests/testthat/test-location.R +++ b/tests/testthat/test-location.R @@ -972,7 +972,7 @@ test_that("can pull packets as a result of a query", { orderly_location_pull( "parameter:i < 3", name = "data", - pull_metadata = TRUE, + fetch_metadata = TRUE, root = root$dst$path)) expect_setequal(ids_moved, ids[1:2]) }) diff --git a/tests/testthat/test-outpack-packet.R b/tests/testthat/test-outpack-packet.R index 23bd338f..57d7b25e 100644 --- a/tests/testthat/test-outpack-packet.R +++ b/tests/testthat/test-outpack-packet.R @@ -740,7 +740,7 @@ test_that("can pull in dependency when not found, if requested", { expect_equal(nrow(root$a$index$data()$location), 0) expect_equal(length(root$a$index$data()$unpacked), 0) - options <- build_search_options(pull_metadata = TRUE, allow_remote = TRUE) + options <- build_search_options(fetch_metadata = TRUE, allow_remote = TRUE) suppressMessages( outpack_packet_use_dependency(p_a, query, c("data.rds" = "data.rds"), search_options = options)) diff --git a/tests/testthat/test-outpack-tools.R b/tests/testthat/test-outpack-tools.R index 588201e9..5470bb54 100644 --- a/tests/testthat/test-outpack-tools.R +++ b/tests/testthat/test-outpack-tools.R @@ -372,7 +372,7 @@ test_that("can differentiate remote metadata", { expect_equal(nrow(d3), 0) d4 <- orderly_metadata_extract(root = root, allow_remote = TRUE, - pull_metadata = TRUE) + fetch_metadata = TRUE) expect_equal(names(d4), c("id", "local", "location", "name", "parameters")) expect_equal(nrow(d4), 8) expect_equal(d4$local, rep(c(TRUE, FALSE), c(5, 3))) diff --git a/tests/testthat/test-query-search.R b/tests/testthat/test-query-search.R index f112dc86..553a7676 100644 --- a/tests/testthat/test-query-search.R +++ b/tests/testthat/test-query-search.R @@ -5,24 +5,24 @@ test_that("can construct search options", { unclass(defaults), list(location = NULL, allow_remote = FALSE, - pull_metadata = FALSE)) + fetch_metadata = FALSE)) opts <- build_search_options(location = c("x", "y"), - pull_metadata = TRUE) + fetch_metadata = TRUE) expect_s3_class(opts, "orderly_search_options") expect_mapequal( unclass(opts), list(location = c("x", "y"), allow_remote = TRUE, - pull_metadata = TRUE)) + fetch_metadata = TRUE)) }) -test_that("pull_metadata implies allow_remote", { - opts <- build_search_options(pull_metadata = TRUE) +test_that("fetch_metadata implies allow_remote", { + opts <- build_search_options(fetch_metadata = TRUE) expect_equal(opts, build_search_options(location = NULL, allow_remote = TRUE, - pull_metadata = TRUE)) + fetch_metadata = TRUE)) }) @@ -866,7 +866,7 @@ test_that("allow search before query", { character(0)) expect_equal( orderly_search(quote(name == "data"), root = root$a, - pull_metadata = TRUE, allow_remote = TRUE), + fetch_metadata = TRUE, allow_remote = TRUE), ids) expect_setequal(names(root$a$index$data()$metadata), ids) }) diff --git a/vignettes/collaboration.Rmd b/vignettes/collaboration.Rmd index 1f614145..2e9c49c8 100644 --- a/vignettes/collaboration.Rmd +++ b/vignettes/collaboration.Rmd @@ -176,7 +176,7 @@ Bob can now query for packets available on the server: ```{r, as = "bob", orderly_root = path_bob} orderly2::orderly_metadata_extract( name = "data", - allow_remote = TRUE, pull_metadata = TRUE) + allow_remote = TRUE, fetch_metadata = TRUE) ``` Having seen there is a new "data" packet here, he can pull this down locally (TODO: mrc-4414 makes this nicer): diff --git a/vignettes/dependencies.Rmd b/vignettes/dependencies.Rmd index 451e567a..bfea5270 100644 --- a/vignettes/dependencies.Rmd +++ b/vignettes/dependencies.Rmd @@ -264,7 +264,7 @@ There are three components here that affect how packets are selected * `location`: is a character vector of locations, matching your location names. Only packets that can be found at these locations will be considered. So if you have a mix of locally created packets as well as ones that other people can see, specifying `location = "server"` would limit to packets that are available on the server, which means that you will end up with dependencies that you colleagues would also get. * `allow_remote`: controls if we are willing to download files from a location in order to satisfy a dependency. If `TRUE`, then when you run the report, it might download files if more recent packets are available on a location than what you have locally. -* `pull_metadata`: only has an effect if `allow_remote` is also `TRUE`; this causes the metadata to be refreshed before dependency resolution. +* `fetch_metadata`: only has an effect if `allow_remote` is also `TRUE`; this causes the metadata to be refreshed before dependency resolution. There is further discussion of the details in `?orderly_run` From b6095054b94ce670726953a73e9df6fc755b635b Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 24 Oct 2024 10:19:49 +0100 Subject: [PATCH 8/8] Fix docs --- R/compare.R | 2 +- R/interactive.R | 2 +- R/query_search.R | 11 ++++++++++- man/orderly_search_options.Rd | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/R/compare.R b/R/compare.R index 4ae3e588..206b5020 100644 --- a/R/compare.R +++ b/R/compare.R @@ -31,7 +31,7 @@ compare_filesets <- function(target, current) { ##' ##' @param target The id of the packet to use in the comparison. ##' @param current The id of the other packet against which to compare. -##' @inheritParams orderly_search_options +##' @inheritParams orderly_search ##' @inheritParams orderly_metadata ##' @return An object of class orderly_comparison. The object can be printed to ##' get a summary description of the differences, or passed to diff --git a/R/interactive.R b/R/interactive.R index 846272fa..6451f581 100644 --- a/R/interactive.R +++ b/R/interactive.R @@ -75,7 +75,7 @@ detect_orderly_interactive_path <- function( ##' ##' @title Set search options for interactive use ##' -##' @inheritParams orderly_search_options +##' @inheritParams orderly_search ##' ##' @return Nothing, called for its side effects ##' @export diff --git a/R/query_search.R b/R/query_search.R index e28dcc13..441b2a68 100644 --- a/R/query_search.R +++ b/R/query_search.R @@ -19,6 +19,15 @@ ##' @inheritParams orderly_query ##' @inheritParams orderly_search_options ##' +##' @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 +##' to update. If pulling many packets in sequence, you *will* want +##' to update this option to `FALSE` after the first pull, otherwise +##' it will update the metadata between every packet, which will be +##' needlessly slow. +##' ##' @param options **DEPRECATED**. Please don't use this any more, and ##' instead use the arguments `location`, `allow_remote` and ##' `fetch_metadata` directly. @@ -66,7 +75,7 @@ orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL, ##' vector in the `location` argument, or if you have specified ##' `fetch_metadata = TRUE`, otherwise `FALSE`. ##' -##' @param fetch_metadata Logical, indicating if we should pull +##' @param pull_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 diff --git a/man/orderly_search_options.Rd b/man/orderly_search_options.Rd index a0bea1b0..35ea8682 100644 --- a/man/orderly_search_options.Rd +++ b/man/orderly_search_options.Rd @@ -23,7 +23,7 @@ you might pull a large quantity of data. The default is \code{NULL}. This is vector in the \code{location} argument, or if you have specified \code{fetch_metadata = TRUE}, otherwise \code{FALSE}.} -\item{fetch_metadata}{Logical, indicating if we should pull +\item{pull_metadata}{Logical, indicating if we should pull metadata immediately before the search. If \code{location} is given, then we will pass this through to \link{orderly_location_fetch_metadata} to filter locations