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