Skip to content

Commit

Permalink
[MNT] CI fixes and pytest options (#2249)
Browse files Browse the repository at this point in the history
* ci fixes

* Empty commit for CI

* Update _borf.py

* Update conftest.py

* Update conftest.py

---------

Co-authored-by: MatthewMiddlehurst <[email protected]>
  • Loading branch information
MatthewMiddlehurst and MatthewMiddlehurst authored Oct 25, 2024
1 parent afd0df7 commit 7f81460
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 57 deletions.
2 changes: 1 addition & 1 deletion aeon/anomaly_detection/_copod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 2 additions & 35 deletions aeon/transformations/collection/dictionary_based/_borf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
60 changes: 39 additions & 21 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

0 comments on commit 7f81460

Please sign in to comment.