Skip to content

Commit

Permalink
Explicit arguments to orderly_metadata_extract
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Oct 18, 2024
1 parent 11f7756 commit a1c980e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion R/location.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ orderly_location_pull_packet <- function(expr,
allow_remote = TRUE,
pull_metadata = pull_metadata)

if (is.character(expr) && is.null(name) && all(grepl(re_id, expr))) {
if (expr_is_literal_id(expr, name)) {
ids <- expr
} else {
## TODO: we may drop options here
Expand Down
25 changes: 15 additions & 10 deletions R/outpack_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,32 @@
##'
##' @title Extract metadata from orderly2 packets
##'
##' @param ... Arguments passed through to
##' [orderly2::orderly_search]. In the special case where the first
##' argument is a character vector of ids *and* there are no named
##' dot arguments, then we interpret this argument as a vector of
##' ids directly.
##'
##' @param extract A character vector of columns to extract, possibly
##' named. See Details for the format.
##'
##' @inheritParams orderly_metadata
##' @inheritParams orderly_search
##'
##' @return A `data.frame`, the columns of which vary based on the
##' names of `extract`; see Details for more information.
##'
##' @export
orderly_metadata_extract <- function(..., extract = NULL, root = NULL) {
orderly_metadata_extract <- function(expr = NULL, name = NULL, location = NULL,
allow_remote = NULL, pull_metadata = FALSE,
extract = NULL, root = NULL) {
root <- root_open(root, require_orderly = FALSE)
if (dots_is_literal_id(...)) {
ids <- ..1

options <- orderly_search_options(location = location,
allow_remote = allow_remote,
pull_metadata = pull_metadata)
if (expr_is_literal_id(expr, name)) {
ids <- expr
} else {
ids <- orderly_search(..., root = root)
## TODO: we may drop options here
ids <- orderly_search(expr, name = name,
options = options,
# location = location, pull_metadata = pull_metadata,
root = root)
}
extract <- parse_extract(extract, environment())

Expand Down
7 changes: 7 additions & 0 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ dots_is_literal_id <- function(...) {
}


expr_is_literal_id <- function(expr, ...) {
all(vlapply(list(...), is.null)) &&
is.character(expr) &&
all(grepl(re_id, expr))
}


as_orderly_query <- function(expr, name = NULL, scope = NULL, subquery = NULL,
arg = "expr", call = parent.frame()) {
if (missing(expr)) {
Expand Down
20 changes: 14 additions & 6 deletions man/orderly_metadata_extract.Rd

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

0 comments on commit a1c980e

Please sign in to comment.