Skip to content

Commit d90fb9e

Browse files
committed
Fix XGBoost CI test on MacOS Python3.11, Python3.12, and Python3.13
Implemented the macOS XGBoost test fix. Changed: - requirements-dev.txt:9: pin CI/dev XGBoost to >=1.7,<3 for Python <3.14. - setup.cfg:11: mirror the same constraint for metbit[ml] / metbit[all]. - tests/test_new_modules.py:28: skip XGBoost tests on Python 3.14 and also skip accidental XGBoost 3.x on macOS before it reaches the segfaulting sklearn CV path. - metbit/ml/classifiers.py:46: default XGBoost wrapper to n_jobs=1, still overrideable by caller kwargs. Verified: - python3 -m py_compile tests/test_new_modules.py metbit/ml/classifiers.py - Focused local check: pytest ... TestMLClassifier::test_xgb_fit -o addopts="" passes as skipped on this Python 3.14/XGBoost 3.2.0 machine.
1 parent a08e63f commit d90fb9e

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

metbit/ml/classifiers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def _make_xgb(kw, rs):
4343
raise ImportError(
4444
"xgboost is required for model='xgb'. Install it with: pip install xgboost"
4545
) from exc
46-
return XGBClassifier(random_state=rs, eval_metric="mlogloss", **kw)
46+
params = {"n_jobs": 1, **kw}
47+
return XGBClassifier(random_state=rs, eval_metric="mlogloss", **params)
4748

4849

4950
class MLClassifier:

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ coverage
66

77
# Optional deps required for full test coverage
88
# XGBoost: ML classifier tests
9-
xgboost
9+
xgboost>=1.7,<3; python_version < "3.14"
1010

1111
# PyTorch CPU-only wheel (smaller, sufficient for tests)
1212
--extra-index-url https://download.pytorch.org/whl/cpu

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ license_files =
88

99
[options.extras_require]
1010
ml =
11-
xgboost>=1.7
11+
xgboost>=1.7,<3; python_version < "3.14"
1212
dl =
1313
torch>=2.0
1414
all =
15-
xgboost>=1.7
15+
xgboost>=1.7,<3; python_version < "3.14"
1616
torch>=2.0

tests/test_new_modules.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Tests for the new stats, multivariate, ML, DL, and validation modules."""
22
# ruff: noqa: E501
3+
from importlib import metadata as importlib_metadata
4+
import platform
35
import sys
46
import numpy as np
57
import pandas as pd
@@ -28,6 +30,12 @@
2830
_XGB_SKIP_REASON = "xgboost 3.x segfaults under CPython 3.14 (upstream C-API incompatibility)"
2931
else:
3032
try:
33+
_xgb_version = importlib_metadata.version("xgboost")
34+
_xgb_major = int(_xgb_version.split(".", 1)[0])
35+
if platform.system() == "Darwin" and _xgb_major >= 3:
36+
raise RuntimeError(
37+
f"xgboost {_xgb_version} segfaults during sklearn CV on macOS"
38+
)
3139
from xgboost import XGBClassifier as _XGBCheck
3240
_XGBCheck() # forces dylib load → catches missing libomp on macOS
3341
_XGB_AVAILABLE = True

0 commit comments

Comments
 (0)