diff --git a/R/run_ML.R b/R/run_ML.R index bb9e534..f143a41 100644 --- a/R/run_ML.R +++ b/R/run_ML.R @@ -1429,16 +1429,16 @@ runModelingPipelineIntense <- function(parquet_dir, # ------------------------------- # [1] Generate inputs # ------------------------------- - # safe_run( -# "[1] Generating ML feature matrices", -# generateMLInputs, - # parquet_dir = parquet_dir, - # out_path = out_root, - # n_fold = n_fold, - # split = split, - # min_n = min_n, - # verbosity = if (verbose) "minimal" else "debug" - # ) + safe_run( + "[1] Generating ML feature matrices", + generateMLInputs, + parquet_dir = parquet_dir, + out_path = out_root, + n_fold = n_fold, + split = split, + min_n = min_n, + verbosity = if (verbose) "minimal" else "debug" + ) # ------------------------------- # Seed loop diff --git a/tests/testthat/test-run-modeling-pipeline-intense.R b/tests/testthat/test-run-modeling-pipeline-intense.R new file mode 100644 index 0000000..fe196a9 --- /dev/null +++ b/tests/testthat/test-run-modeling-pipeline-intense.R @@ -0,0 +1,33 @@ +# Unit test for runModelingPipelineIntense()'s control flow. Mocks out the +# heavy steps (matrix generation, model training) so this stays fast and only +# checks that the wrapper actually calls them in order, rather than exercising +# real matrix generation / model fitting (already covered elsewhere). + +test_that("runModelingPipelineIntense() generates matrices before training", { + tmp_root <- withr::local_tempdir() + parquet_dir <- file.path(tmp_root, "Test_species") + dir.create(parquet_dir) + + generate_calls <- list() + local_mocked_bindings( + generateMLInputs = function(...) { + generate_calls[[length(generate_calls) + 1]] <<- list(...) + invisible(NULL) + }, + runMLmodels = function(...) invisible(NULL), + runMDRmodels = function(...) invisible(NULL) + ) + + runModelingPipelineIntense( + parquet_dir = parquet_dir, + n_seeds = 1, + verbose = FALSE + ) + + # The matrix-generation step must actually run (regression test: this step + # was previously commented out, so every later step silently had nothing + # to work with). + expect_length(generate_calls, 1) + expect_equal(generate_calls[[1]]$parquet_dir, normalizePath(parquet_dir)) + expect_equal(generate_calls[[1]]$out_path, normalizePath(tmp_root)) +})