Skip to content
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

Update macos tests to latest pytorch #3568

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
77 changes: 8 additions & 69 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,83 +20,22 @@ 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.11"
extras: "test-core"
fail-fast: false
runs-on: ${{ matrix.os }}
runs-on: macos-latest
steps:
- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache python libs
uses: actions/cache@v4
if: matrix.extras == 'test'
with:
path: |
# Only cache a subset of libraries, ensuring cache size remains under 10GB. See GH dsgibbons#42
${{ env.pythonLocation }}/**/site-packages/pyspark*
${{ env.pythonLocation }}/**/site-packages/nvidia*
${{ env.pythonLocation }}/**/site-packages/torch*
${{ env.pythonLocation }}/**/site-packages/functorch*
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ env.pythonLocation }}-${{ hashFiles('setup.py', 'pyproject.toml') }}-0
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Use "eager" update strategy in case cached dependencies are outdated
# Using regular install NOT editable install: see GH #3020
pip install --upgrade --upgrade-strategy eager '.[${{ matrix.extras }},plots]'
pip install eager pytest torch scikit-learn lightgbm
- name: pip list
run: pip list
- 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@v3
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@v3
pytest tests/test_bug121101.py
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ test = [
"pyod",
"transformers",
"protobuf==3.20.3", # See GH #3046
"torch==2.2.0; sys_platform == 'darwin'", # see GH #3524
"torch; sys_platform != 'darwin'",
"torch",
"torchvision",
"tensorflow<2.16;python_version<'3.12'", # FIXME: pending keras 3.0 support, pending tf py3.12 support
"sentencepiece",
Expand Down Expand Up @@ -114,7 +113,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
10 changes: 10 additions & 0 deletions tests/test_bug121101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import time

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)