Skip to content

Commit

Permalink
lint + don't skip test
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Feb 2, 2024
1 parent 5665d04 commit 6a3ee3d
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 63 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
ON_CI: "TRUE"

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion R/util_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion man/orderly_cleanup.Rd

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

2 changes: 1 addition & 1 deletion man/orderly_list_src.Rd

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

4 changes: 2 additions & 2 deletions man/orderly_new.Rd

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

2 changes: 1 addition & 1 deletion man/orderly_parameters.Rd

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

4 changes: 2 additions & 2 deletions man/orderly_plugin_register.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-orderly.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ test_that("error if a non-directory file is found in the src dir", {
})


test_that("allow creation of <reportname>.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")
Expand Down
23 changes: 13 additions & 10 deletions tests/testthat/test-run.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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")'))
Expand All @@ -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")',
Expand All @@ -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)

Expand All @@ -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")'))
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions vignettes/dependencies.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<reportname>.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()
Expand All @@ -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"))
Expand All @@ -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).
Expand Down Expand Up @@ -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(
Expand All @@ -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`:
Expand All @@ -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`).
Expand Down
Loading

0 comments on commit 6a3ee3d

Please sign in to comment.