Skip to content
111 changes: 61 additions & 50 deletions .github/workflows/lib-lint-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
push:
branches:
- develop
- releases/**
- release/**
tags:
- "v*"
pull_request:
merge_group:
branches:
- develop
- releases/**
- release/**
workflow_dispatch: # run on request (no need for PR)

permissions: {} # No permissions by default
Expand Down Expand Up @@ -66,17 +66,26 @@ jobs:
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0

- name: Install uv and set the python version
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with:
enable-cache: false
python-version: "3.12"
- name: Install tox
version: "0.8.15"

# Install pre-commit
- name: Install pre-commit
working-directory: library
run: |
pip install '.[dev]'
- name: Code quality checks
python -m pip install --upgrade pip
pip install pre-commit

# Execute pre-commit checks
- name: Run pre-commit checks
working-directory: library
run: tox r -vv -e pre-commit
run: pre-commit run --all-files

Unit-Test:
runs-on: [self-hosted, linux, x64, dev, dmount]
permissions:
Expand All @@ -89,47 +98,33 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.12"
tox-env: "py312"
- python-version: "3.11"
tox-env: "py311"
python-version: ["3.11", "3.12"]
name: Unit-Test-with-Python${{ matrix.python-version }}
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Install Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0

- name: Install uv and set the python version
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with:
enable-cache: false
python-version: ${{ matrix.python-version }}
- name: Install tox
working-directory: library
run: |
pip install '.[dev]'
- name: Run unit test
working-directory: library
run: tox r -vv -e unit-test-${{ matrix.tox-env }}
version: "0.8.15"

- name: Installing dependencies
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --no-extra xpu flag excludes the xpu extra, but according to the pyproject.toml conflicts configuration, xpu and cuda extras conflict with each other. Consider documenting why xpu is explicitly excluded or verify that the conflicts configuration handles this correctly.

Suggested change
- name: Installing dependencies
- name: Installing dependencies
# Exclude the 'xpu' extra because 'xpu' and 'cuda' extras conflict in pyproject.toml.
# This ensures that only 'cuda' dependencies are installed for this test matrix.

Copilot uses AI. Check for mistakes.

run: uv sync --locked --all-extras --no-extra xpu --dev

- name: Unit testing
run: uv run pytest tests/unit --cov --cov-report=xml
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytest command is missing the working directory specification. The command should include working-directory: library or use an explicit path like library/tests/unit to ensure tests run from the correct location.

Suggested change
run: uv run pytest tests/unit --cov --cov-report=xml
run: uv run pytest tests/unit --cov --cov-report=xml
working-directory: library

Copilot uses AI. Check for mistakes.


- name: Upload coverage reports to Codecov
working-directory: library
run: |
# If the workflow is triggered from PR then it gets the commit id from the PR.
# else it uses the commit id of the latest commit. This is because the commit
# of the checked-out branch/commit does not exist in the tree as it is grafted.
# Also note: GitHub does not pass secrets to pipelines triggered from a fork.
# This means that upload will fail for PRs from forks.
if [ -n "${{ github.event.pull_request.head.sha }}" ]
then
COMMIT_ID=${{ github.event.pull_request.head.sha }}
else
COMMIT_ID=${{ github.sha }}
fi
# current version of codecov-action does not support uploading reports through the proxy
# so we use the latest version of codecov uploader binary
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${{ secrets.CODECOV_TOKEN }} --sha $COMMIT_ID -U $HTTP_PROXY -f .tox/coverage_unit-test-${{ matrix.tox-env }}.xml -F ${{ matrix.tox-env }}
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
flags: coverage_unit-test_Python-${{ matrix.python-version }}
use_oidc: true

Integration-Test:
if: |
github.event.pull_request.draft == false &&
Expand All @@ -146,30 +141,46 @@ jobs:
matrix:
include:
- task: "multi_class_cls"
python-version: "3.12"
- task: "multi_label_cls"
python-version: "3.12"
- task: "h_label_cls"
python-version: "3.12"
- task: "anomaly"
python-version: "3.12"
- task: "keypoint_detection"
python-version: "3.12"
- task: "detection"
python-version: "3.12"
- task: "instance_segmentation"
python-version: "3.12"
- task: "semantic_segmentation"
python-version: "3.12"
name: Integration-Test-${{ matrix.task }}-py312
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Install Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0

- name: Install uv and set the python version
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with:
python-version: "3.12"
- name: Install tox
working-directory: library
run: |
pip install '.[dev]'
- name: Run Integration Test
working-directory: library
run: tox r -vv -e integration-test-${{ matrix.task }} -- --task ${{ matrix.task }} --run-category-only
enable-cache: false
python-version: ${{ matrix.python-version }}
version: "0.8.15"

- name: Installing dependencies
run: uv sync --locked --all-extras --no-extra xpu --dev

- name: Integration testing
run: uv run pytest tests/integration/${{ matrix.task }} --cov --cov-report=xml
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytest command is missing the working directory specification. The command should include working-directory: library or use an explicit path like library/tests/integration/${{ matrix.task }} to ensure tests run from the correct location.

Suggested change
run: uv run pytest tests/integration/${{ matrix.task }} --cov --cov-report=xml
run: uv run pytest tests/integration/${{ matrix.task }} --cov --cov-report=xml
working-directory: library

Copilot uses AI. Check for mistakes.


- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
flags: coverage_integration-test-${{ matrix.task }}_Python-${{ matrix.python-version }}
use_oidc: true

required_check:
name: Required Check lib-lint-and-test
Expand Down
13 changes: 8 additions & 5 deletions library/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ dependencies = [
"einops==0.8.1",
"decord==0.6.0",
"typeguard>=4.3,<4.5",
# TODO(ashwinvaidya17): https://github.com/openvinotoolkit/anomalib/issues/2126
"setuptools<70",
"setuptools",
"lightning==2.4.0",
"torchmetrics==1.6.0",
"pytorchcv==0.0.67",
Expand Down Expand Up @@ -79,7 +78,7 @@ xpu = [

docs = [
"furo",
"myst-parser",
"myst-parser>=2.0.0",
"sphinx==7.2.6",
"pydata-sphinx-theme==0.12.0",
"sphinx-tabs",
Expand All @@ -89,7 +88,6 @@ docs = [
"sphinx-autoapi",
"sphinxemoji",
"nbsphinx",
"myst-parser>=2.0.0",
"linkify-it-py",
]

Expand All @@ -112,6 +110,11 @@ otx = "otx.cli:main"
Documentation = "https://open-edge-platform.github.io/training_extensions/"
Repository = "https://github.com/open-edge-platform/training_extensions/"

[tool.uv]
conflicts = [
[{extra="xpu"}, {extra="cuda"}]
]

[tool.uv.sources]
torch = [
{ index = "torch-xpu", extra = "xpu"},
Expand Down Expand Up @@ -188,7 +191,7 @@ show_error_codes = true
line-length = 120

# minimum target version
target-version = "py38"
target-version = "py310"

# Enumerate all fixed violations.
show-fixes = true
Expand Down
Loading
Loading