kinto-b / makepipe

Tools for constructing simple make-like pipelines in R.
https://kinto-b.github.io/makepipe/
GNU General Public License v3.0
30 stars 0 forks source link

Add tests argument to make functions #7

Open gorcha opened 3 years ago

gorcha commented 3 years ago

It'd be cool to have a test argument to the make functions that can either be an expression or a file/directory path, that is run at the end to validate the make.

Depending on the type:

Would need to think about how to parse test results while also allowing maximum flexibility, since different testing approaches would return different things (e.g. test_dir/test_file return the test results, an expression block with a test_that call in it would return either NULL or throw an error).

For e.g.

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"),
  tests = "tests/test-1-data.R"
)
kinto-b commented 3 years ago

Great idea!

In terms of parsing the test results, do you have in mind adding some indication of test success/failure to the visualisation? For instance, using dark red for sources/recipes associated with failures?

gorcha commented 3 years ago

That'd be cool! I wonder if you could use a javascript library for the vis so you could make it a linkable graph, and hotlink recipes to their test results? Not exactly the same thing but kind of like how covr gives you a little temporary html doc to go through your test coverage. For e.g. vis.js (haven't actually used it, just first search result :P)

I've been reading a bit about the validate package as well, which could be cool. It's a tiny bit more restrictive than what you can do with for e.g. testdat but there are some really cool features like specifying validation sets from yaml - check out the section in the docs

I wonder if you could even do both, like a "test" argument that allows you to specify a test set for the recipe, and a "validate" argument that lets you provide validation rules for each of the targets?

kinto-b commented 3 years ago

I'm actually using the visNetwork package under the hood, which is just a wrapper for vis.js, so I reckon there would be a way to get the linking to work. But might be difficult to actually get the test results in an html format.

That validate package looks cool. I love the yaml specification of test rules. I kinda wanna look at doing something similar for testdat now...

I reckon sticking with the generic testthat framework would be better though, since I want to make as few assumptions about what users are going to be doing in their pipelines as possible.