diff --git a/.Rbuildignore b/.Rbuildignore index 18aee3d..30fb57b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -28,3 +28,4 @@ ^CRAN-RELEASE$ ^doc$ ^Meta$ +^delayed_dump.*$ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1e871e0..cd764e9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ inst/doc doc Meta +delayed_dump* \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index fdc013e..8c13554 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: delayed Title: A Framework for Parallelizing Dependent Tasks -Version: 0.4.0 +Version: 0.5.0 Authors@R: c( person("Jeremy", "Coyle", email = "jeremyrcoyle@gmail.com", role = c("aut", "cre", "cph"), @@ -28,7 +28,10 @@ Imports: BBmisc, progress, R.utils, - R.oo + R.oo, + futile.logger, + tryCatchLog, + fs Suggests: testthat, knitr, diff --git a/NAMESPACE b/NAMESPACE index fbcdbd6..d294144 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,10 +8,12 @@ export(SequentialJob) export(bundle_delayed) export(delayed) export(delayed_fun) +export(delayed_traceback) export(eval_delayed) export(find_delayed_error) export(plot_delayed_shiny) import(R6) +import(futile.logger) import(rlang) import(rstackdeque) import(visNetwork) diff --git a/R/Delayed.R b/R/Delayed.R index eb54f29..aeb32e6 100644 --- a/R/Delayed.R +++ b/R/Delayed.R @@ -136,7 +136,6 @@ Delayed <- R6Class( value <- scheduler$compute() return(value) } - ), active = list( @@ -195,13 +194,17 @@ Delayed <- R6Class( runtime_self = function() { return(private$.job$runtime) }, - runtime = function(){ - if(is.null(private$.runtime_total)){ - sub_times <- sapply(self$delayed_dependencies,`[[`,"runtime") - - private$.runtime_total <- sum(unlist(sub_times))+self$runtime_self + runtime = function() { + if (is.null(private$.runtime_total)) { + all_runtimes <- get_all_runtimes(self) + suppressWarnings({ + dt <- rbindlist(all_runtimes) + }) + sub_time <- dt[!duplicated(dt), sum(runtime)] + + private$.runtime_total <- sub_time + self$runtime_self } - + return(private$.runtime_total) }, state = function() { diff --git a/R/Job.R b/R/Job.R index 513c5d0..b4c8139 100644 --- a/R/Job.R +++ b/R/Job.R @@ -1,23 +1,28 @@ #' Helper Function to Evaluate Delayed #' @param to_eval a list as generated from Delayed$prepare_eval() #' @param timeout a timeout indicating when to terminate the job +#' @param name the name of the delayed object (used for logging output) #' @export #' @importFrom R.utils withTimeout TimeoutException #' @importFrom R.oo throw -eval_delayed <- function(to_eval, timeout = Inf) { +eval_delayed <- function(to_eval, timeout = Inf, name = "") { if (timeout < 0) { R.oo::throw(R.utils::TimeoutException("time exhausted in other steps")) } - result <- R.utils::withTimeout( - { - rlang::eval_bare( - expr = to_eval$expr, - env = to_eval$env - ) - }, - timeout = timeout - ) + if (is.finite(timeout)) { + setTimeLimit(timeout, timeout, transient = TRUE) + on.exit({ + setTimeLimit(cpu = Inf, elapsed = Inf, transient = FALSE) + }) + } + + result <- try_with_logs({ + result <- rlang::eval_bare( + expr = to_eval$expr, + env = to_eval$env + ) + }, context = name) return(result) } @@ -92,14 +97,19 @@ SequentialJob <- R6Class( public = list( initialize = function(delayed_object) { to_eval <- delayed_object$prepare_eval() - start_time <-proc.time() - - private$.result <- try({ - set.seed(delayed_object$seed) - eval_delayed(to_eval, delayed_object$timeout) - }) + start_time <- proc.time() + + set.seed(delayed_object$seed) + private$.result <- try( + { + eval_delayed(to_eval, + delayed_object$timeout, + delayed_object$name) + }, + silent = TRUE + ) - private$.runtime <- (proc.time()-start_time)[[3]] + private$.runtime <- (proc.time() - start_time)[[3]] super$initialize(delayed_object) } ), @@ -148,12 +158,13 @@ FutureJob <- R6Class( env <- list( eval_delayed = eval_delayed, to_eval = delayed_object$prepare_eval(), - timeout = delayed_object$timeout + timeout = delayed_object$timeout, + name = delayed_object$name ) private$.start_time <- proc.time() private$.future <- future( - expr = quote(eval_delayed(to_eval, timeout)), + expr = quote(eval_delayed(to_eval, timeout, name)), # expr = to_eval$expr, # env = to_eval$env, substitute = FALSE, diff --git a/R/Scheduler.R b/R/Scheduler.R index a4cd5db..289c661 100644 --- a/R/Scheduler.R +++ b/R/Scheduler.R @@ -21,7 +21,7 @@ Scheduler <- R6Class( initialize = function(delayed_object, job_type = FutureJob, nworkers = NULL, - verbose = FALSE, + verbose = getOption("delayed.verbose"), progress = FALSE, ...) { private$.delayed_object <- delayed_object private$.task_lists <- list( @@ -64,7 +64,7 @@ Scheduler <- R6Class( dependent_uuid = NULL) { state <- delayed_object$update_state uuid <- delayed_object$uuid - delayed_object$seed <- runif(1,0,1e6) + delayed_object$seed <- runif(1, 0, 1e6) private$.n_tasks <- private$.n_tasks + 1 delayed_object$task_order <- private$.n_tasks assign(uuid, delayed_object, envir = private$.task_lists[[state]]) @@ -128,12 +128,12 @@ Scheduler <- R6Class( job_type <- private$.job_type if (current_task$sequential) { - SequentialJob$new(current_task) self$update_task(current_task, "ready", "running") + SequentialJob$new(current_task) } else { + self$update_task(current_task, "ready", "running") current_task$timeout <- self$time_left job <- job_type$new(current_task) - self$update_task(current_task, "ready", "running") } updated_tasks <- c(current_task) diff --git a/R/debug_helpers.R b/R/debug_helpers.R deleted file mode 100644 index bde7a49..0000000 --- a/R/debug_helpers.R +++ /dev/null @@ -1,8 +0,0 @@ -.delayed_traceback <- NULL - -delayed_traceback <- function() { - traceback(.delayed_traceback) -} - -delayed_log_traceback <- function() { -} diff --git a/R/logging_helpers.R b/R/logging_helpers.R new file mode 100644 index 0000000..dc3f27e --- /dev/null +++ b/R/logging_helpers.R @@ -0,0 +1,91 @@ + +#' Get traceback for last delayed error +#' @param call_stack a call stack argument (defaults to last delayed error) +#' @param cat if TRUE, uses cat to print the traceback +#' @export +delayed_traceback <- function(call_stack=NULL, cat = TRUE){ + if(is.null(call_stack)){ + call_stack <- get0("traceback", envir=.delayed_env) + } + # TODO: maybe suppress the delayed boilerplate in here + if(length(call_stack)==0){ + message("no traceback available") + } + + stacktrace <- tryCatchLog::limitedLabelsCompact(call_stack, FALSE) + stacktrace <- paste(" ", + seq_along(stacktrace), + stacktrace, + collapse = "\n") + + + if(cat){ + cat(stacktrace) + } + + invisible(stacktrace) +} + +#' @import futile.logger +default_condition_handler <- function(c){ + condition_class <- class(c)[1] + message <- sprintf("%s %s %s", condition_class, context, c$message) + + + + + if (inherits(c,"error")){ + log_fun <- flog.error + + # TODO: add option to also do this for warnings + call_stack <- sys.calls() + assign("traceback", call_stack, envir=.delayed_env) + + if(getOption("delayed.dumpfile")){ + context <- fs::path_sanitize(context,"-") + filename <- sprintf("delayed_dump_%s_%s.rdata", + context, + strftime(Sys.time(),"%Y%m%d%H%M%S")) + utils::dump.frames() + save.image(file = filename) + + message <- paste(message, + sprintf("\tframes dumped to %s", filename), + sep = "\n") + + } + + if(getOption("delayed.stacktrace")){ + stacktrace <- delayed_traceback(call_stack, FALSE) + message <- paste(message, stacktrace, sep = "\n") + } + + + + } else if(inherits(c,"warning")){ + log_fun <- flog.warn + } else { + log_fun <- flog.info + + } + + + + + log_fun(message) + + +} + +try_with_logs <- function(expr, condition_handler=default_condition_handler, context=NULL){ + # make a copy of the handler and add context + ch_instance <- condition_handler + environment(ch_instance) <- new.env(parent=environment(condition_handler)) + assign("context",context, envir=environment(ch_instance)) + + tryCatch( + withCallingHandlers(expr, + condition = ch_instance + ) + ) +} diff --git a/R/utils.R b/R/utils.R index 57a1213..94e82c9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -35,3 +35,11 @@ find_delayed_error <- function(delayed_object) { bundle_args <- function(...) { return(list(...)) } + +get_all_runtimes <- function(delayed_obj) { + dd_runtimes <- lapply(delayed_obj$delayed_dependencies, get_all_runtimes) + this_runtime <- list(uuid = delayed_obj$uuid, runtime = delayed_obj$runtime_self) + + result <- c(unlist(dd_runtimes, recursive = FALSE), list(this_runtime)) + return(result) +} diff --git a/R/zzz.R b/R/zzz.R index 658fedf..c619ce5 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -5,3 +5,12 @@ utils::packageDescription("delayed")$Title )) } + +.onLoad <- function(...){ + options(delayed.stacktrace = FALSE) + options(delayed.dumpfile = FALSE) + options(delayed.verbose = FALSE) +} + +.delayed_env <- new.env() + diff --git a/README.html b/README.html index 35669a9..e11ca55 100644 --- a/README.html +++ b/README.html @@ -603,7 +603,7 @@

R/delayed

-

Travis-CI Build Status Build status Coverage Status CRAN CRAN downloads Project Status: Active – The project has reached a stable, usable state and is being actively developed. License: GPL v3

+

Travis-CI Build Status Build status Coverage Status CRAN CRAN downloads Project Status: Active – The project has reached a stable, usable state and is being actively developed. License: GPL v3

A framework for parallelizing dependent tasks

@@ -614,47 +614,47 @@

What’s delayed?


Installation

For standard use, we recommend installing the package from CRAN via

-
install.packages("delayed")
+
install.packages("delayed")

Install the most recent stable release from GitHub via devtools:

-
devtools::install_github("tlverse/delayed")
+
devtools::install_github("tlverse/delayed")

Issues

If you encounter any bugs or have any specific feature requests, please file an issue.


Example

This minimal example shows how to use delayed to handle dependent computations via chaining of tasks:

-
library(delayed)
-#> delayed v0.3.0: Framework for Parallelizing Dependent Tasks
-
-# delay a function that does a bit of math
-mapfun <- function(x, y) {(x + y) / (x - y)}
-delayed_mapfun <- delayed_fun(mapfun)
-
-set.seed(14765)
-library(future)
-plan(multicore, workers = 2)
-const <- 7
-
-# re-define the delayed object from above
-delayed_norm <- delayed(rnorm(n = const))
-delayed_pois <- delayed(rpois(n = const, lambda = const))
-chained_norm_pois <- delayed_mapfun(delayed_norm, delayed_pois)
-
-# compute it using the future plan (multicore with 2 cores)
-chained_norm_pois$compute(nworkers = 2, verbose = TRUE)
-#> run:0 ready:2 workers:2
-#> updating rnorm(n = const) from ready to running
-#> run:1 ready:1 workers:2
-#> updating rpois(n = const, lambda = const) from ready to running
-#> run:2 ready:0 workers:2
-#> updating rnorm(n = const) from running to resolved
-#> updating rpois(n = const, lambda = const) from running to resolved
-#> updating mapfun(x = delayed_norm, y = delayed_pois) from waiting to ready
-#> run:0 ready:1 workers:2
-#> updating mapfun(x = delayed_norm, y = delayed_pois) from ready to running
-#> run:1 ready:0 workers:2
-#> updating mapfun(x = delayed_norm, y = delayed_pois) from running to resolved
-#> [1] -1.1601934 -0.4678799 -1.2152393 -0.8963905 -1.0718538 -1.0619060 -0.8325901
+
library(delayed)
+#> delayed v0.4.0: A Framework for Parallelizing Dependent Tasks
+
+# delay a function that does a bit of math
+mapfun <- function(x, y) {(x + y) / (x - y)}
+delayed_mapfun <- delayed_fun(mapfun)
+
+set.seed(14765)
+library(future)
+plan(multicore, workers = 2)
+const <- 7
+
+# re-define the delayed object from above
+delayed_norm <- delayed(rnorm(n = const))
+delayed_pois <- delayed(rpois(n = const, lambda = const))
+chained_norm_pois <- delayed_mapfun(delayed_norm, delayed_pois)
+
+# compute it using the future plan (multicore with 2 cores)
+chained_norm_pois$compute(nworkers = 2, verbose = TRUE)
+#> run:0 ready:2 workers:2
+#> updating rnorm(n = const) from ready to running
+#> run:1 ready:1 workers:2
+#> updating rpois(n = const, lambda = const) from ready to running
+#> run:2 ready:0 workers:2
+#> updating rnorm(n = const) from running to resolved
+#> updating rpois(n = const, lambda = const) from running to resolved
+#> updating mapfun(x = delayed_norm, y = delayed_pois) from waiting to ready
+#> run:0 ready:1 workers:2
+#> updating mapfun(x = delayed_norm, y = delayed_pois) from ready to running
+#> run:1 ready:0 workers:2
+#> updating mapfun(x = delayed_norm, y = delayed_pois) from running to resolved
+#> [1] -0.6688907 -1.2691496 -1.1808899 -1.7605806 -0.5992127 -0.6838026 -1.4086257

Remark: In the above, the delayed computation is carried out in parallel using the framework offered by the excellent future package and its associated ecosystem.


License

diff --git a/README.md b/README.md index 67f9f57..9bb0034 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/ **Author:** [Jeremy Coyle](https://github.com/jeremyrcoyle) ------ +------------------------------------------------------------------------ ## What’s `delayed`? @@ -35,7 +35,7 @@ use `delayed`, please consult the package [vignette](https://nhejazi.github.io/delayed/articles/delayed.html) online, or do so from within [R](https://www.r-project.org/). ------ +------------------------------------------------------------------------ ## Installation @@ -53,14 +53,14 @@ Install the most recent *stable release* from GitHub via devtools::install_github("tlverse/delayed") ``` ------ +------------------------------------------------------------------------ ## Issues If you encounter any bugs or have any specific feature requests, please [file an issue](https://github.com/tlverse/delayed/issues). ------ +------------------------------------------------------------------------ ## Example @@ -69,7 +69,7 @@ computations via chaining of tasks: ``` r library(delayed) -#> delayed v0.3.0: Framework for Parallelizing Dependent Tasks +#> delayed v0.4.0: A Framework for Parallelizing Dependent Tasks # delay a function that does a bit of math mapfun <- function(x, y) {(x + y) / (x - y)} @@ -99,7 +99,7 @@ chained_norm_pois$compute(nworkers = 2, verbose = TRUE) #> updating mapfun(x = delayed_norm, y = delayed_pois) from ready to running #> run:1 ready:0 workers:2 #> updating mapfun(x = delayed_norm, y = delayed_pois) from running to resolved -#> [1] -1.1601934 -0.4678799 -1.2152393 -0.8963905 -1.0718538 -1.0619060 -0.8325901 +#> [1] -0.6688907 -1.2691496 -1.1808899 -1.7605806 -0.5992127 -0.6838026 -1.4086257 ``` *Remark:* In the above, the delayed computation is carried out in @@ -107,7 +107,7 @@ parallel using the framework offered by the excellent [`future` package](https://github.com/HenrikBengtsson/future) and its associated ecosystem. ------ +------------------------------------------------------------------------ ## License diff --git a/docs/404.html b/docs/404.html index 11b6bd0..040b33a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
@@ -123,6 +127,12 @@

Page not found (404)

+ + @@ -133,7 +143,7 @@

Page not found (404)

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 5b08822..601a176 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
@@ -186,6 +190,12 @@

+ + @@ -196,7 +206,7 @@

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index aacf1e5..dce7f9f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
@@ -797,6 +801,12 @@

License

+ + @@ -807,7 +817,7 @@

License

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/delayed.html b/docs/articles/delayed.html index 407a0e0..fc8713b 100644 --- a/docs/articles/delayed.html +++ b/docs/articles/delayed.html @@ -6,13 +6,13 @@ `delayed`: A Framework for Parallelizing Dependent Tasks • delayed - - - - + + + + + - - + - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
@@ -123,9 +127,10 @@

Articles

All vignettes

- +
+
`delayed`: A Framework for Parallelizing Dependent Tasks
+
+
@@ -137,7 +142,7 @@

All vignettes

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/authors.html b/docs/authors.html index 311c840..cc0fc51 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
@@ -121,11 +125,11 @@

Authors

@@ -142,7 +146,7 @@

Authors

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/index.html b/docs/index.html index 99e74a1..5cdc460 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,17 +6,17 @@ A Framework for Parallelizing Dependent Tasks • delayed - - - - + + + + + - - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
    @@ -116,22 +120,22 @@
    -
    -

    -delayed 0.3.0 2020-02-28 +
    +

    +delayed 0.3.0 2020-02-28

    • Initial version for CRAN release.
    • Changes to core functions to keep up with rlang updates.
    -
    -

    -delayed 0.2.1 Unreleased +
    +

    +delayed 0.2.1 Unreleased

    • Stable release with modifications to keep up with changes in rlang.
    • @@ -139,14 +143,10 @@

    - @@ -158,7 +158,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/pkgdown.css b/docs/pkgdown.css index 9145958..1273238 100644 --- a/docs/pkgdown.css +++ b/docs/pkgdown.css @@ -17,6 +17,10 @@ html, body { height: 100%; } +body { + position: relative; +} + body > .container { display: flex; height: 100%; @@ -67,6 +71,10 @@ summary { margin-top: calc(-60px + 1em); } +dd { + margin-left: 3em; +} + /* Section anchors ---------------------------------*/ a.anchor { @@ -100,29 +108,132 @@ a.anchor { margin-top: -40px; } +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + /* Sidebar --------------------------*/ -#sidebar { +#pkgdown-sidebar { margin-top: 30px; position: -webkit-sticky; position: sticky; top: 70px; } -#sidebar h2 { + +#pkgdown-sidebar h2 { font-size: 1.5em; margin-top: 1em; } -#sidebar h2:first-child { +#pkgdown-sidebar h2:first-child { margin-top: 0; } -#sidebar .list-unstyled li { +#pkgdown-sidebar .list-unstyled li { margin-bottom: 0.5em; } +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + .orcid { - height: 16px; + font-size: 16px; + color: #A6CE39; /* margins are required by official ORCID trademark and display guidelines */ margin-left:4px; margin-right:4px; @@ -133,14 +244,14 @@ a.anchor { .ref-index th {font-weight: normal;} -.ref-index td {vertical-align: top;} +.ref-index td {vertical-align: top; min-width: 100px} .ref-index .icon {width: 40px;} .ref-index .alias {width: 40%;} .ref-index-icons .alias {width: calc(40% - 40px);} .ref-index .title {width: 60%;} .ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} .ref-arguments .name {width: 20%;} .ref-arguments .desc {width: 80%;} diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 087a762..7e7048f 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -9,11 +9,6 @@ $('body').css('padding-top', $('.navbar').height() + 10); }); - $('body').scrollspy({ - target: '#sidebar', - offset: 60 - }); - $('[data-toggle="tooltip"]').tooltip(); var cur_path = paths(location.pathname); diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index ab4c216..36bde37 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,8 +1,9 @@ -pandoc: 2.2.1 -pkgdown: 1.4.1 +pandoc: '2.11' +pkgdown: 1.6.1 pkgdown_sha: ~ articles: delayed: delayed.html +last_built: 2021-04-29T18:56Z urls: reference: http://tlverse.org/delayed/reference article: http://tlverse.org/delayed/articles diff --git a/docs/reference/DelayedClass.html b/docs/reference/DelayedClass.html index 509e227..f452bbe 100644 --- a/docs/reference/DelayedClass.html +++ b/docs/reference/DelayedClass.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -37,7 +41,6 @@ - @@ -65,7 +68,7 @@ - +
    @@ -119,7 +122,7 @@
    @@ -131,15 +134,15 @@

    Delayed class that manages dependencies and computes when necessary

    Examples

    -
    d <- delayed(3 + 4) -methods::is(d, "Delayed")
    #> [1] TRUE
    d$compute()
    #> [1] 7
    +
    d <- delayed(3 + 4) +methods::is(d, "Delayed") +
    #> [1] TRUE
    d$compute() +
    #> [1] 7
    - @@ -150,7 +153,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/FutureJob.html b/docs/reference/FutureJob.html index 3f26284..10bab26 100644 --- a/docs/reference/FutureJob.html +++ b/docs/reference/FutureJob.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -38,7 +42,6 @@ - @@ -66,7 +69,7 @@ - +
    @@ -120,7 +123,7 @@
    @@ -133,17 +136,16 @@

    Future Delayed Jobs

    Examples

    -
    library(future) -plan(multicore, workers = 1) -d <- delayed(3 + 4) -sched <- Scheduler$new(d, FutureJob, nworkers = 1)
    +
    library(future) +plan(multicore, workers = 1) +d <- delayed(3 + 4) +sched <- Scheduler$new(d, FutureJob, nworkers = 1) +
    - @@ -154,7 +156,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/Job.html b/docs/reference/Job.html index 55a9cf6..fc58754 100644 --- a/docs/reference/Job.html +++ b/docs/reference/Job.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -41,7 +45,6 @@ immediately, blocking the current process until they are complete. FutureJobs leverages future to evaluate according to the specified plan." /> - @@ -69,7 +72,7 @@ - +
    @@ -123,7 +126,7 @@
    @@ -139,11 +142,10 @@

    Evaluation of Delayed Objects

    - @@ -154,7 +156,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png new file mode 100644 index 0000000..17a3580 Binary files /dev/null and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/Scheduler.html b/docs/reference/Scheduler.html index aa8a571..a4f02ed 100644 --- a/docs/reference/Scheduler.html +++ b/docs/reference/Scheduler.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -37,7 +41,6 @@ - @@ -65,7 +68,7 @@ - +
    @@ -119,7 +122,7 @@
    @@ -131,16 +134,15 @@

    Scheduler class that orders compute tasks and dispatches tasks to workersExamples

    -
    d <- delayed(3 + 4) -sched <- Scheduler$new(d, SequentialJob) -sched$compute()
    #> [1] 7
    +
    d <- delayed(3 + 4) +sched <- Scheduler$new(d, SequentialJob) +sched$compute() +
    #> [1] 7
    - @@ -151,7 +153,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/SequentialJob.html b/docs/reference/SequentialJob.html index 7292d95..5a8a50e 100644 --- a/docs/reference/SequentialJob.html +++ b/docs/reference/SequentialJob.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -38,7 +42,6 @@ - @@ -66,7 +69,7 @@ - +
    @@ -120,7 +123,7 @@
    @@ -133,15 +136,14 @@

    Sequential Delayed Jobs

    Examples

    -
    d <- delayed(3 + 4) -sched <- Scheduler$new(d, SequentialJob)
    +
    d <- delayed(3 + 4) +sched <- Scheduler$new(d, SequentialJob) +
    - @@ -152,7 +154,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/bundle_delayed.html b/docs/reference/bundle_delayed.html index 42aaa05..6eab578 100644 --- a/docs/reference/bundle_delayed.html +++ b/docs/reference/bundle_delayed.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -38,7 +42,6 @@ - @@ -66,7 +69,7 @@ - +
    @@ -120,7 +123,7 @@
    @@ -129,9 +132,9 @@

    Bundle Delayed Objects

    object out of an arbitrary number of input Delayed objects.

    -
    bundle_delayed(delayed_list)
    +    
    bundle_delayed(delayed_list)
     
    -bundle_args(...)
    +bundle_args(...)

    Arguments

    @@ -149,14 +152,15 @@

    Arg

    Examples

    -
    ident_fun <- function(x) { - Sys.sleep(0.01) - x -} -delayed_ident <- delayed_fun(ident_fun) -d_list <- lapply(1:10, delayed_ident) -d_bundle <- bundle_delayed(d_list) -d_bundle$compute(progress = FALSE)
    #> [[1]] +
    ident_fun <- function(x) { + Sys.sleep(0.01) + x +} +delayed_ident <- delayed_fun(ident_fun) +d_list <- lapply(1:10, delayed_ident) +d_bundle <- bundle_delayed(d_list) +d_bundle$compute(progress = FALSE) +
    #> [[1]] #> [1] 1 #> #> [[2]] @@ -187,13 +191,10 @@

    Examp #> [1] 10 #>

    - @@ -204,7 +205,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/delayed.html b/docs/reference/delayed.html index a112828..d16d196 100644 --- a/docs/reference/delayed.html +++ b/docs/reference/delayed.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -38,7 +42,6 @@ - @@ -66,7 +69,7 @@ - +
    @@ -120,7 +123,7 @@
    @@ -129,9 +132,9 @@

    Generates Delayed Version of an Expression

    Delayed objects

    -
    delayed(expr, sequential = FALSE, expect_error = FALSE)
    +    
    delayed(expr, sequential = FALSE, expect_error = FALSE, timeout = NULL)
     
    -delayed_fun(fun, sequential = FALSE, expect_error = FALSE)
    +delayed_fun(fun, sequential = FALSE, expect_error = FALSE)

    Arguments

    @@ -146,7 +149,11 @@

    Arg

    - + + + + @@ -157,21 +164,20 @@

    Arg

    Examples

    -
    d <- delayed(3 + 4) -d$compute()
    #> [1] 7
    adder <- function(x, y) { - x + y -} -delayed_adder <- delayed_fun(adder) -z <- delayed_adder(3, 4) -z$compute()
    #> [1] 7
    +
    d <- delayed(3 + 4) +d$compute() +
    #> [1] 7
    adder <- function(x, y) { + x + y +} +delayed_adder <- delayed_fun(adder) +z <- delayed_adder(3, 4) +z$compute() +
    #> [1] 7
    - @@ -182,7 +188,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/eval_delayed.html b/docs/reference/eval_delayed.html new file mode 100644 index 0000000..f90dff7 --- /dev/null +++ b/docs/reference/eval_delayed.html @@ -0,0 +1,176 @@ + + + + + + + + +Helper Function to Evaluate Delayed — eval_delayed • delayed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Helper Function to Evaluate Delayed

    +
    + +
    eval_delayed(to_eval, timeout = Inf)
    + +

    Arguments

    +
    expect_error

    if TRUE, pass error to downstream tasks instead of +

    if TRUE, pass error to downstream tasks instead of

    timeout

    specify a time limit for computation halting computation

    + + + + + + + + + +
    to_eval

    a list as generated from Delayed$prepare_eval()

    timeout

    a timeout indicating when to terminate the job

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/find_delayed_error.html b/docs/reference/find_delayed_error.html index c629ef8..f858842 100644 --- a/docs/reference/find_delayed_error.html +++ b/docs/reference/find_delayed_error.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -38,7 +42,6 @@ - @@ -66,7 +69,7 @@ - +
    @@ -120,7 +123,7 @@
    @@ -129,7 +132,7 @@

    Find error in delayed chain

    object with state "error"

    -
    find_delayed_error(delayed_object)
    +
    find_delayed_error(delayed_object)

    Arguments

    @@ -142,19 +145,108 @@

    Arg

    Examples

    -
    delayed_error <- delayed_fun(stop) -error_message <- "this is an error" -broken_delayed <- delayed_error(error_message) -broken_delayed$expect_error <- TRUE -result <- broken_delayed$compute()
    +
    delayed_error <- delayed_fun(stop) +error_message <- "this is an error" +broken_delayed <- delayed_error(error_message) +broken_delayed$expect_error <- TRUE +result <- broken_delayed$compute() +
    #> ERROR [2021-04-29 11:56:29] [ERROR] this is an error +#> +#> Compact call stack: +#> 1 tryCatch(withCallingHandlers({ +#> +#> Full call stack: +#> 1 tryCatch(withCallingHandlers({ +#> NULL +#> saveRDS(do.call(do.call +#> 2 tryCatchList(expr, classes, parentenv, handlers) +#> 3 tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names +#> 4 doTryCatch(return(expr), name, parentenv, handler) +#> 5 tryCatchList(expr, names[-nh], parentenv, handlers[-nh]) +#> 6 tryCatchOne(expr, names, parentenv, handlers[[1]]) +#> 7 doTryCatch(return(expr), name, parentenv, handler) +#> 8 withCallingHandlers({ +#> NULL +#> saveRDS(do.call(do.call, c(readR +#> 9 saveRDS(do.call(do.call, c(readRDS("/var/folders/8m/0x4xq6v534j4y9f7jycckj5 +#> 10 do.call(do.call, c(readRDS("/var/folders/8m/0x4xq6v534j4y9f7jycckj5c0000gn/ +#> 11 (function (what, args, quote = FALSE, envir = parent.frame()) +#> { +#> +#> 12 (function (..., crayon_enabled, crayon_colors, pkgdown_internet) +#> { +#> +#> 13 pkgdown::build_site(...) +#> 14 build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_ru +#> 15 build_reference(pkg, lazy = lazy, examples = examples, run_dont_run = run_d +#> 16 purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, examples +#> 17 .f(.x[[i]], ...) +#> 18 withCallingHandlers(data_reference_topic(topic, pkg, examples = examples, r +#> 19 data_reference_topic(topic, pkg, examples = examples, run_dont_run = run_do +#> 20 run_examples(tags$tag_examples[[1]], env = new.env(parent = globalenv()), t +#> 21 highlight_examples(code, topic, env = env) +#> 22 downlit::evaluate_and_highlight(code, fig_save = fig_save_topic, env = chil +#> 23 evaluate::evaluate(code, child_env(env), new_device = TRUE) +#> 24 evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, debug +#> 25 timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, en +#> 26 handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, enclos)), wa +#> 27 try(f, silent = TRUE) +#> 28 tryCatch(expr, error = function(e) { +#> call <- conditionCall(e) +#> +#> 29 tryCatchList(expr, classes, parentenv, handlers) +#> 30 tryCatchOne(expr, names, parentenv, handlers[[1]]) +#> 31 doTryCatch(return(expr), name, parentenv, handler) +#> 32 withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHand +#> 33 withVisible(eval(expr, envir, enclos)) +#> 34 eval(expr, envir, enclos) +#> 35 eval(expr, envir, enclos) +#> 36 broken_delayed$compute() +#> 37 scheduler$compute() +#> 38 self$compute_step() +#> 39 job_type$new(current_task) +#> 40 initialize(...) +#> 41 future(expr = quote(eval_delayed(to_eval, timeout)), substitute = FALSE, gl +#> 42 makeFuture(expr, substitute = FALSE, envir = envir, globals = globals, pack +#> 43 sequential(expr, envir = envir, substitute = FALSE, lazy = lazy, seed = see +#> 44 run(future) +#> 45 run.UniprocessFuture(future) +#> 46 eval(expr, envir = envir, enclos = baseenv()) +#> 47 eval(expr, envir = envir, enclos = baseenv()) +#> 48 base::tryCatch({ +#> base::withCallingHandlers({ +#> ...future. +#> 49 tryCatchList(expr, classes, parentenv, handlers) +#> 50 tryCatchOne(expr, names, parentenv, handlers[[1]]) +#> 51 doTryCatch(return(expr), name, parentenv, handler) +#> 52 base::withCallingHandlers({ +#> ...future.value <- base::withVisible(ba +#> 53 base::withVisible(base::local(eval_delayed(to_eval, timeout))) +#> 54 base::local(eval_delayed(to_eval, timeout)) +#> 55 eval.parent(substitute(eval(quote(expr), envir))) +#> 56 eval(expr, p) +#> 57 eval(expr, p) +#> 58 eval(quote(eval_delayed(to_eval, timeout)), new.env()) +#> 59 eval(quote(eval_delayed(to_eval, timeout)), new.env()) +#> 60 eval_delayed(to_eval, timeout) +#> 61 tryCatchLog::tryCatchLog({ +#> result <- rlang::eval_bare(expr = to_eva +#> 62 tryCatch(withCallingHandlers(expr, condition = cond.handler), ..., finally +#> 63 tryCatchList(expr, classes, parentenv, handlers) +#> 64 withCallingHandlers(expr, condition = cond.handler) +#> 65 rlang::eval_bare(expr = to_eval$expr, env = to_eval$env) +#> 66 stop("this is an error") +#> 67 .handleSimpleError(function (c) +#> { +#> log.message <- c$message +#> +#> +#>
    - @@ -165,7 +257,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 4801fe2..ea9befa 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -63,7 +67,7 @@ - +
    @@ -134,6 +138,11 @@

    + + +

    + + + + + @@ -187,11 +202,10 @@

    -

    Contents

    -
    + @@ -202,7 +216,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/make_graph.html b/docs/reference/make_graph.html index 248fe98..24e1a01 100644 --- a/docs/reference/make_graph.html +++ b/docs/reference/make_graph.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -37,7 +41,6 @@ - @@ -65,7 +68,7 @@ - +
    @@ -119,7 +122,7 @@
    @@ -127,7 +130,7 @@

    Graphical Representation of a Task Dependency Structure

    Graphical Representation of a Task Dependency Structure

    -
    make_graph(delayed_object, graph = NULL, level = 1)
    +
    make_graph(delayed_object, graph = NULL, level = 1)

    Arguments

    @@ -166,6 +175,12 @@

    eval_delayed()

    +

    Helper Function to Evaluate Delayed

    find_delayed_error()

    @@ -148,12 +151,10 @@

    Arg - @@ -164,7 +165,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/plot.Delayed.html b/docs/reference/plot.Delayed.html index 1d6f757..f6cb7e0 100644 --- a/docs/reference/plot.Delayed.html +++ b/docs/reference/plot.Delayed.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -37,7 +41,6 @@ - @@ -65,7 +68,7 @@ - +
    @@ -119,7 +122,7 @@
    @@ -128,7 +131,7 @@

    Plot Method for Delayed Objects

    # S3 method for Delayed
    -plot(x, color = TRUE, height = "500px", width = "100%", ...)
    +plot(x, color = TRUE, height = "500px", width = "100%", ...)

    Arguments

    @@ -159,23 +162,21 @@

    Arg

    Examples

    -
    adder <- function(x, y) { - x + y -} -delayed_adder <- delayed_fun(adder) -z <- delayed_adder(3, 4) -z2 <- delayed_adder(z, 4) -z2$sequential <- TRUE -z3 <- delayed_adder(z2, z) -plot(z3)
    +
    adder <- function(x, y) { + x + y +} +delayed_adder <- delayed_fun(adder) +z <- delayed_adder(3, 4) +z2 <- delayed_adder(z, 4) +z2$sequential <- TRUE +z3 <- delayed_adder(z2, z) +plot(z3) +
    - @@ -186,7 +187,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/plot_delayed_shiny.html b/docs/reference/plot_delayed_shiny.html index c0f7d93..fef173d 100644 --- a/docs/reference/plot_delayed_shiny.html +++ b/docs/reference/plot_delayed_shiny.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -37,7 +41,6 @@ - @@ -65,7 +68,7 @@ - +
    @@ -119,7 +122,7 @@
    @@ -127,7 +130,7 @@

    Animated Representation a Task Dependency Structure

    uses shiny

    -
    plot_delayed_shiny(scheduler)
    +
    plot_delayed_shiny(scheduler)

    Arguments

    @@ -140,25 +143,24 @@

    Arg

    Examples

    -
    if (FALSE) { -adder <- function(x, y) { - x + y -} -delayed_adder <- delayed_fun(adder) -z <- delayed_adder(3, 4) -z2 <- delayed_adder(z, 4) -z2$sequential <- TRUE -z3 <- delayed_adder(z2, z) -plot_delayed_shiny(z3) -}
    +
    if (FALSE) { +adder <- function(x, y) { + x + y +} +delayed_adder <- delayed_fun(adder) +z <- delayed_adder(3, 4) +z2 <- delayed_adder(z, 4) +z2$sequential <- TRUE +z3 <- delayed_adder(z2, z) +plot_delayed_shiny(z3) +} + +
    - @@ -169,7 +171,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 6c1436f..a0fef3d 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -24,6 +24,9 @@ http://tlverse.org/delayed/reference/delayed.html + + http://tlverse.org/delayed/reference/eval_delayed.html + http://tlverse.org/delayed/reference/find_delayed_error.html diff --git a/man/delayed_traceback.Rd b/man/delayed_traceback.Rd new file mode 100644 index 0000000..04455d7 --- /dev/null +++ b/man/delayed_traceback.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/logging_helpers.R +\name{delayed_traceback} +\alias{delayed_traceback} +\title{Get traceback for last delayed error} +\usage{ +delayed_traceback(call_stack = NULL, cat = TRUE) +} +\arguments{ +\item{call_stack}{a call stack argument (defaults to last delayed error)} + +\item{cat}{if TRUE, uses cat to print the traceback} +} +\description{ +Get traceback for last delayed error +} diff --git a/man/eval_delayed.Rd b/man/eval_delayed.Rd index 65ae7ed..10a76ba 100644 --- a/man/eval_delayed.Rd +++ b/man/eval_delayed.Rd @@ -4,12 +4,14 @@ \alias{eval_delayed} \title{Helper Function to Evaluate Delayed} \usage{ -eval_delayed(to_eval, timeout = Inf) +eval_delayed(to_eval, timeout = Inf, name = "") } \arguments{ \item{to_eval}{a list as generated from Delayed$prepare_eval()} \item{timeout}{a timeout indicating when to terminate the job} + +\item{name}{the name of the delayed object (used for logging output)} } \description{ Helper Function to Evaluate Delayed diff --git a/tests/testthat/test_Delayed.R b/tests/testthat/test-Delayed.R similarity index 100% rename from tests/testthat/test_Delayed.R rename to tests/testthat/test-Delayed.R diff --git a/tests/testthat/test_benchmark.R b/tests/testthat/test-benchmark.R similarity index 91% rename from tests/testthat/test_benchmark.R rename to tests/testthat/test-benchmark.R index a14caea..6c8ddd9 100644 --- a/tests/testthat/test_benchmark.R +++ b/tests/testthat/test-benchmark.R @@ -1,4 +1,5 @@ library(future) +library(data.table) adder <- function(x, y) { Sys.sleep(2) x + y @@ -21,7 +22,7 @@ time_sequential <- system.time({ }) # test runtime logging -expect_equivalent(time_sequential[[3]],big_adder$runtime, tol=0.1) +expect_equivalent(time_sequential[[3]], big_adder$runtime, tol = 0.1) nworkers <- 2 big_adder <- make_adder_list() diff --git a/tests/testthat/test_error_handling.R b/tests/testthat/test-error_handling.R similarity index 96% rename from tests/testthat/test_error_handling.R rename to tests/testthat/test-error_handling.R index c765e6c..22c32bc 100644 --- a/tests/testthat/test_error_handling.R +++ b/tests/testthat/test-error_handling.R @@ -1,8 +1,6 @@ -library(delayed) library(testthat) library(future) context("Delayed Error Handling") - delayed_error <- delayed_fun(stop) error_message <- "this is an error" diff --git a/tests/testthat/test_make_graph.R b/tests/testthat/test-make_graph.R similarity index 100% rename from tests/testthat/test_make_graph.R rename to tests/testthat/test-make_graph.R diff --git a/tests/testthat/test_seed.R b/tests/testthat/test-seed.R similarity index 100% rename from tests/testthat/test_seed.R rename to tests/testthat/test-seed.R diff --git a/tests/testthat/test_timeout.R b/tests/testthat/test-timeout.R similarity index 100% rename from tests/testthat/test_timeout.R rename to tests/testthat/test-timeout.R