Skip to content

Proper .config values with parallel_over = "everything" #1049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2025
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
4 changes: 4 additions & 0 deletions R/loop_over_all_stages-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
make_static <- function(
workflow,
param_info,
grid,
metrics,
eval_time,
split_args,
Expand All @@ -26,9 +27,12 @@ make_static <- function(
cli::cli_abort("{.arg eval_time} should be a numeric vector.")
}

configs <- get_config_key(grid, workflow)

list(
wflow = workflow,
param_info = param_info,
configs = configs,
post_estimation = workflows::.workflow_includes_calibration(workflow),
metrics = metrics,
metric_info = tibble::as_tibble(metrics),
Expand Down
17 changes: 7 additions & 10 deletions R/loop_over_all_stages.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ loop_over_all_stages <- function(resamples, grid, static) {

sched <- schedule_grid(grid, static$wflow)

config_tbl <- get_config_key(grid, static$wflow)
config_tbl <- static$configs

# Append data partitions here; these are the same for the duration of this function
data_splits <- get_data_subsets(static$wflow, split, static$split_args)
Expand Down Expand Up @@ -288,7 +288,7 @@ loop_over_all_stages <- function(resamples, grid, static) {
event_level = static$control$event_level,
metrics_info = metrics_info(static$metrics)
) |>
add_configs(static, config_tbl)
add_configs(static)
)

if (has_log_notes(all_metrics)) {
Expand All @@ -306,7 +306,7 @@ loop_over_all_stages <- function(resamples, grid, static) {

if (!is.null(extracts)) {

extracts <- add_configs(extracts, static, config_tbl) |>
extracts <- add_configs(extracts, static) |>
dplyr::relocate(.config, .after = .extracts) |>
dplyr::relocate(names(grid))

Expand Down Expand Up @@ -342,11 +342,7 @@ loop_over_all_stages <- function(resamples, grid, static) {
} else {
return_tbl$.predictions <-
list(
add_configs(
pred_reserve,
static,
config_tbl
) |>
add_configs(pred_reserve, static) |>
# Filter out joined rows that corresponded to a config that failed
dplyr::filter(!is.na(.row))
)
Expand Down Expand Up @@ -395,9 +391,10 @@ get_row_wise_grid <- function(wflow, grid) {

# ------------------------------------------------------------------------------

add_configs <- function(x, static, config_tbl) {
add_configs <- function(x, static) {
config_tbl <- static$configs
if (length(static$param_info$id) > 0) {
x <- dplyr::full_join(x, config_tbl, by = static$param_info$id)
x <- dplyr::left_join(x, config_tbl, by = static$param_info$id)
} else {
x <- dplyr::bind_cols(x, config_tbl)
}
Expand Down
1 change: 1 addition & 0 deletions R/tune_grid_loop_new.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tune_grid_loop_new <- function(
static <- make_static(
workflow,
param_info = param_info,
grid = grid,
metrics = metrics,
eval_time = eval_time,
split_args = split_args,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# maker static object

Code
tune:::make_static(1, param_info = extract_parameter_set_dials(wflow), metrics = metric_set(
accuracy), eval_time = NULL, split_args = mc_cv_args, control = control_resamples())
tune:::make_static(1, param_info = extract_parameter_set_dials(wflow), grid = dt_grid,
metrics = metric_set(accuracy), eval_time = NULL, split_args = mc_cv_args,
control = control_resamples())
Condition
Error in `tune:::make_static()`:
! `workflow` should be a <workflow> object.

---

Code
tune:::make_static(wflow, param_info = 2, metrics = metric_set(accuracy),
eval_time = NULL, split_args = mc_cv_args, control = control_resamples())
tune:::make_static(wflow, param_info = 2, grid = dt_grid, metrics = metric_set(
accuracy), eval_time = NULL, split_args = mc_cv_args, control = control_resamples())
Condition
Error in `tune:::make_static()`:
! `param_info` should be a <parameters> object.
Expand All @@ -20,7 +21,8 @@

Code
tune:::make_static(wflow, param_info = extract_parameter_set_dials(wflow),
metrics = 3, eval_time = NULL, split_args = mc_cv_args, control = control_resamples())
grid = dt_grid, metrics = 3, eval_time = NULL, split_args = mc_cv_args,
control = control_resamples())
Condition
Error in `tune:::make_static()`:
! `metrics` should be a <metric_set> object.
Expand All @@ -29,7 +31,7 @@

Code
tune:::make_static(wflow, param_info = extract_parameter_set_dials(wflow),
metrics = metric_set(accuracy), eval_time = "four", split_args = mc_cv_args,
grid = dt_grid, metrics = metric_set(accuracy), eval_time = "four", split_args = mc_cv_args,
control = control_resamples())
Condition
Error in `tune:::make_static()`:
Expand Down
86 changes: 0 additions & 86 deletions tests/testthat/_snaps/loop-over-all-stages-logging.md

This file was deleted.

2 changes: 0 additions & 2 deletions tests/testthat/test-grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -735,5 +735,3 @@ test_that("retain extra attributes", {
"being saved contains a recipe, which is"
)
})


Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test_that("maker static object", {
res <- tune:::make_static(
wflow,
param_info = wflow |> extract_parameter_set_dials(),
grid = dt_grid,
metrics = metric_set(accuracy),
eval_time = NULL,
split_args = mc_cv_args,
Expand All @@ -23,6 +24,7 @@ test_that("maker static object", {
c(
"wflow",
"param_info",
"configs",
"post_estimation",
"metrics",
"metric_info",
Expand All @@ -38,6 +40,7 @@ test_that("maker static object", {
tune:::make_static(
1,
param_info = wflow |> extract_parameter_set_dials(),
grid = dt_grid,
metrics = metric_set(accuracy),
eval_time = NULL,
split_args = mc_cv_args,
Expand All @@ -50,6 +53,7 @@ test_that("maker static object", {
tune:::make_static(
wflow,
param_info = 2,
grid = dt_grid,
metrics = metric_set(accuracy),
eval_time = NULL,
split_args = mc_cv_args,
Expand All @@ -62,6 +66,7 @@ test_that("maker static object", {
tune:::make_static(
wflow,
param_info = wflow |> extract_parameter_set_dials(),
grid = dt_grid,
metrics = 3,
eval_time = NULL,
split_args = mc_cv_args,
Expand All @@ -74,6 +79,7 @@ test_that("maker static object", {
tune:::make_static(
wflow,
param_info = wflow |> extract_parameter_set_dials(),
grid = dt_grid,
metrics = metric_set(accuracy),
eval_time = "four",
split_args = mc_cv_args,
Expand All @@ -91,6 +97,7 @@ test_that("maker static object", {
c(
"wflow",
"param_info",
"configs",
"post_estimation",
"metrics",
"metric_info",
Expand Down
Loading