Skip to content

Commit

Permalink
Minor adjustments post #1007
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Sep 30, 2019
1 parent a168d53 commit 1c38feb
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 430 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Thumbs.db
*.bbl
*.blg
*.dcf
*.dll
*.gcda
*.gcno
*.httr-oauth
Expand Down
8 changes: 3 additions & 5 deletions R/drake_plan_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ is_trigger_call <- function(expr) {
#'
#' @details Most data science workflows consist of imperative scripts.
#' `drake`, on the other hand, assumes you write *functions*.
#' `code_to_function()` allows for pre-exising workflows to incorporate
#' `code_to_function()` allows for pre-existing workflows to incorporate
#' drake as a workflow management tool seamlessly for cases where
#' re-factoring is unfeasible. So drake can monitor dependencies, the
#' targets are passed as arguments of the dependent functions.
Expand All @@ -1073,7 +1073,7 @@ is_trigger_call <- function(expr) {
#' isolate_example("contain side effects", {
#' # The `code_to_function()` function creates a function that makes it
#' # available for drake to process as part of the workflow.
#' # The main purpose is to allow pre-exising workflows to incorporate drake
#' # The main purpose is to allow pre-existing workflows to incorporate drake
#' # into the workflow seamlessly for cases where re-factoring is unfeasible.
#' #
#'
Expand Down Expand Up @@ -1142,19 +1142,17 @@ is_trigger_call <- function(expr) {
#' }
#' })
#' }

code_to_function <- function(path) {
lines <- readLines(path)
if (any(grepl(knitr_pattern, lines))) {
lines <- get_tangled_text(path)
}

lines <- c(
"function(...){",
lines,
"list(time = Sys.time(),tempfile = tempfile())",
"}"
)
)
text <- paste(lines, sep = "\n")
func <- eval(safe_parse(text))
func
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ reference:
- '`drake_plan`'
- '`transform_plan`'
- '`drake_plan_source`'
- '`code_to_function`'
- '`code_to_plan`'
- '`plan_to_code`'
- '`plan_to_notebook`'
Expand Down
1 change: 1 addition & 0 deletions drake.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
Expand Down
4 changes: 2 additions & 2 deletions man/code_to_function.Rd

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

Binary file removed src/drake.dll
Binary file not shown.
Loading

0 comments on commit 1c38feb

Please sign in to comment.