Skip to content

Commit

Permalink
CLEANUP: Remove also finished() and status(), cf. Issue #58
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Jan 2, 2021
1 parent e64b55b commit defe3b7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 66 deletions.
4 changes: 0 additions & 4 deletions NAMESPACE
@@ -1,15 +1,13 @@
# Generated by roxygen2: do not edit by hand

S3method(delete,BatchtoolsFuture)
S3method(finished,BatchtoolsFuture)
S3method(loggedError,BatchtoolsFuture)
S3method(loggedOutput,BatchtoolsFuture)
S3method(nbrOfWorkers,batchtools)
S3method(print,BatchtoolsFuture)
S3method(resolved,BatchtoolsFuture)
S3method(result,BatchtoolsFuture)
S3method(run,BatchtoolsFuture)
S3method(status,BatchtoolsFuture)
export("%resources%")
export(BatchtoolsFuture)
export(BatchtoolsFutureError)
Expand All @@ -22,10 +20,8 @@ export(batchtools_openlava)
export(batchtools_sge)
export(batchtools_slurm)
export(batchtools_torque)
export(finished)
export(loggedError)
export(loggedOutput)
export(status)
importFrom(batchtools,batchExport)
importFrom(batchtools,batchMap)
importFrom(batchtools,clearRegistry)
Expand Down
8 changes: 4 additions & 4 deletions NEWS
Expand Up @@ -8,8 +8,8 @@ SIGNIFICANT CHANGES:
* Lazy batchtools futures only creates the internal batchtools registry when
the future is launched.

* Removed S3 generic await(), which is a function that was only used for
internal purposes.
* Removed S3 generic functions await(), finished(), and status(), which were
functions that were used for internal purposes.

DOCUMENTATION:

Expand All @@ -23,8 +23,8 @@ BUG FIXES:

DEPRECATED AND DEFUNCT:

* Removed S3 generic await(), which is a function that was only used for
internal purposes.
* Removed S3 generic functions await(), finished(), and status(), which were
functions that were used for internal purposes.


Version: 0.9.0 [2020-04-14]
Expand Down
71 changes: 22 additions & 49 deletions R/BatchtoolsFuture-class.R
Expand Up @@ -187,29 +187,8 @@ print.BatchtoolsFuture <- function(x, ...) {
}


status <- function(...) UseMethod("status")
finished <- function(...) UseMethod("finished")
loggedError <- function(...) UseMethod("loggedError")
loggedOutput <- function(...) UseMethod("loggedOutput")

#' Status of batchtools future
#'
#' @param future The future.
#' @param \ldots Not used.
#'
#' @return A character vector or a logical scalar.
#'
#' @aliases status finished result
#' loggedError loggedOutput
#' @keywords internal
#'
#' @export
#' @export status
#' @export finished
#' @export loggedError
#' @export loggedOutput
#' @importFrom batchtools getStatus
status.BatchtoolsFuture <- function(future, ...) {
status <- function(future, ...) {
debug <- getOption("future.debug", FALSE)
if (debug) {
mdebug("status() for ", class(future)[1], " ...")
Expand Down Expand Up @@ -258,16 +237,32 @@ status.BatchtoolsFuture <- function(future, ...) {
}


#' @export
#' @keywords internal
finished.BatchtoolsFuture <- function(future, ...) {
finished <- function(future, ...) {
status <- status(future)
if (is_na(status)) return(NA)
any(c("finished", "error", "expired") %in% status)
}

#' @export


#' Logged output of batchtools future
#'
#' @param future The future.
#' @param \ldots Not used.
#'
#' @return A character vector or a logical scalar.
#'
#' @aliases loggedOutput loggedError
#'
#' @export loggedError
#' @export loggedOutput
#' @keywords internal
loggedOutput <- function(...) UseMethod("loggedOutput")
loggedError <- function(...) UseMethod("loggedError")


#' @importFrom batchtools getErrorMessages
#' @export
loggedError.BatchtoolsFuture <- function(future, ...) {
stat <- status(future)
if (is_na(stat)) return(NULL)
Expand All @@ -294,7 +289,6 @@ loggedError.BatchtoolsFuture <- function(future, ...) {

#' @importFrom batchtools getLog
#' @export
#' @keywords internal
loggedOutput.BatchtoolsFuture <- function(future, ...) {
stat <- status(future)
if (is_na(stat)) return(NULL)
Expand Down Expand Up @@ -502,29 +496,8 @@ run.BatchtoolsFuture <- function(future, ...) {
} ## run()


#' Awaits the value of a batchtools future
#'
#' @param future The future.
#' @param cleanup If TRUE, the registry is completely removed upon
#' success, otherwise not.
#' @param timeout Total time (in seconds) waiting before generating an error.
#' @param delta The number of seconds to wait between each poll.
#' @param alpha A factor to scale up the waiting time in each iteration such
#' that the waiting time in the k:th iteration is `alpha ^ k * delta`.
#' @param \ldots Not used.
#'
#' @return The value of the evaluated expression.
#' If an error occurs, an informative Exception is thrown.
#'
#' @details
#' Note that `await()` should only be called once, because
#' after being called the actual asynchronous future may be removed
#' and will no longer available in subsequent calls. If called
#' again, an error may be thrown.
#'
#' @importFrom batchtools getErrorMessages loadResult waitForJobs
#' @importFrom batchtools loadResult waitForJobs
#' @importFrom utils tail
#' @keywords internal
await <- function(future, cleanup = TRUE,
timeout = getOption("future.wait.timeout", 30 * 24 * 60 * 60),
delta = getOption("future.wait.interval", 1.0),
Expand Down
14 changes: 5 additions & 9 deletions man/status.BatchtoolsFuture.Rd → man/loggedOutput.Rd

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

0 comments on commit defe3b7

Please sign in to comment.