Mock tensorboard callbacks for all freqAI tests

This commit is contained in:
Matthias
2023-05-13 08:02:19 +02:00
parent 23e8932a44
commit ab0f9d78ee
2 changed files with 15 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import platform
from copy import deepcopy from copy import deepcopy
from pathlib import Path from pathlib import Path
from typing import Any, Dict from typing import Any, Dict
@@ -14,6 +15,19 @@ from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver
from tests.conftest import get_patched_exchange from tests.conftest import get_patched_exchange
def is_mac() -> bool:
machine = platform.system()
return "Darwin" in machine
@pytest.fixture(scope="function", autouse=True)
def patch_tensorboard_maconly(mocker):
if is_mac():
# MacOS CI is not friendly to tensorboard
mocker.patch('freqtrade.freqai.tensorboard.tensorboard.SummaryWriter')
mocker.patch('freqtrade.freqai.tensorboard.tensorboard.TensorBoardCallback.after_iteration')
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def freqai_conf(default_conf, tmpdir): def freqai_conf(default_conf, tmpdir):
freqaiconf = deepcopy(default_conf) freqaiconf = deepcopy(default_conf)

View File

@@ -15,7 +15,7 @@ from freqtrade.optimize.backtesting import Backtesting
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.plugins.pairlistmanager import PairListManager
from tests.conftest import EXMS, create_mock_trades, get_patched_exchange, log_has_re from tests.conftest import EXMS, create_mock_trades, get_patched_exchange, log_has_re
from tests.freqai.conftest import (get_patched_freqai_strategy, make_rl_config, from tests.freqai.conftest import (get_patched_freqai_strategy, is_mac, make_rl_config,
mock_pytorch_mlp_model_training_parameters) mock_pytorch_mlp_model_training_parameters)
@@ -28,11 +28,6 @@ def is_arm() -> bool:
return "arm" in machine or "aarch64" in machine return "arm" in machine or "aarch64" in machine
def is_mac() -> bool:
machine = platform.system()
return "Darwin" in machine
def can_run_model(model: str) -> None: def can_run_model(model: str) -> None:
if (is_arm() or is_py11()) and "Catboost" in model: if (is_arm() or is_py11()) and "Catboost" in model:
pytest.skip("CatBoost is not supported on ARM.") pytest.skip("CatBoost is not supported on ARM.")
@@ -59,10 +54,6 @@ def test_extract_data_and_train_model_Standard(mocker, freqai_conf, model, pca,
dbscan, float32, can_short, shuffle, buffer): dbscan, float32, can_short, shuffle, buffer):
can_run_model(model) can_run_model(model)
if is_mac():
# MacOS CI is not friendly to tensorboard
mocker.patch('freqtrade.freqai.tensorboard.tensorboard.SummaryWriter')
mocker.patch('freqtrade.freqai.tensorboard.tensorboard.TensorBoardCallback.after_iteration')
model_save_ext = 'joblib' model_save_ext = 'joblib'
freqai_conf.update({"freqaimodel": model}) freqai_conf.update({"freqaimodel": model})