From 7f81460b24d442b6efedbeadc2deddac7fcce0bb Mon Sep 17 00:00:00 2001 From: Matthew Middlehurst Date: Fri, 25 Oct 2024 23:39:53 +0300 Subject: [PATCH] [MNT] CI fixes and pytest options (#2249) * ci fixes * Empty commit for CI * Update _borf.py * Update conftest.py * Update conftest.py --------- Co-authored-by: MatthewMiddlehurst --- aeon/anomaly_detection/_copod.py | 2 +- .../collection/dictionary_based/_borf.py | 37 +----------- conftest.py | 60 ++++++++++++------- 3 files changed, 42 insertions(+), 57 deletions(-) diff --git a/aeon/anomaly_detection/_copod.py b/aeon/anomaly_detection/_copod.py index d1fc88dc86..1194f98b94 100644 --- a/aeon/anomaly_detection/_copod.py +++ b/aeon/anomaly_detection/_copod.py @@ -67,7 +67,7 @@ def _fit_predict( return super()._fit_predict(X, y) @classmethod - def get_test_params(cls, parameter_set="default") -> dict: + def _get_test_params(cls, parameter_set="default") -> dict: """Return testing parameter settings for the estimator. Parameters diff --git a/aeon/transformations/collection/dictionary_based/_borf.py b/aeon/transformations/collection/dictionary_based/_borf.py index f1af5bf944..0a32a7bf31 100644 --- a/aeon/transformations/collection/dictionary_based/_borf.py +++ b/aeon/transformations/collection/dictionary_based/_borf.py @@ -182,7 +182,7 @@ def _transform(self, X, y=None): return self.pipe_.transform(X) @classmethod - def get_test_params(cls, parameter_set="default"): + def _get_test_params(cls, parameter_set="default"): """Return testing parameter settings for the estimator. Parameters @@ -200,40 +200,7 @@ def get_test_params(cls, parameter_set="default"): instance. `create_test_instance` uses the first (or only) dictionary in `params`. """ - params = [ - { - "window_size_min_window_size": 4, - "window_size_max_window_size": None, - "word_lengths_n_word_lengths": 4, - "alphabets_min_symbols": 3, - "alphabets_max_symbols": 4, - "alphabets_step": 1, - "dilations_min_dilation": 1, - "dilations_max_dilation": None, - "min_window_to_signal_std_ratio": 0.0, - "n_jobs": 1, - "n_jobs_numba": 1, - "transformer_weights": None, - "complexity": "quadratic", - "densify": False, - }, - { - "window_size_min_window_size": 4, - "window_size_max_window_size": None, - "word_lengths_n_word_lengths": 4, - "alphabets_min_symbols": 3, - "alphabets_max_symbols": 4, - "alphabets_step": 1, - "dilations_min_dilation": 1, - "dilations_max_dilation": None, - "min_window_to_signal_std_ratio": 0.0, - "n_jobs": 1, - "n_jobs_numba": 1, - "transformer_weights": None, - "complexity": "quadratic", - "densify": True, - }, - ] + params = [{"densify": False}, {"densify": True}] return params diff --git a/conftest.py b/conftest.py index ace2d0b708..0c1299b8cc 100644 --- a/conftest.py +++ b/conftest.py @@ -8,11 +8,24 @@ least once, but not necessarily on each operating system / python version combination. """ -__maintainer__ = [] +__maintainer__ = ["MatthewMiddlehurst"] def pytest_addoption(parser): """Pytest command line parser options adder.""" + parser.addoption( + "--nonumba", + default=False, + help=("Disable numba via the NUMBA_DISABLE_JIT environment variable."), + ) + parser.addoption( + "--enablethreading", + default=False, + help=( + "Allow threading and skip setting number of threads to 1 for various " + "libraries and environment variables." + ), + ) parser.addoption( "--prtesting", default=False, @@ -28,33 +41,38 @@ def pytest_configure(config): """Pytest configuration preamble.""" import os - # Must be called before any numpy imports - os.environ["MKL_NUM_THREADS"] = "1" - os.environ["NUMEXPR_NUM_THREADS"] = "1" - os.environ["OMP_NUM_THREADS"] = "1" - os.environ["OPENBLAS_NUM_THREADS"] = "1" - os.environ["VECLIB_MAXIMUM_THREADS"] = "1" + if config.getoption("--nonumba") in [True, "True", "true"]: + os.environ["NUMBA_DISABLE_JIT"] = "1" - import numba + if not config.getoption("--enablethreading") in [True, "True", "true"]: + # Must be called before any numpy imports + os.environ["MKL_NUM_THREADS"] = "1" + os.environ["NUMEXPR_NUM_THREADS"] = "1" + os.environ["OMP_NUM_THREADS"] = "1" + os.environ["OPENBLAS_NUM_THREADS"] = "1" + os.environ["VECLIB_MAXIMUM_THREADS"] = "1" - from aeon.testing import testing_config - from aeon.utils.validation._dependencies import _check_soft_dependencies + import numba - numba.set_num_threads(1) + numba.set_num_threads(1) - if _check_soft_dependencies("tensorflow", severity="none"): - from tensorflow.config.threading import ( - set_inter_op_parallelism_threads, - set_intra_op_parallelism_threads, - ) + from aeon.utils.validation._dependencies import _check_soft_dependencies - set_inter_op_parallelism_threads(1) - set_intra_op_parallelism_threads(1) + if _check_soft_dependencies("tensorflow", severity="none"): + from tensorflow.config.threading import ( + set_inter_op_parallelism_threads, + set_intra_op_parallelism_threads, + ) - if _check_soft_dependencies("torch", severity="none"): - import torch + set_inter_op_parallelism_threads(1) + set_intra_op_parallelism_threads(1) - torch.set_num_threads(1) + if _check_soft_dependencies("torch", severity="none"): + import torch + + torch.set_num_threads(1) if config.getoption("--prtesting") in [True, "True", "true"]: + from aeon.testing import testing_config + testing_config.PR_TESTING = True