@@ -96,7 +96,6 @@ def tracking_objective2(trial, *args, **kwargs):
9696 second_run_trials .add (trial .number )
9797 return original_objective2 (trial , * args , ** kwargs )
9898
99- # pipeline_optimizer.nodes[NodeType.scoring].objective = tracking_objective2
10099 pipeline_optimizer .set_config (logging_config )
101100 pipeline_optimizer .set_config (DataConfig (scheme = "ho" , separation_ratio = None ))
102101 with patch .object (pipeline_optimizer .nodes [NodeType .scoring ], "objective" , side_effect = tracking_objective2 ):
@@ -121,3 +120,30 @@ def tracking_objective2(trial, *args, **kwargs):
121120 f"Database { db_file .name } did not have more trials after second run "
122121 f"({ trials_after_first_run [db_file .name ]} vs { trials_after_second_run } )"
123122 )
123+
124+
125+ def test_resuming_with_memory_storage_warning (dataset_no_oos , tmp_path , caplog ):
126+ """Test that a warning is issued when trying to resume with memory storage."""
127+ project_dir = tmp_path
128+ search_space = get_search_space ("optuna" )
129+
130+ # Setup first pipeline with memory storage
131+ logging_config = LoggingConfig (
132+ project_dir = project_dir ,
133+ run_name = "test_memory_storage_warning" ,
134+ dump_modules = False , # Keep modules in RAM
135+ clear_ram = False ,
136+ )
137+
138+ pipeline_optimizer = Pipeline .from_search_space (search_space )
139+ pipeline_optimizer .set_config (logging_config )
140+ pipeline_optimizer .set_config (DataConfig (
141+ scheme = "ho" ,
142+ separation_ratio = None ,
143+ n_folds = 2 ,
144+ validation_size = 0.2
145+ ))
146+ pipeline_optimizer .fit (dataset_no_oos , refit_after = False , sampler = "random" )
147+
148+ assert any ("Memory storage is not compatible with resuming optimization" in record .message for record in caplog .records )
149+
0 commit comments