move delayed and wrap_non_picklable_objects from hyperopt to hyperopt_optimizer

This commit is contained in:
viotemp1
2025-04-28 18:50:09 +03:00
parent 04492e75b2
commit c32f8e972a
2 changed files with 5 additions and 5 deletions

View File

@@ -14,7 +14,7 @@ from pathlib import Path
from typing import Any from typing import Any
import rapidjson import rapidjson
from joblib import Parallel, cpu_count, delayed, wrap_non_picklable_objects from joblib import Parallel, cpu_count
from freqtrade.constants import FTHYPT_FILEVERSION, LAST_BT_RESULT_FN, Config from freqtrade.constants import FTHYPT_FILEVERSION, LAST_BT_RESULT_FN, Config
from freqtrade.enums import HyperoptState from freqtrade.enums import HyperoptState
@@ -160,9 +160,7 @@ class Hyperopt:
return self.hyperopter.generate_optimizer(*args, **kwargs) return self.hyperopter.generate_optimizer(*args, **kwargs)
return parallel( return parallel(optimizer_wrapper(v) for v in asked)
delayed(wrap_non_picklable_objects(optimizer_wrapper))(v) for v in asked
)
def _set_random_state(self, random_state: int | None) -> int: def _set_random_state(self, random_state: int | None) -> int:
return random_state or random.randint(1, 2**16 - 1) # noqa: S311 return random_state or random.randint(1, 2**16 - 1) # noqa: S311

View File

@@ -11,7 +11,7 @@ from pathlib import Path
from typing import Any from typing import Any
import optuna import optuna
from joblib import dump, load from joblib import dump, load, delayed, wrap_non_picklable_objects
from joblib.externals import cloudpickle from joblib.externals import cloudpickle
from optuna.exceptions import ExperimentalWarning from optuna.exceptions import ExperimentalWarning
from pandas import DataFrame from pandas import DataFrame
@@ -260,6 +260,8 @@ class HyperOptimizer:
# noinspection PyProtectedMember # noinspection PyProtectedMember
attr.value = params_dict[attr_name] attr.value = params_dict[attr_name]
@delayed
@wrap_non_picklable_objects
def generate_optimizer(self, raw_params: dict[str, Any]) -> dict[str, Any]: def generate_optimizer(self, raw_params: dict[str, Any]) -> dict[str, Any]:
""" """
Used Optimize function. Used Optimize function.