Merge pull request #3229 from hroff-1902/hyperopt-improve-logging
Improve hyperopt-list logging
This commit is contained in:
commit
09e488a693
@ -376,13 +376,13 @@ class Hyperopt:
|
||||
|
||||
# Verification for overwrite
|
||||
if path.isfile(csv_file):
|
||||
logger.error("CSV-File already exists!")
|
||||
logger.error(f"CSV file already exists: {csv_file}")
|
||||
return
|
||||
|
||||
try:
|
||||
io.open(csv_file, 'w+').close()
|
||||
except IOError:
|
||||
logger.error("Filed to create CSV-File!")
|
||||
logger.error(f"Failed to create CSV file: {csv_file}")
|
||||
return
|
||||
|
||||
trials = json_normalize(results, max_level=1)
|
||||
@ -420,7 +420,7 @@ class Hyperopt:
|
||||
|
||||
trials = trials.drop(columns=['is_initial_point', 'is_best', 'is_profit'])
|
||||
trials.to_csv(csv_file, index=False, header=True, mode='w', encoding='UTF-8')
|
||||
print("CSV-File created!")
|
||||
logger.info(f"CSV file created: {csv_file}")
|
||||
|
||||
def has_space(self, space: str) -> bool:
|
||||
"""
|
||||
|
@ -727,7 +727,7 @@ def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys):
|
||||
assert re.match("['ETH/BTC', 'TKN/BTC', 'BLK/BTC', 'LTC/BTC', 'XRP/BTC']", captured.out)
|
||||
|
||||
|
||||
def test_hyperopt_list(mocker, capsys, hyperopt_results):
|
||||
def test_hyperopt_list(mocker, capsys, caplog, hyperopt_results):
|
||||
mocker.patch(
|
||||
'freqtrade.optimize.hyperopt.Hyperopt.load_previous_results',
|
||||
MagicMock(return_value=hyperopt_results)
|
||||
@ -911,8 +911,7 @@ def test_hyperopt_list(mocker, capsys, hyperopt_results):
|
||||
pargs['config'] = None
|
||||
start_hyperopt_list(pargs)
|
||||
captured = capsys.readouterr()
|
||||
assert all(x in captured.out
|
||||
for x in ["CSV-File created!"])
|
||||
log_has("CSV file created: test_file.csv", caplog)
|
||||
f = Path("test_file.csv")
|
||||
assert 'Best,1,2,-1.25%,-0.00125625,,-2.51,"3,930.0 m",0.43662' in f.read_text()
|
||||
assert f.is_file()
|
||||
|
Loading…
Reference in New Issue
Block a user