Skip to content

Update macos tests to latest pytorch #3568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 8 additions & 91 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,99 +20,16 @@ concurrency:
# Cancel only PR intermediate builds
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

# Temporary simpler job for debugging purposes
jobs:
run_tests:
strategy:
matrix:
os: ["ubuntu-latest"]
# The total number of matrix jobs should match codecov.yml `after_n_builds`.
python-version: ["3.9", "3.10", "3.11", "3.12"]
extras: ["test"]
include:
# Test on windows/mac, just one job each
- os: windows-latest
python-version: "3.11"
extras: "test"
- os: macos-latest
python-version: "3.11"
extras: "test"
# Run tests with only the core dependencies, to ensure we
# cover the latest version of numpy/pandas. See GH dsgibbons#46
- os: ubuntu-latest
python-version: "3.12"
extras: "test-core"
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 40
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install libomp (macOS)
if: matrix.os == 'macos-latest'
run: brew install libomp
- name: Install dependencies
# Do regular install NOT editable install: see GH #3020
run: |
python -m pip install --upgrade uv
uv pip install --system '.[${{ matrix.extras }},plots]'
- name: Test with pytest
# Ensure we avoid adding current working directory to sys.path:
# - Use "pytest" over "python -m pytest"
# - Use "append" import mode rather than default "prepend"
run: >
pytest --durations=20
--cov --cov-report=xml
--mpl-generate-summary=html --mpl-results-path=./mpl-results
--import-mode=append
- name: Upload mpl test report
if: failure()
uses: actions/upload-artifact@v4
with:
name: mpl-results-${{ matrix.python-version }}-${{ runner.os }}-${{ matrix.extras }}
path: mpl-results/
if-no-files-found: ignore
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}


test_oldest_supported_numpy:
# Package is built with numpy 2.X, and tested against numpy 1.X.
# This job is recommended by https://numpy.org/doc/stable/dev/depending_on_numpy.html#numpy-2-0-specific-advice
# The "oldest supported numpy" is determined by SPEC 0:
# https://scientific-python.org/specs/spec-0000/
name: run tests (oldest supported numpy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system numpy==1.24.0 '.[test-core,plots]'
- name: Test with pytest
run: pytest --durations=20 --import-mode=append

run_mypy:
# Run mypy on the latest Python version
name: run mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system '.[test-core]'
- name: Run mypy
run: mypy shap tests
python-version: 3.11
- run: brew install libomp
- run: pip install pytest torch scikit-learn lightgbm
- run: pip list
- run: pytest --noconftest tests/test_bug121101.py
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ test = [
"transformers",
"tf-keras",
"protobuf==3.20.3", # See GH #3046
"torch==2.2.0; sys_platform == 'darwin'", # see GH #3524
"torch; sys_platform != 'darwin'",
"torch",
"torchvision",
"tensorflow",
"sentencepiece",
Expand Down Expand Up @@ -194,7 +193,7 @@ version_file = "shap/_version.py"
local_scheme = "no-local-version"

[tool.pytest.ini_options]
addopts = "--mpl"
# addopts = "--mpl"
testpaths = ["tests"]
filterwarnings = [
# Ignore warnings that are entirely from 3rd party libs outside our control
Expand Down
13 changes: 13 additions & 0 deletions tests/test_bug121101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ruff: noqa
# fmt: off
import time

import lightgbm
import torch
from sklearn.datasets import fetch_california_housing


def test_something():
X, y = fetch_california_housing(return_X_y=True)
torch.tensor(X)
time.sleep(3)
Loading