Merge pull request #2563 from hroff-1902/hyperopt-save
Hyperopt: Save epochs at intermediate points
This commit is contained in:
@@ -360,7 +360,7 @@ def test_log_results_if_loss_improves(hyperopt, capsys) -> None:
|
||||
hyperopt.log_results(
|
||||
{
|
||||
'loss': 1,
|
||||
'current_epoch': 1,
|
||||
'current_epoch': 2, # This starts from 1 (in a human-friendly manner)
|
||||
'results_explanation': 'foo.',
|
||||
'is_initial_point': False
|
||||
}
|
||||
@@ -374,6 +374,7 @@ def test_no_log_if_loss_does_not_improve(hyperopt, caplog) -> None:
|
||||
hyperopt.log_results(
|
||||
{
|
||||
'loss': 3,
|
||||
'current_epoch': 1,
|
||||
}
|
||||
)
|
||||
assert caplog.record_tuples == []
|
||||
@@ -382,13 +383,19 @@ def test_no_log_if_loss_does_not_improve(hyperopt, caplog) -> None:
|
||||
def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None:
|
||||
trials = create_trials(mocker, hyperopt, testdatadir)
|
||||
mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None)
|
||||
hyperopt.trials = trials
|
||||
hyperopt.save_trials()
|
||||
|
||||
trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
|
||||
assert log_has(f"Saving 1 evaluations to '{trials_file}'", caplog)
|
||||
|
||||
hyperopt.trials = trials
|
||||
hyperopt.save_trials(final=True)
|
||||
assert log_has("Saving 1 epoch.", caplog)
|
||||
assert log_has(f"1 epoch saved to '{trials_file}'.", caplog)
|
||||
mock_dump.assert_called_once()
|
||||
|
||||
hyperopt.trials = trials + trials
|
||||
hyperopt.save_trials(final=True)
|
||||
assert log_has("Saving 2 epochs.", caplog)
|
||||
assert log_has(f"2 epochs saved to '{trials_file}'.", caplog)
|
||||
|
||||
|
||||
def test_read_trials_returns_trials_file(mocker, hyperopt, testdatadir, caplog) -> None:
|
||||
trials = create_trials(mocker, hyperopt, testdatadir)
|
||||
|
Reference in New Issue
Block a user