From d44f08dde992078fb967089c6ccf0a05fd4132b1 Mon Sep 17 00:00:00 2001 From: be-marc Date: Fri, 16 Aug 2024 12:23:52 +0200 Subject: [PATCH] kill --- inst/testthat/helper_misc.R | 2 +- tests/testthat/test_ArchiveAsyncTuning.R | 2 +- tests/testthat/test_AutoTuner.R | 2 +- tests/testthat/test_TunerAsyncDesignPoints.R | 2 +- tests/testthat/test_TunerAsyncGridSearch.R | 2 +- tests/testthat/test_TunerAsyncRandomSearch.R | 2 +- .../testthat/test_TuningInstanceAsyncMultiCrit.R | 12 ++++++------ .../test_TuningInstanceAsyncSingleCrit.R | 16 +++++++--------- tests/testthat/test_mlr_callbacks.R | 2 +- 9 files changed, 20 insertions(+), 22 deletions(-) diff --git a/inst/testthat/helper_misc.R b/inst/testthat/helper_misc.R index e9e27841..ea09e459 100644 --- a/inst/testthat/helper_misc.R +++ b/inst/testthat/helper_misc.R @@ -149,7 +149,7 @@ flush_redis = function() { expect_rush_reset = function(rush, type = "kill") { processes = rush$processes rush$reset(type = type) - Sys.sleep(2) + Sys.sleep(1) keys = rush$connector$command(c("KEYS", "*")) if (!test_list(keys, len = 0)) { stopf("Found keys in redis after reset: %s", keys) diff --git a/tests/testthat/test_ArchiveAsyncTuning.R b/tests/testthat/test_ArchiveAsyncTuning.R index 53c063b7..2ba30723 100644 --- a/tests/testthat/test_ArchiveAsyncTuning.R +++ b/tests/testthat/test_ArchiveAsyncTuning.R @@ -48,7 +48,7 @@ test_that("ArchiveAsyncTuning access methods work", { expect_resample_result(instance$archive$resample_result(i)) }) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("ArchiveAsyncTuning as.data.table function works", { diff --git a/tests/testthat/test_AutoTuner.R b/tests/testthat/test_AutoTuner.R index b2d3799b..140b02b4 100644 --- a/tests/testthat/test_AutoTuner.R +++ b/tests/testthat/test_AutoTuner.R @@ -634,7 +634,7 @@ test_that("AutoTuner works with async tuner", { expect_data_table(at$tuning_instance$result, nrows = 1) expect_data_table(at$tuning_instance$archive$data, min.rows = 4) - expect_rush_reset(at$tuning_instance$rush, type = "terminate") + expect_rush_reset(at$tuning_instance$rush, type = "kill") }) # Internal Tuning -------------------------------------------------------------- diff --git a/tests/testthat/test_TunerAsyncDesignPoints.R b/tests/testthat/test_TunerAsyncDesignPoints.R index ca088bf1..c206c943 100644 --- a/tests/testthat/test_TunerAsyncDesignPoints.R +++ b/tests/testthat/test_TunerAsyncDesignPoints.R @@ -22,5 +22,5 @@ test_that("TunerAsyncDesignPoints works", { expect_data_table(tuner$optimize(instance), nrows = 1) expect_data_table(instance$archive$data, nrows = 2) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) diff --git a/tests/testthat/test_TunerAsyncGridSearch.R b/tests/testthat/test_TunerAsyncGridSearch.R index e2dba5ed..869d00d9 100644 --- a/tests/testthat/test_TunerAsyncGridSearch.R +++ b/tests/testthat/test_TunerAsyncGridSearch.R @@ -21,5 +21,5 @@ test_that("TunerAsyncGridSearch works", { expect_data_table(tuner$optimize(instance), nrows = 1) expect_data_table(instance$archive$data, nrows = 100) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) diff --git a/tests/testthat/test_TunerAsyncRandomSearch.R b/tests/testthat/test_TunerAsyncRandomSearch.R index 181bc035..4aec6d92 100644 --- a/tests/testthat/test_TunerAsyncRandomSearch.R +++ b/tests/testthat/test_TunerAsyncRandomSearch.R @@ -21,7 +21,7 @@ test_that("TunerAsyncRandomSearch works", { expect_data_table(tuner$optimize(instance), nrows = 1) expect_data_table(instance$archive$data, min.rows = 20) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) diff --git a/tests/testthat/test_TuningInstanceAsyncMultiCrit.R b/tests/testthat/test_TuningInstanceAsyncMultiCrit.R index 6f3d256a..1d622160 100644 --- a/tests/testthat/test_TuningInstanceAsyncMultiCrit.R +++ b/tests/testthat/test_TuningInstanceAsyncMultiCrit.R @@ -21,7 +21,7 @@ test_that("initializing TuningInstanceAsyncSingleCrit works", { expect_r6(instance$rush, "Rush") expect_null(instance$result) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("rush controller can be passed to TuningInstanceAsyncSingleCrit", { @@ -44,7 +44,7 @@ test_that("rush controller can be passed to TuningInstanceAsyncSingleCrit", { expect_class(instance$rush, "Rush") expect_equal(instance$rush$network_id, "remote_network") - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("TuningInstanceAsyncSingleCrit can be passed to a tuner", { @@ -66,7 +66,7 @@ test_that("TuningInstanceAsyncSingleCrit can be passed to a tuner", { tuner$optimize(instance) expect_data_table(instance$archive$data, min.rows = 3L) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("assigning a result to TuningInstanceAsyncSingleCrit works", { @@ -114,7 +114,7 @@ test_that("saving the benchmark result with TuningInstanceRushSingleCrit works", expect_gte(instance$archive$benchmark_result$n_resample_results, 3L) expect_null(instance$archive$resample_result(1)$learners[[1]]$model) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("saving the models with TuningInstanceRushSingleCrit works", { @@ -141,7 +141,7 @@ test_that("saving the models with TuningInstanceRushSingleCrit works", { expect_gte(instance$archive$benchmark_result$n_resample_results, 3L) expect_class(instance$archive$resample_result(1)$learners[[1]]$model, "rpart") - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) # test_that("crashing workers are detected", { @@ -223,5 +223,5 @@ test_that("Multi-crit internal tuning works", { map_int(instance$archive$data$internal_tuned_values, "iter")[1:20] ) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) diff --git a/tests/testthat/test_TuningInstanceAsyncSingleCrit.R b/tests/testthat/test_TuningInstanceAsyncSingleCrit.R index fbd009d9..83b73652 100644 --- a/tests/testthat/test_TuningInstanceAsyncSingleCrit.R +++ b/tests/testthat/test_TuningInstanceAsyncSingleCrit.R @@ -20,7 +20,7 @@ test_that("initializing TuningInstanceAsyncSingleCrit works", { expect_r6(instance$rush, "Rush") expect_null(instance$result) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("rush controller can be passed to TuningInstanceAsyncSingleCrit", { @@ -41,7 +41,7 @@ test_that("rush controller can be passed to TuningInstanceAsyncSingleCrit", { expect_class(instance$rush, "Rush") expect_equal(instance$rush$network_id, "remote_network") - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("TuningInstanceAsyncSingleCrit can be passed to a tuner", { @@ -63,7 +63,7 @@ test_that("TuningInstanceAsyncSingleCrit can be passed to a tuner", { tuner$optimize(instance) expect_data_table(instance$archive$data, min.rows = 3L) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("assigning a result to TuningInstanceAsyncSingleCrit works", { @@ -87,7 +87,7 @@ test_that("assigning a result to TuningInstanceAsyncSingleCrit works", { result = instance$result expect_data_table(result, nrows = 1) expect_names(names(result), must.include = c("cp", "learner_param_vals", "x_domain", "classif.ce")) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("saving the benchmark result with TuningInstanceRushSingleCrit works", { @@ -112,7 +112,7 @@ test_that("saving the benchmark result with TuningInstanceRushSingleCrit works", expect_benchmark_result(instance$archive$benchmark_result) expect_gte(instance$archive$benchmark_result$n_resample_results, 3L) expect_null(instance$archive$resample_result(1)$learners[[1]]$model) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("saving the models with TuningInstanceRushSingleCrit works", { @@ -138,7 +138,7 @@ test_that("saving the models with TuningInstanceRushSingleCrit works", { expect_benchmark_result(instance$archive$benchmark_result) expect_gte(instance$archive$benchmark_result$n_resample_results, 3L) expect_class(instance$archive$resample_result(1)$learners[[1]]$model, "rpart") - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) # test_that("crashing workers are detected", { @@ -186,13 +186,11 @@ test_that("Async single-crit internal tuning works", { as.data.table(instance$archive) - message(instance$archive$data$internal_tuned_values) - expect_list(instance$archive$data$internal_tuned_values, min.len = 20, types = "list") expect_equal(instance$archive$data$internal_tuned_values[[1]], list(iter = 99)) expect_false(instance$result_learner_param_vals$early_stopping) expect_equal(instance$result_learner_param_vals$iter, 99) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) test_that("Internal tuning throws an error on incorrect configuration", { diff --git a/tests/testthat/test_mlr_callbacks.R b/tests/testthat/test_mlr_callbacks.R index 2e74979a..4340e17e 100644 --- a/tests/testthat/test_mlr_callbacks.R +++ b/tests/testthat/test_mlr_callbacks.R @@ -55,7 +55,7 @@ test_that("async measures callback works", { expect_numeric(instance$archive$data$classif.ce_holdout) - expect_rush_reset(instance$rush, type = "terminate") + expect_rush_reset(instance$rush, type = "kill") }) # async mlflow callback --------------------------------------------------------