Skip to content

Commit

Permalink
More ways that allow_remote should be controlled
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Oct 18, 2024
1 parent ad67d7f commit 0084415
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 6 additions & 3 deletions R/query_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ orderly_search <- function(expr, name = NULL, scope = NULL, subquery = NULL,
##' only to a location that we have metadata from). If this is
##' `TRUE`, then in conjunction with [orderly2::orderly_dependency]
##' you might pull a large quantity of data. The default `NULL` is
##' `TRUE` if locations are listed explicitly as a character vector
##' in the `location` argument, or if you have specified
##' `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`.
##'
##' @param pull_metadata Logical, indicating if we should pull
Expand All @@ -82,9 +82,12 @@ orderly_search_options <- function(location = NULL,
if (!is.null(location)) {
assert_character(location)
}
has_remote_location <- !is.null(location) &&
length(setdiff(location, c("local", "orphan")) > 0)

assert_scalar_logical(pull_metadata)
if (is.null(allow_remote)) {
allow_remote <- !is.null(location) || pull_metadata
allow_remote <- has_remote_location || pull_metadata
} else {
assert_scalar_logical(allow_remote)
}
Expand Down
4 changes: 2 additions & 2 deletions man/orderly_search_options.Rd

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

12 changes: 12 additions & 0 deletions tests/testthat/test-query-search.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ test_that("pull_metadata implies allow_remote", {
})


test_that("nontrivial location implies allow_remote", {
expect_false(orderly_search_options(location = NULL)$allow_remote)
expect_false(orderly_search_options(location = "local")$allow_remote)
expect_false(
orderly_search_options(location = c("local", "orphan"))$allow_remote)
expect_true(
orderly_search_options(location = "server")$allow_remote)
expect_true(
orderly_search_options(location = c("local", "server"))$allow_remote)
})


test_that("can convert into search options", {
opts <- orderly_search_options(location = "x",
allow_remote = FALSE,
Expand Down

0 comments on commit 0084415

Please sign in to comment.