From 49a60fa67f6be852eee390bbc7aa40bc6db6763d Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 8 Jul 2024 06:44:21 +0200 Subject: [PATCH] Properly support "--no-color" for hyperopt --- freqtrade/optimize/hyperopt.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 8d2f8846a..b411e7752 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -14,11 +14,11 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Tuple import rapidjson -from colorama import init as colorama_init from joblib import Parallel, cpu_count, delayed, dump, load, wrap_non_picklable_objects from joblib.externals import cloudpickle from pandas import DataFrame from rich.align import Align +from rich.console import Console from rich.progress import ( BarColumn, MofNCompleteColumn, @@ -625,13 +625,13 @@ class Hyperopt: self.opt = self.get_optimizer(self.dimensions, config_jobs) - if self.print_colorized: - colorama_init(autoreset=True) - try: with Parallel(n_jobs=config_jobs) as parallel: jobs = parallel._effective_n_jobs() logger.info(f"Effective number of parallel workers used: {jobs}") + console = Console( + color_system="auto" if self.print_colorized else None, + ) # Define progressbar with CustomProgress( @@ -644,6 +644,7 @@ class Hyperopt: "•", TimeRemainingColumn(), expand=True, + console=console, cust_objs=[Align.center(self._hyper_out.table)], ) as pbar: task = pbar.add_task("Epochs", total=self.total_epochs)