Skip to content

Commit

Permalink
kill
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Aug 16, 2024
1 parent 9248840 commit d44f08d
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion inst/testthat/helper_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_ArchiveAsyncTuning.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_AutoTuner.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_TunerAsyncDesignPoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
2 changes: 1 addition & 1 deletion tests/testthat/test_TunerAsyncGridSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
2 changes: 1 addition & 1 deletion tests/testthat/test_TunerAsyncRandomSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})


12 changes: 6 additions & 6 deletions tests/testthat/test_TuningInstanceAsyncMultiCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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", {
Expand All @@ -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", {
Expand Down Expand Up @@ -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", {
Expand All @@ -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", {
Expand Down Expand Up @@ -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")
})
16 changes: 7 additions & 9 deletions tests/testthat/test_TuningInstanceAsyncSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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", {
Expand All @@ -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", {
Expand All @@ -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", {
Expand All @@ -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", {
Expand All @@ -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", {
Expand Down Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_mlr_callbacks.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------
Expand Down

0 comments on commit d44f08d

Please sign in to comment.