Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mlr-org/rush
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed May 21, 2024
2 parents 25dd8c7 + ffd2013 commit 0ab5a77
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 117 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ jobs:
limit-access-to-actor: true

- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-manual")' # "--as-cran" prevents to start external processes
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export(assert_rush_workers)
export(assert_rushs)
export(get_hostname)
export(heartbeat)
export(remove_rush_plan)
export(rsh)
export(rush_available)
export(rush_config)
Expand Down
2 changes: 1 addition & 1 deletion R/Rush.R
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ Rush = R6::R6Class("Rush",
wait_for_workers = function(n, timeout = Inf) {
assert_count(n)
assert_number(timeout)
timeout = if (is.finite(timeout)) timeout else rush_config()$start_worker_timeout
timeout = if (is.finite(timeout)) timeout else rush_config()$start_worker_timeout %??% Inf

start_time = Sys.time()
while(self$n_workers < n) {
Expand Down
13 changes: 13 additions & 0 deletions R/rush_plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#' If `NULL`, the `REDIS_URL` environment variable is parsed.
#' If `REDIS_URL` is not set, a default configuration is used.
#' See [redux::redis_config] for details.
#' @param start_worker_timeout (`numeric(1)`)\cr
#' The time in seconds to wait for a worker to start.
#'
#' @template param_n_workers
#' @template param_lgr_thresholds
Expand Down Expand Up @@ -55,6 +57,17 @@ rush_config = function() {
start_worker_timeout = rush_env$start_worker_timeout)
}

#' @title Remove Rush Plan
#'
#' @description
#' Removes the rush plan that was set by [rush_plan()].
#'
#' @export
remove_rush_plan = function() {
rm(list = ls(envir = rush_env), envir = rush_env)
invisible(NULL)
}

#' @title Rush Available
#'
#' @description
Expand Down
10 changes: 9 additions & 1 deletion man/Rush.Rd

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

11 changes: 11 additions & 0 deletions man/remove_rush_plan.Rd

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

6 changes: 5 additions & 1 deletion man/rush_plan.Rd

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

1 change: 1 addition & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ reference:
- rush_plan
- rush_available
- rush_config
- remove_rush_plan
- title: Worker Loop
contents:
- start_worker
Expand Down
11 changes: 0 additions & 11 deletions tests/testthat/_snaps/Rush.md

This file was deleted.

3 changes: 1 addition & 2 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ expect_rush_task = function(task) {
}

expect_rush_reset = function(rush, type = "kill") {
remove_rush_plan()
processes = rush$processes
rush$reset(type = type)
expect_list(rush$connector$command(c("KEYS", "*")), len = 0)
walk(processes, function(p) p$kill())
}

lg$set_threshold("debug")
13 changes: 13 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
old_opts = options(
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE,
warnPartialMatchDollar = TRUE
)

# https://github.com/HenrikBengtsson/Wishlist-for-R/issues/88
old_opts = lapply(old_opts, function(x) if (is.null(x)) FALSE else x)

lg_rush = lgr::get_logger("rush")
old_threshold_rush = lg_rush$threshold
lg_rush$set_threshold(0)

2 changes: 2 additions & 0 deletions tests/testthat/teardown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
options(old_opts)
lg_rush$set_threshold(old_threshold_rush)
Loading

0 comments on commit 0ab5a77

Please sign in to comment.