Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ jobs:
- name: Tests
env:
SUPER_SECRET: ${{ secrets.HF_HUB_TOKEN }}
# skip slow inference tests here, see inference-test.yml
run: |
python -m pytest -s -v --cov-report=xml skops/
python -m pytest -s -v --cov-report=xml -m "not inference" skops/

- name: Mypy
run: mypy --config-file pyproject.toml skops
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/inference-test-full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Tests hitting the inference API are slow and prone to hanging, resulting in
# timeouts. Therefore, we only run inference tests on the full test matrix if
# the head commit message contains the text "[CI inference]". See #118

name: inference-tests-full

on:
- push
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
inference-pytest-full:

runs-on: ${{ matrix.os }}
if: ${{ (github.repository == 'skops-dev/skops') && contains(github.event.head_commit.message, '[CI inference]') }}
strategy:
fail-fast: false # need to see which ones fail
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ["3.7", "3.8", "3.9", "3.10"]

# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 15

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
pip install .[docs,tests]
python --version
pip --version
pip list
shell: bash

- name: Full inference tests
env:
SUPER_SECRET: ${{ secrets.HF_HUB_TOKEN }}
run: |
python -m pytest -s -v -m "inference" skops/
48 changes: 48 additions & 0 deletions .github/workflows/inference-test-partial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Tests hitting the inference API are slow and prone to hanging, resulting in
# timeouts. Therefore, we only run a subset of settings with inference tests by
# default. See #118

name: inference-tests-partial

on:
- push
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
inference-pytest-partial:

runs-on: ${{ matrix.os }}
if: ${{ (github.repository == 'skops-dev/skops') && (!contains(github.event.head_commit.message, '[CI inference]')) }}
strategy:
fail-fast: false # need to see which ones fail
matrix:
os: [ubuntu-latest]
python: ["3.10"]

# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 15

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
pip install .[docs,tests]
python --version
pip --version
pip list
shell: bash

- name: Partial inference tests
env:
SUPER_SECRET: ${{ secrets.HF_HUB_TOKEN }}
run: |
python -m pytest -s -v -m "inference" skops/
7 changes: 6 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ internet with:

.. code:: bash

pytest -m "not network"
pytest -m "not network" skops

Similarly, there is a flag, ``-m inference`` for tests that hit the Hugging Face
Inference API, which can be quite slow or even hang. Skip these tests as long as
you don't make any changes to this functionality. If you already skip network
tests, the inference tests will also be skipped.


Releases
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ filterwarnings = [
]
markers = [
"network: marks tests as requiring internet (deselect with '-m \"not network\"')",
"inference: marks tests that call inference API (deselect with '-m \"not inference\"')",
]
addopts = "--cov=skops --cov-report=term-missing --doctest-modules"

Expand Down
4 changes: 3 additions & 1 deletion skops/hub_utils/tests/test_hf_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def repo_path_for_inference():
yield Path(repo_path)


@pytest.mark.inference
@pytest.mark.network
@flaky(max_runs=3)
@pytest.mark.parametrize(
Expand All @@ -408,7 +409,8 @@ def test_inference(
repo_path_for_inference,
destination_path,
):
# test inference backend for classifier and regressor models.
# Test inference backend for classifier and regressor models. This test can
# take a lot of time.
client = HfApi()

repo_path = repo_path_for_inference
Expand Down