Skip to content

Commit

Permalink
feat: add elements to rush_config
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Apr 3, 2024
1 parent 8291876 commit e99400f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 4 additions & 9 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ get_hostname = function() {
host = Sys.info()["nodename"]
host = host[host != ""]
if (length(host) == 0) {
host <- readLines(pipe("/usr/bin/env uname -n"))
host = readLines(pipe("/usr/bin/env uname -n"))
}
}
host[1]
Expand All @@ -42,15 +42,18 @@ with_rng_state = function(fun, args, seed) {
mlr3misc::invoke(fun, .args = args)
}

# checks if a seed is a valid L'Ecuyer-CMRG seed
is_lecyer_cmrg_seed = function(seed) {
is.numeric(seed) && length(seed) == 7L && all(is.finite(seed)) && (seed[1] %% 10000L == 407L)
}

# get the current RNG state
get_random_seed = function() {
env = globalenv()
env$.Random.seed
}

# set the RNG state
set_random_seed = function(seed, kind = NULL) {
env = globalenv()
old_seed = env$.Random.seed
Expand All @@ -77,11 +80,3 @@ safe_bin_to_object = function(bin) {
if (is.null(bin)) return(NULL)
redux::bin_to_object(bin)
}

is_retriable = function(task) {
if (is.null(task$max_retries)) return(FALSE)
assert_int(task$max_retries)
assert_int(task$n_failures, null.ok = TRUE)

task$max_retries > task$n_failures %??% 0
}
11 changes: 7 additions & 4 deletions R/rush_plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ rush_plan = function(n_workers, config = NULL, lgr_thresholds = NULL, large_obje
#' @title Get Rush Config
#'
#' @description
#' Returns the redis config file ([redux::redis_config]) that was set by [rush_plan()].
#' Returns the rush config that was set by [rush_plan()].
#'
#' @return [redux::redis_config()]\cr
#' A redis config file.
#' @return `list(4)`
#'
#' @export
rush_config = function() {
list(config = rush_env$config, n_workers = rush_env$n_workers)
list(
config = rush_env$config,
n_workers = rush_env$n_workers,
lgr_thresholds = rush_env$lgr_thresholds,
large_objects_path = rush_env$large_objects_path)
}

#' @title Rush Available
Expand Down

0 comments on commit e99400f

Please sign in to comment.