[python-package] Remove dead Python 2 guard and sklearn.cross_validation fallback#12086
[python-package] Remove dead Python 2 guard and sklearn.cross_validation fallback#12086PavelGuzenfeld wants to merge 6 commits intodmlc:masterfrom
Conversation
- Remove `assert sys.version_info[0] == 3` — XGBoost requires Python >= 3.10 (pyproject.toml), making this check dead code. Using `assert` for version checks is also incorrect as assertions are stripped under `python -O`. - Remove `sklearn.cross_validation` import fallback — `sklearn.cross_validation` was removed in scikit-learn 0.20 (2018). Any scikit-learn version supporting Python 3.10+ will have `sklearn.model_selection`.
There was a problem hiding this comment.
Pull request overview
Removes unreachable legacy compatibility code in compat.py now that XGBoost requires modern Python/scikit-learn versions.
Changes:
- Removed a dead Python 2 guard that could never trigger under the project’s Python >= 3.10 requirement.
- Removed an unreachable fallback import of
sklearn.cross_validation.StratifiedKFold, importing only fromsklearn.model_selection.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Please address CI failures |
|
Fixed the pre-commit failure — ruff flagged two formatting issues:
The Windows test failure was unrelated (self-hosted runner lost connectivity). |
|
The only CI failure — Google Test (C++) CUDA 12 (mgpu) — is unrelated to this PR's changes. It failed during Docker container initialization due to an ECR authentication error:
This is a transient infrastructure issue (AWS ECR auth), not a code problem. A maintainer with admin access would need to re-trigger the failed job. |
|
Hi, friendly ping on this PR. It has been approved by @RAMitchell and all CI checks are passing except for a single infrastructure-related failure (AWS ECR Docker login on the CUDA mgpu job), which appears unrelated to the changes here. I attempted to re-run the failed job but don't have the permissions. Could a maintainer re-trigger that job or merge given the failure is infrastructure-related? Thank you! |
|
I prepared a fix for the macOS x86_64 wheel CI failure here: RAMitchell#2 It avoids pulling Homebrew LLVMs If useful, the fix commit is |
|
Thanks @RAMitchell! I've cherry-picked your fix commit ( |
Issue persists. |
|
We will try to fix it in #12108 |
Add section documenting 3 merged PRs (dmlc#12087, dmlc#12089, dmlc#12094), 1 open PR (dmlc#12086), and 3 closed/superseded PRs.
|
Out of curiosity, is there something like the previous k price happening? Looking at your agent tracker with the difficulty classification, looks quite similar to the trend in that competition. |
|
Please remove bde4a3e (macos fix) and we will merge it. |
Summary
Remove two pieces of dead compatibility code from
compat.py:assert sys.version_info[0] == 3— XGBoost requires Python >= 3.10(
pyproject.toml), so this check can never fail. Additionally, usingassertfor version checks is incorrect since assertions are strippedunder
python -O.sklearn.cross_validationimport fallback —sklearn.cross_validationwas removed in scikit-learn 0.20 (2018). Any scikit-learn version that
supports Python >= 3.10 will have
sklearn.model_selection, makingthe
try/exceptfallback unreachable.Files changed
python-package/xgboost/compat.py— 7 lines removed, 1 added