From 8f69baa990c9b09404e09123bcb67f72a270260b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Li=C3=A9tar?= Date: Fri, 15 Nov 2024 14:57:10 +0000 Subject: [PATCH] Support `environment:` from an interactive session. The code path for interactive sessions, through orderly_copy_files, was not propagating the environment from the caller to `orderly_search`. The broke support for `environment:`-style queries, but only when running interactively. In orderly_copy_files (and orderly_dependency), the `envir` parameter actually has two purposes: it provides values for `environment:` and it provides values that are substituted in the file paths to be copied. This dual usage causes a bit of confusion and may be what led to this issue. We may want to tidy up some of this in the future, possibly with the help of rlang's quosures and quasiquotation support. --- DESCRIPTION | 2 +- R/outpack_helpers.R | 1 + tests/testthat/examples/depends-query/depends-query.R | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 142493fa..b00a85c0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orderly2 Title: Orderly Next Generation -Version: 1.99.55 +Version: 1.99.56 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Robert", "Ashton", role = "aut"), diff --git a/R/outpack_helpers.R b/R/outpack_helpers.R index 32d97ae4..67b078c8 100644 --- a/R/outpack_helpers.R +++ b/R/outpack_helpers.R @@ -113,6 +113,7 @@ orderly_copy_files <- function(expr, files, dest, overwrite = TRUE, location = options$location, allow_remote = options$allow_remote, fetch_metadata = options$fetch_metadata, + envir = envir, root = root) if (length(id) > 1) { cli::cli_abort( diff --git a/tests/testthat/examples/depends-query/depends-query.R b/tests/testthat/examples/depends-query/depends-query.R index 5e1198b3..f596a304 100644 --- a/tests/testthat/examples/depends-query/depends-query.R +++ b/tests/testthat/examples/depends-query/depends-query.R @@ -1,9 +1,11 @@ orderly2::orderly_parameters(a = NULL, b = NULL, c = NULL) + +value <- c orderly2::orderly_dependency( "parameters", paste("latest(parameter:a == this:a &&", "parameter:b == this:b &&", - "parameter:c == this:c)"), + "parameter:c == environment:value)"), c(input.rds = "data.rds")) orderly2::orderly_artefact("result.rds", description = "Processed data") d <- readRDS("input.rds")