Skip to content

Commit

Permalink
Merge pull request #151 from mrc-ide/gh-144
Browse files Browse the repository at this point in the history
Error informatively if no packets found
  • Loading branch information
richfitz authored Jul 5, 2024
2 parents 07c1d31 + ea0da5b commit 1fd09ff
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: orderly2
Title: Orderly Next Generation
Version: 1.99.18
Version: 1.99.19
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"),
email = "[email protected]"),
person("Robert", "Ashton", role = "aut"),
Expand Down
17 changes: 17 additions & 0 deletions R/location.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,23 @@ orderly_location_pull_packet <- function(..., options = NULL, recursive = NULL,
ids <- orderly_search(..., options = options, root = root)
}

if (length(ids) == 0) {
if (options$allow_remote && !options$pull_metadata) {
pull_arg <- gsub(" ", "\u00a0", "options = list(pull_metadata = TRUE)")
hint <- c(i = paste("Did you forget to pull metadata? You can do this",
"by using the argument '{pull_arg}' in the call",
"to 'orderly_location_pull_packet()', or",
"by running 'orderly_location_pull_metadata()'"))
} else {
hint <- NULL
}
cli::cli_abort(
c("No packets found in query, so cannot pull anything",
i = paste("Your query returned no packets, which is probably a mistake",
"so I'm erroring here."),
hint))
}

plan <- location_build_pull_plan(ids, options$locations, recursive, root,
call = environment())

Expand Down
4 changes: 3 additions & 1 deletion R/outpack_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ config_set_require_complete_tree <- function(value, root, call) {

if (value) {
id <- root$index$unpacked()
orderly_location_pull_packet(id, recursive = TRUE, root = root)
if (length(id) > 0) {
orderly_location_pull_packet(id, recursive = TRUE, root = root)
}
}

config$core$require_complete_tree <- value
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-location.R
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,21 @@ test_that("can pull a packet from one location to another, using file store", {
})


test_that("can error where a query returns no packets", {
root <- list()
for (name in c("src", "dst")) {
root[[name]] <- create_temporary_root()
}

id <- create_random_packet(root$src)
orderly_location_add("src", "path", list(path = root$src$path),
root = root$dst)
err <- expect_error(
orderly_location_pull_packet(name = "data", root = root$dst),
"No packets found in query, so cannot pull anything")
})


test_that("can pull a packet from one location to another, archive only", {
root <- list()
for (name in c("src", "dst")) {
Expand Down

0 comments on commit 1fd09ff

Please sign in to comment.