diff --git a/CRAN-RELEASE b/CRAN-RELEASE deleted file mode 100644 index 688fb16..0000000 --- a/CRAN-RELEASE +++ /dev/null @@ -1,2 +0,0 @@ -This package was submitted to CRAN on 2021-10-28. -Once it is accepted, delete this file and tag the release (commit 8d7bbff). diff --git a/DESCRIPTION b/DESCRIPTION index f7e2490..b858332 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: makepipe Title: Pipeline Tools Inspired by 'GNU Make' -Version: 0.0.4 +Version: 0.0.5 Authors@R: person(given = "Kinto", family = "Behr", diff --git a/NEWS.md b/NEWS.md index e93df5e..67096f8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# makepipe 0.0.5 + +* Fixed minor bug having to do with the propagation of out-of-dateness in +Pipeline visualizations. + # makepipe 0.0.4 * Renamed package from `piper` to `makepipe` (#11). diff --git a/R/Pipeline.R b/R/Pipeline.R index cbdb5ae..a8f9e32 100644 --- a/R/Pipeline.R +++ b/R/Pipeline.R @@ -196,6 +196,7 @@ Pipeline <- R6::R6Class(classname = "Pipeline", list( # Propagate out-of-dateness for (i in seq_along(edges$to)) { + if (edges$.source[i]) next edges$out_of_date[i] <- propagate_outofdateness(edges$to[i], edges) } @@ -376,7 +377,7 @@ propagate_outofdateness <- function(initial_node, edges, next_node = NULL) { inputs <- edges[edges$to == next_node, ] for (i in seq_along(inputs$from)) { - outdated <- inputs$from_mtime[i] > target_mtime + outdated <- inputs$out_of_date[i] | inputs$from_mtime[i] > target_mtime next_node <- inputs$from[i] # Base case diff --git a/README.Rmd b/README.Rmd index 0c6f51c..9821f64 100644 --- a/README.Rmd +++ b/README.Rmd @@ -29,12 +29,21 @@ of data science workflows. ## Installation -You can install the development version from [GitHub](https://github.com/) with: +You can install the released version of `makepipe` from +[CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("makepipe") +``` + +And the development version from [GitHub](https://github.com/) with: ``` r # install.packages("devtools") devtools::install_github("kinto-b/makepipe") ``` + + ## Building a pipeline To construct a pipeline, one simply needs to chain together a number of @@ -50,8 +59,8 @@ visualisation of the pipeline. For example: library(makepipe) make_with_source( dependencies = c("data/0_raw_data.csv", "lookup/concordance.csv"), - source = c("1 data_prep.R"), - targets = c("data/1_data.Rds") + source = "1 data_prep.R", + targets = "data/1_data.Rds" ) make_with_recipe( dependencies = c("data/1_data.Rds", "data/0_pop.Rds"), diff --git a/README.md b/README.md index 9c96a55..6a7fa47 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,14 @@ easy-going, being adaptable to a wide range of data science workflows. ## Installation -You can install the development version from -[GitHub](https://github.com/) with: +You can install the released version of `makepipe` from +[CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("makepipe") +``` + +And the development version from [GitHub](https://github.com/) with: ``` r # install.packages("devtools") @@ -44,8 +50,8 @@ For example: library(makepipe) make_with_source( dependencies = c("data/0_raw_data.csv", "lookup/concordance.csv"), - source = c("1 data_prep.R"), - targets = c("data/1_data.Rds") + source = "1 data_prep.R", + targets = "data/1_data.Rds" ) make_with_recipe( dependencies = c("data/1_data.Rds", "data/0_pop.Rds"), diff --git a/cran-comments.md b/cran-comments.md index 4ec7c48..794cae7 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,8 @@ ## Resubmission -This is a resubmission (thank you for taking the time to read my last -submission). In this version I have: +This is a re-submission. In this version I have: -* Removed package name and all backticks from Description text. +* Replaced installed test files with tempfiles so that the tests only write to +the temporary directory ## Test environments * local R installation, R 4.1.0 diff --git a/inst/tests/mtcars.csv b/inst/tests/mtcars.csv deleted file mode 100644 index 2abcf28..0000000 --- a/inst/tests/mtcars.csv +++ /dev/null @@ -1,33 +0,0 @@ -"mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb" -21,6,160,110,3.9,2.62,16.46,0,1,4,4 -21,6,160,110,3.9,2.875,17.02,0,1,4,4 -22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 -21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 -18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 -18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 -14.3,8,360,245,3.21,3.57,15.84,0,0,3,4 -24.4,4,146.7,62,3.69,3.19,20,1,0,4,2 -22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2 -19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4 -17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4 -16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3 -17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3 -15.2,8,275.8,180,3.07,3.78,18,0,0,3,3 -10.4,8,472,205,2.93,5.25,17.98,0,0,3,4 -10.4,8,460,215,3,5.424,17.82,0,0,3,4 -14.7,8,440,230,3.23,5.345,17.42,0,0,3,4 -32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1 -30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2 -33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1 -21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1 -15.5,8,318,150,2.76,3.52,16.87,0,0,3,2 -15.2,8,304,150,3.15,3.435,17.3,0,0,3,2 -13.3,8,350,245,3.73,3.84,15.41,0,0,3,4 -19.2,8,400,175,3.08,3.845,17.05,0,0,3,2 -27.3,4,79,66,4.08,1.935,18.9,1,1,4,1 -26,4,120.3,91,4.43,2.14,16.7,0,1,5,2 -30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2 -15.8,8,351,264,4.22,3.17,14.5,0,1,5,4 -19.7,6,145,175,3.62,2.77,15.5,0,1,5,6 -15,8,301,335,3.54,3.57,14.6,0,1,5,8 -21.4,4,121,109,4.11,2.78,18.6,1,1,4,2 diff --git a/inst/tests/mtcars.txt b/inst/tests/mtcars.txt deleted file mode 100644 index 09cbb71..0000000 --- a/inst/tests/mtcars.txt +++ /dev/null @@ -1,33 +0,0 @@ -"mpg"|"cyl"|"disp"|"hp"|"drat"|"wt"|"qsec"|"vs"|"am"|"gear"|"carb" -21|6|160|110|3.9|2.62|16.46|0|1|4|4 -21|6|160|110|3.9|2.875|17.02|0|1|4|4 -22.8|4|108|93|3.85|2.32|18.61|1|1|4|1 -21.4|6|258|110|3.08|3.215|19.44|1|0|3|1 -18.7|8|360|175|3.15|3.44|17.02|0|0|3|2 -18.1|6|225|105|2.76|3.46|20.22|1|0|3|1 -14.3|8|360|245|3.21|3.57|15.84|0|0|3|4 -24.4|4|146.7|62|3.69|3.19|20|1|0|4|2 -22.8|4|140.8|95|3.92|3.15|22.9|1|0|4|2 -19.2|6|167.6|123|3.92|3.44|18.3|1|0|4|4 -17.8|6|167.6|123|3.92|3.44|18.9|1|0|4|4 -16.4|8|275.8|180|3.07|4.07|17.4|0|0|3|3 -17.3|8|275.8|180|3.07|3.73|17.6|0|0|3|3 -15.2|8|275.8|180|3.07|3.78|18|0|0|3|3 -10.4|8|472|205|2.93|5.25|17.98|0|0|3|4 -10.4|8|460|215|3|5.424|17.82|0|0|3|4 -14.7|8|440|230|3.23|5.345|17.42|0|0|3|4 -32.4|4|78.7|66|4.08|2.2|19.47|1|1|4|1 -30.4|4|75.7|52|4.93|1.615|18.52|1|1|4|2 -33.9|4|71.1|65|4.22|1.835|19.9|1|1|4|1 -21.5|4|120.1|97|3.7|2.465|20.01|1|0|3|1 -15.5|8|318|150|2.76|3.52|16.87|0|0|3|2 -15.2|8|304|150|3.15|3.435|17.3|0|0|3|2 -13.3|8|350|245|3.73|3.84|15.41|0|0|3|4 -19.2|8|400|175|3.08|3.845|17.05|0|0|3|2 -27.3|4|79|66|4.08|1.935|18.9|1|1|4|1 -26|4|120.3|91|4.43|2.14|16.7|0|1|5|2 -30.4|4|95.1|113|3.77|1.513|16.9|1|1|5|2 -15.8|8|351|264|4.22|3.17|14.5|0|1|5|4 -19.7|6|145|175|3.62|2.77|15.5|0|1|5|6 -15|8|301|335|3.54|3.57|14.6|0|1|5|8 -21.4|4|121|109|4.11|2.78|18.6|1|1|4|2 diff --git a/inst/tests/mtcars1.R b/inst/tests/mtcars1.R deleted file mode 100644 index e9fc557..0000000 --- a/inst/tests/mtcars1.R +++ /dev/null @@ -1,3 +0,0 @@ -mt <- read.csv(system.file("tests", "mtcars_src.csv", package = "makepipe"), check.names = FALSE) -makepipe::make_register(5, 'five') -write.csv(mt,file.path(system.file("tests", package = "makepipe"), "mtcars.csv"), row.names = FALSE) diff --git a/inst/tests/mtcars2.R b/inst/tests/mtcars2.R deleted file mode 100644 index 4d84662..0000000 --- a/inst/tests/mtcars2.R +++ /dev/null @@ -1,7 +0,0 @@ -mt <- read.csv(system.file("tests", "mtcars.csv", package = "makepipe"), check.names = FALSE, row.names = NULL) -write.table( - mt, - file.path(system.file("tests", package = "makepipe"), "mtcars.txt"), - sep = "|", - row.names = FALSE -) diff --git a/inst/tests/mtcars_src.csv b/inst/tests/mtcars_src.csv deleted file mode 100644 index 2abcf28..0000000 --- a/inst/tests/mtcars_src.csv +++ /dev/null @@ -1,33 +0,0 @@ -"mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb" -21,6,160,110,3.9,2.62,16.46,0,1,4,4 -21,6,160,110,3.9,2.875,17.02,0,1,4,4 -22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 -21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 -18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 -18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 -14.3,8,360,245,3.21,3.57,15.84,0,0,3,4 -24.4,4,146.7,62,3.69,3.19,20,1,0,4,2 -22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2 -19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4 -17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4 -16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3 -17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3 -15.2,8,275.8,180,3.07,3.78,18,0,0,3,3 -10.4,8,472,205,2.93,5.25,17.98,0,0,3,4 -10.4,8,460,215,3,5.424,17.82,0,0,3,4 -14.7,8,440,230,3.23,5.345,17.42,0,0,3,4 -32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1 -30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2 -33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1 -21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1 -15.5,8,318,150,2.76,3.52,16.87,0,0,3,2 -15.2,8,304,150,3.15,3.435,17.3,0,0,3,2 -13.3,8,350,245,3.73,3.84,15.41,0,0,3,4 -19.2,8,400,175,3.08,3.845,17.05,0,0,3,2 -27.3,4,79,66,4.08,1.935,18.9,1,1,4,1 -26,4,120.3,91,4.43,2.14,16.7,0,1,5,2 -30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2 -15.8,8,351,264,4.22,3.17,14.5,0,1,5,4 -19.7,6,145,175,3.62,2.77,15.5,0,1,5,6 -15,8,301,335,3.54,3.57,14.6,0,1,5,8 -21.4,4,121,109,4.11,2.78,18.6,1,1,4,2 diff --git a/inst/tests/source1.R b/inst/tests/source1.R new file mode 100644 index 0000000..123e447 --- /dev/null +++ b/inst/tests/source1.R @@ -0,0 +1 @@ +makepipe::make_register(5, 'five') diff --git a/inst/tests/source2.R b/inst/tests/source2.R new file mode 100644 index 0000000..ddf350d --- /dev/null +++ b/inst/tests/source2.R @@ -0,0 +1 @@ +2+2 diff --git a/tests/testthat/test-Pipeline.R b/tests/testthat/test-Pipeline.R index 549b4dc..b8e6f82 100644 --- a/tests/testthat/test-Pipeline.R +++ b/tests/testthat/test-Pipeline.R @@ -1,9 +1,19 @@ # Test files ------------------------------------------------------------------- -dependency <- system.file("tests", "mtcars_src.csv", package = "makepipe") -source1 <- system.file("tests", "mtcars1.R", package = "makepipe") -source2 <- system.file("tests", "mtcars2.R", package = "makepipe") -target1 <- system.file("tests", "mtcars.csv", package = "makepipe") -target2 <- system.file("tests", "mtcars.txt", package = "makepipe") +dependency <- tempfile(fileext=".csv") +write.csv(mtcars, dependency) + +target1 <- tempfile(fileext=".csv") +write.csv(mtcars, target1) + +target2 <- tempfile(fileext=".txt") +write.table(mtcars, target2) + +source1 <- tempfile(fileext=".R") +file.copy(system.file("tests", "source1.R", package = "makepipe"), source1) + +source2 <- tempfile(fileext=".R") +file.copy(system.file("tests", "source2.R", package = "makepipe"), source2) + # Functions -------------------------------------------------------------------- order_filetimes <- function(...) { @@ -166,3 +176,6 @@ test_that("annotations cannot must be character", { }) +# Unlink ------------------------------------------------------------------ + +unlink(c("dependency", "target1", "target2", "source1", "source2")) diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index ebdd528..870ded5 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -1,9 +1,18 @@ # Test files ------------------------------------------------------------------- -dependency <- system.file("tests", "mtcars_src.csv", package = "makepipe") -source1 <- system.file("tests", "mtcars1.R", package = "makepipe") -source2 <- system.file("tests", "mtcars2.R", package = "makepipe") -target1 <- system.file("tests", "mtcars.csv", package = "makepipe") -target2 <- system.file("tests", "mtcars.txt", package = "makepipe") +dependency <- tempfile(fileext=".csv") +write.csv(mtcars, dependency) + +target1 <- tempfile(fileext=".csv") +write.csv(mtcars, target1) + +target2 <- tempfile(fileext=".txt") +write.table(mtcars, target2) + +source1 <- tempfile(fileext=".R") +file.copy(system.file("tests", "source1.R", package = "makepipe"), source1) + +source2 <- tempfile(fileext=".R") +file.copy(system.file("tests", "source2.R", package = "makepipe"), source2) # Functions -------------------------------------------------------------------- order_filetimes <- function(...) { @@ -240,6 +249,8 @@ test_that("make_with_source returns what's registered", { expect_equal(res$result$five, 5) }) + +# Printing --------------------------------------------------------------------- test_that("make_with_recipe result prints nicely", { order_filetimes(target1, dependency) x <- make_with_recipe({ @@ -249,8 +260,8 @@ test_that("make_with_recipe result prints nicely", { expect_output(print(x), regexp = "# makepipe segment") expect_output(print(x), regexp = "* Recipe: ") - expect_output(print(x), regexp = "* Targets: '.*/mtcars.csv'") - expect_output(print(x), regexp = "* File dependencies: '.*/mtcars_src.csv'") + expect_output(print(x), regexp = "* Targets: '.*'") + expect_output(print(x), regexp = "* File dependencies: '.*'") expect_output(print(x), regexp = "* Executed: TRUE") expect_output(print(x), regexp = "* Result: 1 object") expect_output(print(x), regexp = "* Environment: ") @@ -270,17 +281,21 @@ test_that("make_with_source result prints nicely", { x <- make_with_source(source1, target1, dependency, quiet = TRUE) expect_output(print(x), regexp = "# makepipe segment") - expect_output(print(x), regexp = "* Source: '.*/mtcars1.R'") - expect_output(print(x), regexp = "* Targets: '.*/mtcars.csv'") - expect_output(print(x), regexp = "* File dependencies: '.*/mtcars_src.csv'") + expect_output(print(x), regexp = "* Source: '.*'") + expect_output(print(x), regexp = "* Targets: '.*'") + expect_output(print(x), regexp = "* File dependencies: '.*'") expect_output(print(x), regexp = "* Executed: TRUE") expect_output(print(x), regexp = "* Result: 1 object") expect_output(print(x), regexp = "* Environment: ") + order_filetimes(dependency, source1, target1) x <- make_with_source(source1, target1, dependency, quiet = TRUE) expect_output(print(x), regexp = "* Executed: FALSE") }) +# Unlink ------------------------------------------------------------------ + +unlink(c("dependency", "target1", "target2", "source1", "source2"))