Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions R/run_ML.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions tests/testthat/test-run-modeling-pipeline-intense.R
Original file line number Diff line number Diff line change
@@ -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))
})