Merge pull request #3229 from hroff-1902/hyperopt-improve-logging

Improve hyperopt-list logging
This commit is contained in:
hroff-1902 2020-04-28 17:42:56 +03:00 committed by GitHub
commit 09e488a693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -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:
"""

View File

@ -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()