Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct a call to drake_plan() from a workflow plan data frame #493

Merged
merged 4 commits into from
Aug 5, 2018

Conversation

wlandau
Copy link
Member

@wlandau wlandau commented Aug 5, 2018

Summary

This PR is a step toward pretty printing of plans. The new internal drake_plan_call() function constructs a call to drake_plan() from a workflow plan data frame. The actual print method may not be this simple, but it will be based on this generated call.

library(drake)
load_mtcars_example()
my_plan$trigger <- NA
my_plan$trigger[4] <- "trigger(condition = is_tuesday(), file = FALSE)"
my_plan$non_standard_column <- 1234
my_plan
#> # A tibble: 15 x 4
#>    target      command                  trigger           non_standard_co…
#>    <chr>       <chr>                    <chr>                        <dbl>
#>  1 report      "knit(knitr_in(\"report… <NA>                          1234
#>  2 small       simulate(48)             <NA>                          1234
#>  3 large       simulate(64)             <NA>                          1234
#>  4 regression… reg1(small)              trigger(conditio…             1234
#>  5 regression… reg1(large)              <NA>                          1234
#>  6 regression… reg2(small)              <NA>                          1234
#>  7 regression… reg2(large)              <NA>                          1234
#>  8 summ_regre… suppressWarnings(summar… <NA>                          1234
#>  9 summ_regre… suppressWarnings(summar… <NA>                          1234
#> 10 summ_regre… suppressWarnings(summar… <NA>                          1234
#> 11 summ_regre… suppressWarnings(summar… <NA>                          1234
#> 12 coef_regre… suppressWarnings(summar… <NA>                          1234
#> 13 coef_regre… suppressWarnings(summar… <NA>                          1234
#> 14 coef_regre… suppressWarnings(summar… <NA>                          1234
#> 15 coef_regre… suppressWarnings(summar… <NA>                          1234
call <- drake:::drake_plan_call(my_plan)
call
#> drake_plan(report = knit(knitr_in("report.Rmd"), file_out("report.md"), 
#>     quiet = TRUE), small = simulate(48), large = simulate(64), 
#>     regression1_small = target(command = reg1(small), trigger = trigger(condition = is_tuesday(), 
#>         file = FALSE)), regression1_large = reg1(large), regression2_small = reg2(small), 
#>     regression2_large = reg2(large), summ_regression1_small = suppressWarnings(summary(regression1_small$residuals)), 
#>     summ_regression1_large = suppressWarnings(summary(regression1_large$residuals)), 
#>     summ_regression2_small = suppressWarnings(summary(regression2_small$residuals)), 
#>     summ_regression2_large = suppressWarnings(summary(regression2_large$residuals)), 
#>     coef_regression1_small = suppressWarnings(summary(regression1_small))$coefficients, 
#>     coef_regression1_large = suppressWarnings(summary(regression1_large))$coefficients, 
#>     coef_regression2_small = suppressWarnings(summary(regression2_small))$coefficients, 
#>     coef_regression2_large = suppressWarnings(summary(regression2_large))$coefficients)
pkgconfig::set_config("drake::strings_in_dots" = "literals")
eval(call)
#> # A tibble: 15 x 3
#>    target        command                           trigger                
#>  * <chr>         <chr>                             <chr>                  
#>  1 report        "knit(knitr_in(\"report.Rmd\"), … <NA>                   
#>  2 small         simulate(48)                      <NA>                   
#>  3 large         simulate(64)                      <NA>                   
#>  4 regression1_… reg1(small)                       trigger(condition = is…
#>  5 regression1_… reg1(large)                       <NA>                   
#>  6 regression2_… reg2(small)                       <NA>                   
#>  7 regression2_… reg2(large)                       <NA>                   
#>  8 summ_regress… suppressWarnings(summary(regress… <NA>                   
#>  9 summ_regress… suppressWarnings(summary(regress… <NA>                   
#> 10 summ_regress… suppressWarnings(summary(regress… <NA>                   
#> 11 summ_regress… suppressWarnings(summary(regress… <NA>                   
#> 12 coef_regress… suppressWarnings(summary(regress… <NA>                   
#> 13 coef_regress… suppressWarnings(summary(regress… <NA>                   
#> 14 coef_regress… suppressWarnings(summary(regress… <NA>                   
#> 15 coef_regress… suppressWarnings(summary(regress… <NA>

Related GitHub issues and pull requests

Checklist

  • I have read drake's code of conduct, and I agree to follow its rules.
  • I have read the guidelines for contributing.
  • I have listed any substantial changes in the development news.
  • I have added testthat unit tests to tests/testthat to confirm that any new features or functionality work correctly.
  • I have tested this pull request locally with devtools::check()
  • This pull request is ready for review.
  • I think this pull request is ready to merge.

@codecov-io
Copy link

codecov-io commented Aug 5, 2018

Codecov Report

Merging #493 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #493   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          68     68           
  Lines        5957   5979   +22     
=====================================
+ Hits         5957   5979   +22
Impacted Files Coverage Δ
R/drake_plan.R 100% <100%> (ø) ⬆️
R/utils.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64e29a7...4232ef7. Read the comment docs.

@wlandau wlandau mentioned this pull request Aug 5, 2018
@lintr-bot
Copy link

tests/testthat/test-plan.R:573:1: style: Trailing blank lines are superfluous.

^

@wlandau wlandau merged commit aff4812 into master Aug 5, 2018
@wlandau wlandau deleted the drake_plan_call branch August 5, 2018 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants