Skip to content

Commit

Permalink
compatibility with old versions of plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 28, 2025
1 parent e4b5294 commit 1be72d5
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 4 deletions.
55 changes: 53 additions & 2 deletions R/crew_launcher.R
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,20 @@ crew_class_launcher <- R6::R6Class(
#' help create custom launchers.
#' @return Character string with a call to [crew_worker()].
#' @param worker Character string, name of the worker.
#' @param socket Deprecated on 2025-01-28 (`crew` version 1.0.0).
#' @param launcher Deprecated on 2025-01-28 (`crew` version 1.0.0).
#' @param instance Deprecated on 2025-01-28 (`crew` version 1.0.0).
#' @examples
#' launcher <- crew_launcher_local()
#' launcher$start(url = "tcp://127.0.0.1:57000", profile = "profile")
#' launcher$call(worker = "worker_name")
#' launcher$terminate()
call = function(worker) {
call = function(
worker,
socket = NULL,
launcher = NULL,
instance = NULL
) {
call <- substitute(
crew::crew_worker(
settings = settings,
Expand All @@ -575,8 +583,20 @@ crew_class_launcher <- R6::R6Class(
#' @description Start the launcher.
#' @param url Character string, websocket URL for worker connections.
#' @param profile Character string, `mirai` compute profile.
#' @param sockets Deprecated on 2025-01-28 (`crew` version 1.0.0).
#' @return `NULL` (invisibly).
start = function(url, profile) {
start = function(url = NULL, profile = NULL, sockets = NULL) {
crew::crew_deprecate(
name = "sockets",
date = "2025-01-28",
version = "1.0.0",
alternative = "url and profile",
condition = "message",
value = sockets,
skip_cran = TRUE
)
url <- url %|||% sockets[1L]
profile <- profile %|||% crew_random_name()
if (!is.null(private$.async)) {
private$.async$terminate()
}
Expand Down Expand Up @@ -736,6 +756,37 @@ crew_class_launcher <- R6::R6Class(
mirai_wait(tasks = tasks, launching = FALSE)
private$.instances <- launcher_empty_instances
invisible()
},
#' @description Deprecated on 2025-01-28 (`crew` version 1.0.0).
#' @param index Unused argument.
#' @return The integer 1, for compatibility.
crashes = function(index = NULL) {
crew_deprecate(
name = "crashes() method in crew launchers",
date = "2025-01-28",
version = "1.0.0",
alternative = "none",
condition = "message",
value = "x",
skip_cran = TRUE
)
1L
},
#' @description Deprecated on 2025-01-28 (`crew` version 1.0.0).
#' @param name Name to set for the launcher.
#' @return `NULL` (invisibly).
set_name = function(name) {
crew_deprecate(
name = "crashes() method in crew launchers",
date = "2025-01-28",
version = "1.0.0",
alternative = "none",
condition = "message",
value = "x",
skip_cran = TRUE
)
private$.name <- name
invisible()
}
)
)
59 changes: 57 additions & 2 deletions man/crew_class_launcher.Rd

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

2 changes: 2 additions & 0 deletions man/crew_class_launcher_local.Rd

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

11 changes: 11 additions & 0 deletions tests/testthat/test-crew_launcher.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,14 @@ crew_test("deprecate seconds_exit", {
suppressWarnings(crew_launcher(seconds_exit = 1))
expect_true(TRUE)
})

crew_test("deprecated crashes() method", {
x <- crew_launcher_local()
expect_equal(x$crashes(index = 1L), 1L)
})

crew_test("deprecated set_name() method", {
x <- crew_launcher_local(name = "x")
x$set_name(name = "y")
expect_equal(x$name, "y")
})

0 comments on commit 1be72d5

Please sign in to comment.