From 6c9e6cc1983db4919743034b6d0c1bf119f554f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 06:00:19 +0000 Subject: [PATCH 1/3] chore(deps): bump xgboost from 2.0.3 to 2.1.3 Bumps [xgboost](https://github.com/dmlc/xgboost) from 2.0.3 to 2.1.3. - [Release notes](https://github.com/dmlc/xgboost/releases) - [Changelog](https://github.com/dmlc/xgboost/blob/master/NEWS.md) - [Commits](https://github.com/dmlc/xgboost/compare/v2.0.3...v2.1.3) --- updated-dependencies: - dependency-name: xgboost dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-freqai.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-freqai.txt b/requirements-freqai.txt index ca7181004..47c69ff64 100644 --- a/requirements-freqai.txt +++ b/requirements-freqai.txt @@ -10,6 +10,6 @@ catboost==1.2.7; 'arm' not in platform_machine # Temporary downgrade of matplotlib due to https://github.com/matplotlib/matplotlib/issues/28551 matplotlib==3.9.3 lightgbm==4.5.0 -xgboost==2.0.3 +xgboost==2.1.3 tensorboard==2.18.0 datasieve==0.1.7 From c841146968528b4b56466b045e513d240ca0c407 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 2 Dec 2024 07:12:30 +0100 Subject: [PATCH 2/3] chore: Remove non-suppored callback from XGBRFRegressor According to the XGBoost docs, this probably never worked as it was never supported - but is now raising an error for user clarity. --- .../freqai/prediction_models/XGBoostRFRegressor.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/freqtrade/freqai/prediction_models/XGBoostRFRegressor.py b/freqtrade/freqai/prediction_models/XGBoostRFRegressor.py index 12231ed13..140186075 100644 --- a/freqtrade/freqai/prediction_models/XGBoostRFRegressor.py +++ b/freqtrade/freqai/prediction_models/XGBoostRFRegressor.py @@ -5,7 +5,6 @@ from xgboost import XGBRFRegressor from freqtrade.freqai.base_models.BaseRegressionModel import BaseRegressionModel from freqtrade.freqai.data_kitchen import FreqaiDataKitchen -from freqtrade.freqai.tensorboard import TBCallback logger = logging.getLogger(__name__) @@ -45,7 +44,12 @@ class XGBoostRFRegressor(BaseRegressionModel): model = XGBRFRegressor(**self.model_training_parameters) - model.set_params(callbacks=[TBCallback(dk.data_path)]) + # Callbacks are not supported for XGBRFRegressor, and version 2.1.x started to throw + # the following error: + # NotImplementedError: `early_stopping_rounds` and `callbacks` are not implemented + # for random forest. + + # model.set_params(callbacks=[TBCallback(dk.data_path)]) model.fit( X=X, y=y, @@ -55,6 +59,6 @@ class XGBoostRFRegressor(BaseRegressionModel): xgb_model=xgb_model, ) # set the callbacks to empty so that we can serialize to disk later - model.set_params(callbacks=[]) + # model.set_params(callbacks=[]) return model From eee5d710e7c7b72fd2018be0033a20998e26958a Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 8 Dec 2024 09:59:40 +0100 Subject: [PATCH 3/3] chore: patch torch all the time - "list"tests do load the modules as well - so they need the same patch. --- tests/conftest.py | 25 +++++++++++++++++++++++++ tests/freqai/conftest.py | 25 ------------------------- tests/freqai/test_freqai_datakitchen.py | 3 +-- tests/freqai/test_freqai_interface.py | 11 ++++++++--- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 517170860..df8a31974 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # pragma pylint: disable=missing-docstring import json import logging +import platform import re from copy import deepcopy from datetime import datetime, timedelta, timezone @@ -517,6 +518,30 @@ def patch_gc(mocker) -> None: mocker.patch("freqtrade.main.gc_set_threshold") +def is_arm() -> bool: + machine = platform.machine() + return "arm" in machine or "aarch64" in machine + + +def is_mac() -> bool: + machine = platform.system() + return "Darwin" in machine + + +@pytest.fixture(autouse=True) +def patch_torch_initlogs(mocker) -> None: + if is_mac(): + # Mock torch import completely + import sys + import types + + module_name = "torch" + mocked_module = types.ModuleType(module_name) + sys.modules[module_name] = mocked_module + else: + mocker.patch("torch._logging._init_logs") + + @pytest.fixture(autouse=True) def user_dir(mocker, tmp_path) -> Path: user_dir = tmp_path / "user_data" diff --git a/tests/freqai/conftest.py b/tests/freqai/conftest.py index 442f53020..9e14111af 100644 --- a/tests/freqai/conftest.py +++ b/tests/freqai/conftest.py @@ -1,4 +1,3 @@ -import platform import sys from copy import deepcopy from pathlib import Path @@ -20,30 +19,6 @@ def is_py12() -> bool: return sys.version_info >= (3, 12) -def is_mac() -> bool: - machine = platform.system() - return "Darwin" in machine - - -def is_arm() -> bool: - machine = platform.machine() - return "arm" in machine or "aarch64" in machine - - -@pytest.fixture(autouse=True) -def patch_torch_initlogs(mocker) -> None: - if is_mac(): - # Mock torch import completely - import sys - import types - - module_name = "torch" - mocked_module = types.ModuleType(module_name) - sys.modules[module_name] = mocked_module - else: - mocker.patch("torch._logging._init_logs") - - @pytest.fixture(scope="function") def freqai_conf(default_conf, tmp_path): freqaiconf = deepcopy(default_conf) diff --git a/tests/freqai/test_freqai_datakitchen.py b/tests/freqai/test_freqai_datakitchen.py index 27efc3a66..7a219e46e 100644 --- a/tests/freqai/test_freqai_datakitchen.py +++ b/tests/freqai/test_freqai_datakitchen.py @@ -10,11 +10,10 @@ from freqtrade.configuration import TimeRange from freqtrade.data.dataprovider import DataProvider from freqtrade.exceptions import OperationalException from freqtrade.freqai.data_kitchen import FreqaiDataKitchen -from tests.conftest import get_patched_exchange +from tests.conftest import get_patched_exchange, is_mac from tests.freqai.conftest import ( get_patched_data_kitchen, get_patched_freqai_strategy, - is_mac, make_unfiltered_dataframe, ) diff --git a/tests/freqai/test_freqai_interface.py b/tests/freqai/test_freqai_interface.py index 2779ddcb8..0710591c9 100644 --- a/tests/freqai/test_freqai_interface.py +++ b/tests/freqai/test_freqai_interface.py @@ -13,11 +13,16 @@ from freqtrade.freqai.utils import download_all_data_for_training, get_required_ from freqtrade.optimize.backtesting import Backtesting from freqtrade.persistence import Trade from freqtrade.plugins.pairlistmanager import PairListManager -from tests.conftest import EXMS, create_mock_trades, get_patched_exchange, log_has_re -from tests.freqai.conftest import ( - get_patched_freqai_strategy, +from tests.conftest import ( + EXMS, + create_mock_trades, + get_patched_exchange, is_arm, is_mac, + log_has_re, +) +from tests.freqai.conftest import ( + get_patched_freqai_strategy, make_rl_config, mock_pytorch_mlp_model_training_parameters, )