diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 04872beb..45b00a2e 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -13,7 +13,6 @@ jobs: runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - ON_CI: "TRUE" steps: - uses: actions/checkout@v3 diff --git a/R/util_assert.R b/R/util_assert.R index 2d387739..af0e26e4 100644 --- a/R/util_assert.R +++ b/R/util_assert.R @@ -80,7 +80,8 @@ assert_file_exists <- function(files, name = "File", call = NULL, arg = NULL) { } -deprecate_old_orderly_name <- function(src, reportname, suppress_errors = FALSE) { +deprecate_old_orderly_name <- function(src, reportname, + suppress_errors = FALSE) { names <- c(sprintf("%s.R", reportname), "orderly.R") files_exist <- file.exists(file.path(src, names)) if (sum(files_exist) > 1 && !suppress_errors) { diff --git a/man/orderly_cleanup.Rd b/man/orderly_cleanup.Rd index fcf100a6..60312aa6 100644 --- a/man/orderly_cleanup.Rd +++ b/man/orderly_cleanup.Rd @@ -71,7 +71,7 @@ path <- orderly2::orderly_example("default") # We simulate running a packet interactively by using 'source'; # you might have run this line-by-line, or with the "Source" # button in Rstudio. -source(file.path(path, "src/data/orderly.R"), chdir = TRUE) +source(file.path(path, "src/data/data.R"), chdir = TRUE) # Having run this, the output of the report is present in the # source directory: diff --git a/man/orderly_list_src.Rd b/man/orderly_list_src.Rd index 340959ba..fea498ab 100644 --- a/man/orderly_list_src.Rd +++ b/man/orderly_list_src.Rd @@ -24,7 +24,7 @@ for passing to \link{orderly_run} } \description{ List source reports - that is, directories within \verb{src/} that -contain a file \code{orderly.R} +contain a file \verb{.R} } \examples{ path <- orderly2::orderly_example("default") diff --git a/man/orderly_new.Rd b/man/orderly_new.Rd index 70061900..5d8b14e4 100644 --- a/man/orderly_new.Rd +++ b/man/orderly_new.Rd @@ -14,8 +14,8 @@ for now are \code{NULL} (uses the built-in default) and \code{FALSE} which suppresses any default content. We may support customisable templates in future - let us know if this would be useful.} -\item{force}{Create an \code{orderly.R} file within an existing -directory \verb{src/}; this may be useful if you have already +\item{force}{Create a \verb{.R} file within an existing +directory \verb{src/}; this may be useful if you have already created the directory and some files first but want help creating the orderly file.} diff --git a/man/orderly_parameters.Rd b/man/orderly_parameters.Rd index e8c32b21..64788503 100644 --- a/man/orderly_parameters.Rd +++ b/man/orderly_parameters.Rd @@ -25,7 +25,7 @@ have a default, in which case this parameter will be required. When running interactively (i.e., via \code{source()} or running an -\code{orderly.R} session by copy/paste or in Rstudio), the +\verb{.R} session by copy/paste or in Rstudio), the \code{orderly_parameters()} function has different behaviour. First, we look in the current environment (most likely the global diff --git a/man/orderly_plugin_register.Rd b/man/orderly_plugin_register.Rd index dbb0d92a..fb95e394 100644 --- a/man/orderly_plugin_register.Rd +++ b/man/orderly_plugin_register.Rd @@ -43,7 +43,7 @@ etc), and will make your plugin nicer to work with \code{\link[=orderly_metadata_extract]{orderly_metadata_extract()}}. This function will be given a single argument \code{data} which is the data from \code{jsonlite::fromJSON(..., simplifyVector = FALSE)} and you should -apply and required simplifications yourself, returning a +apply any required simplifications yourself, returning a modified copy of the argument.} \item{cleanup}{Optionally, a function to clean up any state that @@ -64,7 +64,7 @@ registering a plugin. \description{ Create an orderly plugin. A plugin is typically defined by a package and is used to extend orderly by enabling new -functionality, declared in \code{orderly_config.yml} and \code{orderly.R} +functionality, declared in \code{orderly_config.yml} and \verb{.R} and affecting the running of reports primarily by creating new objects in the report environment. This system is discussed in more detail in \code{vignette("plugins")}, but will be expanded (likely diff --git a/tests/testthat/test-orderly.R b/tests/testthat/test-orderly.R index a4c61278..839f9010 100644 --- a/tests/testthat/test-orderly.R +++ b/tests/testthat/test-orderly.R @@ -75,10 +75,10 @@ test_that("error if a non-directory file is found in the src dir", { }) -test_that("allow creation of .R in existing dir if force is given", { +test_that("allow creation of foo.R in existing src/foo if force is given", { path <- test_prepare_orderly_example(character()) fs::dir_create(file.path(path, "src", "foo")) - file.create(file.path(path, "src", "foo", "bar")) + file.create(file.path(path, "src", "foo", "deprebar")) err <- expect_error( orderly_new("foo", root = path), "'src/foo/' already exists and contains files") diff --git a/tests/testthat/test-run.R b/tests/testthat/test-run.R index 2c9b4ff4..e8911edf 100644 --- a/tests/testthat/test-run.R +++ b/tests/testthat/test-run.R @@ -83,12 +83,9 @@ test_that("error if declared artefacts are not produced", { test_that("raises deprecation warning for orderly.R", { - skip_if(!identical(Sys.getenv("ON_CI"), "TRUE"), - message = paste("Skipping as deprecation warning", - "only appears every 8 hours per R", - "session. Will be tested on CI.")) path <- test_prepare_orderly_example("deprecated-orderly-name") envir <- new.env() + rlang::reset_message_verbosity("deprecate_orderly_file_name") suppressMessages( expect_message( orderly_run("deprecated-orderly-name", root = path, @@ -451,7 +448,8 @@ test_that("can copy resource from directory, implicitly", { test_that("fail to copy resource from directory, implicitly, strictly", { path <- test_prepare_orderly_example("resource-in-directory") envir <- new.env() - path_src <- file.path(path, "src", "resource-in-directory", "resource-in-directory.R") + path_src <- file.path(path, "src", "resource-in-directory", + "resource-in-directory.R") prepend_lines(path_src, "orderly2::orderly_strict_mode()") err <- suppressWarnings(tryCatch(read.csv("data/a.csv"), error = identity)) expect_error(suppressWarnings( @@ -464,7 +462,8 @@ test_that("fail to copy resource from directory, implicitly, strictly", { test_that("can copy resource from directory, included by file", { path <- test_prepare_orderly_example("resource-in-directory") envir <- new.env() - path_src <- file.path(path, "src", "resource-in-directory", "resource-in-directory.R") + path_src <- file.path(path, "src", "resource-in-directory", + "resource-in-directory.R") prepend_lines(path_src, c('orderly2::orderly_resource("data/a.csv")', 'orderly2::orderly_resource("data/b.csv")')) @@ -482,7 +481,8 @@ test_that("can copy resource from directory, included by file", { test_that("can copy resource from directory, included by file, strict mode", { path <- test_prepare_orderly_example("resource-in-directory") envir <- new.env() - path_src <- file.path(path, "src", "resource-in-directory", "resource-in-directory.R") + path_src <- file.path(path, "src", "resource-in-directory", + "resource-in-directory.R") prepend_lines(path_src, c("orderly2::orderly_strict_mode()", 'orderly2::orderly_resource("data/a.csv")', @@ -501,7 +501,8 @@ test_that("can copy resource from directory, included by file, strict mode", { test_that("can copy resource from directory, included by directory", { path <- test_prepare_orderly_example("resource-in-directory") envir <- new.env() - path_src <- file.path(path, "src", "resource-in-directory", "resource-in-directory.R") + path_src <- file.path(path, "src", "resource-in-directory", + "resource-in-directory.R") prepend_lines(path_src, 'orderly2::orderly_resource("data")') id <- orderly_run_quietly("resource-in-directory", root = path, envir = envir) @@ -518,7 +519,8 @@ test_that("can copy resource from directory, included by directory", { test_that("can copy resource from directory, included by directory, strictly", { path <- test_prepare_orderly_example("resource-in-directory") envir <- new.env() - path_src <- file.path(path, "src", "resource-in-directory", "resource-in-directory.R") + path_src <- file.path(path, "src", "resource-in-directory", + "resource-in-directory.R") prepend_lines(path_src, c("orderly2::orderly_strict_mode()", 'orderly2::orderly_resource("data")')) @@ -582,7 +584,8 @@ test_that("can pull resources programmatically", { test_that("can pull resources programmatically, strictly", { path <- test_prepare_orderly_example("programmatic-resource") - path_src <- file.path(path, "src", "programmatic-resource", "programmatic-resource.R") + path_src <- file.path(path, "src", "programmatic-resource", + "programmatic-resource.R") prepend_lines(path_src, "orderly2::orderly_strict_mode()") id1 <- orderly_run_quietly("programmatic-resource", list(use = "a"), root = path) diff --git a/vignettes/dependencies.Rmd b/vignettes/dependencies.Rmd index 97cb78a2..076e8416 100644 --- a/vignettes/dependencies.Rmd +++ b/vignettes/dependencies.Rmd @@ -28,7 +28,7 @@ Here, we show how to practically use dependencies in a few common scenarios of i ## Basic use -The primary mechanism for using dependencies is to call `orderly2::orderly_dependency()` from within an `orderly.R` script; this finds a suitable completed packet and copies files that are found from within that packet into your current report. +The primary mechanism for using dependencies is to call `orderly2::orderly_dependency()` from within a `.R` script; this finds a suitable completed packet and copies files that are found from within that packet into your current report. ```{r, include = FALSE} path <- tempfile() @@ -42,7 +42,7 @@ writeLines(c( 'd <- read.csv("data.csv")', "d$z <- resid(lm(y ~ x, d))", 'saveRDS(d, "data.rds")'), - file.path(path, "src", "data", "orderly.R")) + file.path(path, "src", "data", "data.R")) orderly2::orderly_run("data", root = path) fs::dir_create(file.path(path, "src", "analysis")) @@ -52,18 +52,18 @@ writeLines(c( 'png("analysis.png")', "plot(y ~ x, d)", "dev.off()"), - file.path(path, "src", "analysis", "orderly.R")) + file.path(path, "src", "analysis", "analysis.R")) ``` ```{r, echo = FALSE} dir_tree(file.path(path), "src") ``` -and `src/analysis/orderly.R` contains: +and `src/analysis/analysis.R` contains: ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/analysis/orderly.R"))) +r_output(readLines(file.path(path, "src/analysis/analysis.R"))) ``` Here, we've used `orderly2::orderly_dependency()` to pull in the file `data.rds` from the most recent version (`latest()`) of the `data` packet, then we've used that file as normal to make a plot, which we've saved as `analysis.png` (this is very similar to the example from `vignette("introduction")`, to get us started). @@ -94,7 +94,7 @@ writeLines(c( "orderly2::orderly_parameters(cyl = NULL)", "d <- mtcars[mtcars$cyl == cyl, ]", 'saveRDS(d, "data.rds")'), - file.path(path, "src", "data", "orderly.R")) + file.path(path, "src", "data", "data.R")) fs::dir_create(file.path(path, "src", "analysis")) writeLines(c( @@ -107,17 +107,17 @@ writeLines(c( 'png("analysis.png")', "plot(mpg ~ disp, d)", "dev.off()"), - file.path(path, "src", "analysis", "orderly.R")) + file.path(path, "src", "analysis", "analysis.R")) ``` ```{r, echo = FALSE} dir_tree(file.path(path), "src") ``` -with `src/data/orderly.R` containing: +with `src/data/data.R` containing: ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/data/orderly.R"))) +r_output(readLines(file.path(path, "src/data/data.R"))) ``` We can run this for several values of `cyl`: @@ -131,7 +131,7 @@ orderly2::orderly_run("data", list(cyl = 8)) Our follow-on analysis contains: ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/analysis/orderly.R"))) +r_output(readLines(file.path(path, "src/analysis/analysis.R"))) ``` Here the query `latest(parameter:cyl == this:cyl)` says "find the most recent packet where it's parameter "cyl" (`parameter:cyl`) is the same as the parameter in the currently running report (`this:cyl`). diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 4ffdd84d..27e7d21b 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -61,7 +61,7 @@ setwd(path) # Creating your first orderly report -An orderly report is a directory `src/` containing a file `orderly.R`. That file may have special commands in it, but for now we'll create one that is as simple as possible; we'll create some random data and save it to disk. This seems silly, but imagine this standing in for something like: +An orderly report is a directory `src/` containing a file `.R`. That file may have special commands in it, but for now we'll create one that is as simple as possible; we'll create some random data and save it to disk. This seems silly, but imagine this standing in for something like: * downloading file from some external site or resource * running a simulation and saving output @@ -77,7 +77,7 @@ writeLines(c( 'd <- read.csv("data.csv")', "d$z <- resid(lm(y ~ x, d))", 'saveRDS(d, "data.rds")'), - file.path(path, "src", "incoming_data", "orderly.R")) + file.path(path, "src", "incoming_data", "incoming_data.R")) ``` Our directory structure (ignoring `.outpack`) looks like: @@ -86,11 +86,11 @@ Our directory structure (ignoring `.outpack`) looks like: dir_tree(path, all = FALSE) ``` -and `src/incoming_data/orderly.R` contains: +and `src/incoming_data/incoming_data.R` contains: ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/incoming_data/orderly.R"))) +r_output(readLines(file.path(path, "src/incoming_data/incoming_data.R"))) ``` To run the report and create a new **packet**, use `orderly2::orderly_run()`: @@ -113,12 +113,12 @@ A few things have changed here: * we have a directory `r paste0("archive/incoming_data/", id)`; this directory contains - the file that was created when we ran the report (`data.rds`; see the script above) - a log of what happened when the report was run and the packet was created - - `orderly.R` and `data.csv`, the original input that have come from our source tree + - `incoming_data.R` and `data.csv`, the original input that have come from our source tree * there is an empty directory `draft/incoming_data` which was created when orderly ran the report in the first place In addition, quite a few files have changed within the `.outpack` directory, but these are not covered here. -That's it! Notice that the initial script is just a plain R script, and you can develop it interactively from within the `src/incoming_data` directory. Note however, that any paths referred to within will be relative to `src/incoming_data` and **not** the orderly repository root. This is important as all reports only see the world relative to their `orderly.R` file. +That's it! Notice that the initial script is just a plain R script, and you can develop it interactively from within the `src/incoming_data` directory. Note however, that any paths referred to within will be relative to `src/incoming_data` and **not** the orderly repository root. This is important as all reports only see the world relative to their `incoming_data.R` file. Once created, you can then refer to this report by id and pull its files wherever you need them, both in the context of another orderly report or just to copy to your desktop to email someone. For example, to copy the file `data.rds` that we created to some location outside of orderly's control you could do @@ -133,7 +133,7 @@ which copies `data.rds` to some new temporary directory `dest` with name `final. # Depending on packets from another report -Creating a new dataset is mostly useful if someone else can use it. To do this we introduce the first of the special orderly commands that you can use from `orderly.R` +Creating a new dataset is mostly useful if someone else can use it. To do this we introduce the first of the special orderly commands that you can use from `.R` ```{r, include = FALSE} fs::dir_create(file.path(path, "src", "analysis")) @@ -144,7 +144,7 @@ writeLines(c( 'png("analysis.png")', "plot(y ~ x, d)", "dev.off()"), - file.path(path, "src", "analysis", "orderly.R")) + file.path(path, "src", "analysis", "analysis.R")) ``` The `src/` directory now looks like: @@ -153,11 +153,11 @@ The `src/` directory now looks like: dir_tree(file.path(path), "src") ``` -and `src/analysis/orderly.R` contains: +and `src/analysis/analysis.R` contains: ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/analysis/orderly.R"))) +r_output(readLines(file.path(path, "src/analysis/analysis.R"))) ``` Here, we've used `orderly2::orderly_dependency()` to pull in the file `data.rds` from the most recent version (`latest()`) of the `data` packet with the filename `incoming.rds`, then we've used that file as normal to make a plot, which we've saved as `analysis.png`. @@ -187,18 +187,18 @@ In addition, there is also a function `orderly::orderly_run_info()` that can be Let's add some additional annotations to the previous reports: ```{r, include = FALSE} -code_data <- readLines(file.path(path, "src", "incoming_data", "orderly.R")) +code_data <- readLines(file.path(path, "src", "incoming_data", "incoming_data.R")) writeLines(c( "orderly2::orderly_strict_mode()", 'orderly2::orderly_resource("data.csv")', 'orderly2::orderly_artefact("Processed data", "data.rds")', "", code_data), - file.path(path, "src", "incoming_data", "orderly.R")) + file.path(path, "src", "incoming_data", "incoming_data.R")) ``` ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/incoming_data/orderly.R"))) +r_output(readLines(file.path(path, "src/incoming_data/incoming_data.R"))) ``` Here, we've added a block of special orderly commands; these could go anywhere, for example above the files that they refer to. If strict mode is enabled (see below) then `orderly2::orderly_resource` calls must go before the files are used as they will only be made available at that point (see below). @@ -220,11 +220,11 @@ writeLines(c( "x <- seq_len(n_samples)", "d <- data.frame(x = x, y = x + rnorm(n_samples))", 'saveRDS(d, "data.rds")'), - file.path(path, "src", "random", "orderly.R")) + file.path(path, "src", "random", "random.R")) ``` ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path, "src/random/orderly.R"))) +r_output(readLines(file.path(path, "src/random/random.R"))) ``` This creates a report that has a single parameter `n_samples` with a default value of 10. We could have used @@ -306,7 +306,7 @@ write.csv(data.frame(x = 1:10, y = runif(10)), dir_tree(path) ``` -We can then write an orderly report `use_shared` that uses this shared file, with its `orderly.R` containing: +We can then write an orderly report `use_shared` that uses this shared file, with its `use_shared.R` containing: ```{r, echo = FALSE, results = "asis"} fs::dir_create(file.path(path, "src", "use_shared")) @@ -318,8 +318,8 @@ writeLines(c( 'png("analysis.png")', "plot(y ~ x, d)", "dev.off()"), - file.path(path, "src", "use_shared", "orderly.R")) -r_output(readLines(file.path(path, "src/use_shared/orderly.R"))) + file.path(path, "src", "use_shared", "use_shared.R")) +r_output(readLines(file.path(path, "src/use_shared/use_shared.R"))) ``` We can run this: @@ -344,24 +344,24 @@ The previous version of orderly (`orderly1`; see `vignette("migrating")`) was ve orderly2::orderly_strict_mode() ``` -anywhere within your `orderly.R` script (conventionally at the top). We may make this more granular in future, but by adding this we: +anywhere within your `.R` script (conventionally at the top). We may make this more granular in future, but by adding this we: -* only copy files from the source directory (`src//`) to the draft directory where the report runs (`draft//`) that were declared with `orderly2::orderly_resource`; this leaves behind any extra files left over in development +* only copy files from the source directory (`src//`) to the draft directory where the report runs (`draft//`) that were declared with `orderly2::orderly_resource`; this leaves behind any extra files left over in development * warn at the end of running a packet if any files are found that are not part of an artefact -Using strict mode also helps `orderly2` clean up the `src/` directory more effectively after interactive development (see next section). +Using strict mode also helps `orderly2` clean up the `src/` directory more effectively after interactive development (see next section). # Interactive development -Set your working directory to `src/` and any orderly script should be fully executable (e.g., source with Rstudio's `Source` button, or R's `source()` function). Dependencies will be copied over as needed. +Set your working directory to `src/` and any orderly script should be fully executable (e.g., source with Rstudio's `Source` button, or R's `source()` function). Dependencies will be copied over as needed. After doing this, you will have a mix of files within your source directory. We recommend a per-source-directory `.gitignore` which will keep these files out of version control (see below). We will soon implement support for cleaning up generated files from this directory. -For example, suppose that we have interactively run our `incoming_data/orderly.R` script, we would leave behind generated files. We can report on this with `orderly2::orderly_cleanup_status`: +For example, suppose that we have interactively run our `incoming_data/incoming_data.R` script, we would leave behind generated files. We can report on this with `orderly2::orderly_cleanup_status`: ```{r, include = FALSE} withr::with_dir(file.path(path, "src/incoming_data"), - sys.source("orderly.R", new.env(parent = .GlobalEnv))) + sys.source("incoming_data.R", new.env(parent = .GlobalEnv))) ``` ```{r, inwd = path} diff --git a/vignettes/migrating.Rmd b/vignettes/migrating.Rmd index 5a4481fd..b3749569 100644 --- a/vignettes/migrating.Rmd +++ b/vignettes/migrating.Rmd @@ -17,7 +17,7 @@ If you have never used version 1.x of orderly, you should not read this document ## So long YAML and thanks for all the whitespace errors -The most obvious user-facing change is that there is (almost) no [YAML](https://en.wikipedia.org/wiki/YAML), with the definition of inputs and outputs for a report now defined within an R script (`orderly.R`). So an orderly report that previously had an `orderly.yml` file that looked like +The most obvious user-facing change is that there is (almost) no [YAML](https://en.wikipedia.org/wiki/YAML), with the definition of inputs and outputs for a report now defined within an R script (`.R`). So an orderly report that previously had an `orderly.yml` file that looked like ```yaml parameters: @@ -39,7 +39,7 @@ artefacts: filenames: data.rds ``` -would end up within an `orderly.R` script that looks like: +would end up within an `.R` script that looks like: ```r orderly2::orderly_parameters(n_min = 10) @@ -110,7 +110,7 @@ There are two parts to a migration: updating the canonical copy of your orderly You should migrate your archive first. Do this for every archive that you want to retain (you might have archives stored locally, on production servers and on staging servers). Archive migration happens *out of place*; that is, we do not modify anything in the original location. If your archive is old and has been used with very old versions of `orderly1` it is possible that this process will have a few hiccups. Please let us know if that is the case. The result of this process is that you will end up with a new directory that contains a new archive conforming to the `outpack` spec and containing `orderly2` metadata. -Next, migrate your source tree. This will be done *in place* so should be done on a fresh clone of your source git repository. For each report, we will examine your `orderly.yml` files and your script files (often `script.R`), delete these, and then write out a new `orderly.R` file that will adapt your report to work for `orderly2`. It is possible that this will not be perfect and might need some minor tweaking but hopefully it will be reasonable. One thing that is not preserved (and we probably cannot do so) is the comments from the `yaml` but as these often refer to `yaml` formatting or `orderly1` features hopefully this is not too much of a problem. You will probably want to manually tweak the generated code anyway, to take advantage of some of the new `orderly2` features such as being able to compute dependencies. +Next, migrate your source tree. This will be done *in place* so should be done on a fresh clone of your source git repository. For each report, we will examine your `orderly.yml` files and your script files (often `script.R`), delete these, and then write out a new `.R` file that will adapt your report to work for `orderly2`. It is possible that this will not be perfect and might need some minor tweaking but hopefully it will be reasonable. One thing that is not preserved (and we probably cannot do so) is the comments from the `yaml` but as these often refer to `yaml` formatting or `orderly1` features hopefully this is not too much of a problem. You will probably want to manually tweak the generated code anyway, to take advantage of some of the new `orderly2` features such as being able to compute dependencies. If you are using OrderlyWeb, you probably need to pause before migrating, as the replacement is not yet ready. diff --git a/vignettes/plugins.Rmd b/vignettes/plugins.Rmd index fc10450b..9b06517d 100644 --- a/vignettes/plugins.Rmd +++ b/vignettes/plugins.Rmd @@ -34,7 +34,7 @@ With the yaml-less design of `orderly2` (see `vignette("migrating")` if you are As an example, we'll implement a stripped down version of the database plugin that inspired this work (see [`orderly.db](https://github.com/mrc-ide/orderly.db) for a fuller implementation). To make this work we need functions: * ...that process additional fields in `orderly_config.yml` that describe where to find the database -* ...that can be called from `orderly.R` that access the database +* ...that can be called from `.R` that access the database * ...that can add metadata to the final orderly metadata about what was done We'll start with the report side of things, describing what we want to happen, then work on the implementation. @@ -64,7 +64,7 @@ writeLines(c( 'orderly2::orderly_artefact("Summary of data", "data.rds")', "", 'saveRDS(summary(dat), "data.rds")'), - file.path(path_example, "orderly.R")) + file.path(path_example, "example.R")) update_package <- function(key, path_pkg) { code <- unname(Filter( @@ -90,10 +90,10 @@ yaml_output(readLines(file.path(path_root, "orderly_config.yml"))) Our plugin is called `example.db` and is listed within the `plugins` section, along with its configuration; in this case indicating the path where the SQLite file can be loaded from. -The `orderly.R` file contains information about use of the database for this specific report; in this case, making the results of the query `SELECT * from mtcars WHERE cyl == 4` against the database available as some R object `dat` +The `example.R` file contains information about use of the database for this specific report; in this case, making the results of the query `SELECT * from mtcars WHERE cyl == 4` against the database available as some R object `dat` ```{r, echo = FALSE, results = "asis"} -r_output(readLines(file.path(path_example, "orderly.R"))) +r_output(readLines(file.path(path_example, "example.R"))) ``` Normally, we imagine some calculation here but this is kept minimal for the purpose of demonstration. @@ -102,7 +102,7 @@ To implement this we need to: 1. create a package 2. write a function to handle the configuration in `orderly_config.yml` -3. write a function `query()` used in `orderly.R` to do the query itself +3. write a function `query()` used in `example.R` to do the query itself ### Create a tiny package