@@ -170,6 +170,48 @@ def test_setup_hyperopt_configuration_stake_amount(mocker, default_conf) -> None
170170 setup_optimize_configuration (get_args (args ), RunMode .HYPEROPT )
171171
172172
173+ def test_setup_hyperopt_early_stop_setup (mocker , default_conf , caplog ) -> None :
174+ patched_configuration_load_config_file (mocker , default_conf )
175+
176+ args = [
177+ "hyperopt" ,
178+ "--config" ,
179+ "config.json" ,
180+ "--strategy" ,
181+ "HyperoptableStrategy" ,
182+ "--early-stop" ,
183+ "1" ,
184+ ]
185+ conf = setup_optimize_configuration (get_args (args ), RunMode .HYPEROPT )
186+ assert isinstance (conf , dict )
187+ assert conf ["early_stop" ] == 20
188+ msg = (
189+ r"Parameter --early-stop detected ... "
190+ r"Will early stop hyperopt if no improvement after (20|25) epochs ..."
191+ )
192+ msg_adjust = r"Early stop epochs .* lower than 20. It will be replaced with 20."
193+ assert log_has_re (msg_adjust , caplog )
194+ assert log_has_re (msg , caplog )
195+
196+ caplog .clear ()
197+
198+ args = [
199+ "hyperopt" ,
200+ "--config" ,
201+ "config.json" ,
202+ "--strategy" ,
203+ CURRENT_TEST_STRATEGY ,
204+ "--early-stop" ,
205+ "25" ,
206+ ]
207+ conf1 = setup_optimize_configuration (get_args (args ), RunMode .HYPEROPT )
208+ assert isinstance (conf1 , dict )
209+
210+ assert conf1 ["early_stop" ] == 25
211+ assert not log_has_re (msg_adjust , caplog )
212+ assert log_has_re (msg , caplog )
213+
214+
173215def test_start_not_installed (mocker , default_conf , import_fails ) -> None :
174216 start_mock = MagicMock ()
175217 patched_configuration_load_config_file (mocker , default_conf )
0 commit comments