Skip to content

Commit c6cabfc

Browse files
committed
feat: reconnect to redis method
1 parent 8c4a4a2 commit c6cabfc

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Suggests:
5050
rpart,
5151
testthat (>= 3.0.0),
5252
xgboost
53+
Remotes:
54+
mlr-org/bbotk
5355
VignetteBuilder:
5456
knitr
5557
Config/testthat/edition: 3

tests/testthat/test_ArchiveAsyncTuning.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,35 @@ test_that("ArchiveAsyncTuning as.data.table function works with switched new ids
226226
expect_rush_reset(instance$rush)
227227
})
228228

229+
test_that("Saving ArchiveAsyncTuning works", {
230+
skip_on_cran()
231+
skip_if_not_installed("rush")
232+
flush_redis()
233+
234+
on.exit({
235+
file.remove("instance.rds")
236+
})
237+
238+
rush::rush_plan(n_workers = 2)
239+
instance = ti_async(
240+
task = tsk("pima"),
241+
learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1)),
242+
resampling = rsmp("cv", folds = 3),
243+
measures = msr("classif.ce"),
244+
terminator = trm("evals", n_evals = 20),
245+
store_benchmark_result = TRUE
246+
)
247+
tuner = tnr("async_random_search")
248+
tuner$optimize(instance)
249+
250+
saveRDS(instance, file = "instance.rds")
251+
252+
loaded_instance = readRDS(file = "instance.rds")
253+
254+
loaded_instance$reconnect()
255+
loaded_instance
256+
})
257+
229258
# Internal Tuning --------------------------------------------------------------
230259

231260
test_that("ArchiveAsyncTuning as.data.table function works internally tuned values", {
@@ -254,3 +283,4 @@ test_that("ArchiveAsyncTuning as.data.table function works internally tuned valu
254283
expect_names(names(tab), must.include = "internal_tuned_values_iter")
255284
expect_equal(tab$internal_tuned_values_iter[1], 99)
256285
})
286+

0 commit comments

Comments
 (0)