Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error informatively if no packets found #151

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading