Skip to content
Merged
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
65 changes: 65 additions & 0 deletions .github/workflows/code-style-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Code Style Checks

on:
push:
branches:
- master
- "*.*.*"
paths:
- "**.py"
- "setup.cfg"
- "requirements-dev.txt"
- "pyproject.toml"
- ".pre-commit-config.yaml"
- ".github/workflows/code-style-checks.yml"
- "!assets/**"
- "!docker/**"
- "!docs/**"
- "!conda.recipe"
pull_request:
paths:
- "**.py"
- "setup.cfg"
- "requirements-dev.txt"
- "pyproject.toml"
- ".pre-commit-config.yaml"
- ".github/workflows/code-style-checks.yml"
- "!assets/**"
- "!docker/**"
- "!docs/**"
- "!conda.recipe"
workflow_dispatch:

concurrency:
# <workflow_name>-<branch_name>-<true || commit_sha (if branch is protected)>
group: code-style-${{ github.ref_name }}-${{ !(github.ref_protected) || github.sha }}
cancel-in-progress: true

jobs:
code-style:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.13"]

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v6
with:
version: "latest"
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: true
cache-dependency-glob: |
**/requirements-dev.txt
**/pyproject.toml

- name: Install dependencies
run: |
uv pip install pre-commit
uv pip install -r requirements-dev.txt
uv pip install -e .

- name: Run pre-commit checks
run: pre-commit run --all-files --show-diff-on-failure
40 changes: 0 additions & 40 deletions .github/workflows/code-style.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/typing-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Type Checking

on:
push:
branches:
- master
- "*.*.*"
paths:
- "ignite/**"
- "examples/**.py"
- "tests/ignite/**"
- "requirements-dev.txt"
- "pyproject.toml"
- "mypy.ini"
- ".github/workflows/typing-checks.yml"
pull_request:
paths:
- "ignite/**"
- "examples/**.py"
- "tests/ignite/**"
- "requirements-dev.txt"
- "pyproject.toml"
- "mypy.ini"
- ".github/workflows/typing-checks.yml"
workflow_dispatch:

concurrency:
# <workflow_name>-<branch_name>-<true || commit_sha (if branch is protected)>
group: typing-${{ github.ref_name }}-${{ !(github.ref_protected) || github.sha }}
cancel-in-progress: true

jobs:
mypy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.13"]
pytorch-channel: [pytorch]

steps:
- uses: actions/checkout@v4

- name: Get year & week number
id: get-date
run: |
echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT

- uses: astral-sh/setup-uv@v6
with:
version: "latest"
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: true
cache-suffix: "${{ steps.get-date.outputs.date }}-typing-${{ runner.os }}-${{ matrix.python-version }}"
cache-dependency-glob: |
**/requirements-dev.txt
**/pyproject.toml

- name: Install PyTorch
run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu

- name: Install dependencies
run: |
uv pip install -r requirements-dev.txt
uv pip install .
uv pip install mypy

- name: Run MyPy type checking
run: mypy
11 changes: 0 additions & 11 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,6 @@ jobs:
uv pip install .
uv pip list

- name: Check code formatting
run: |
pre-commit run -a

- name: Run Mypy
# https://github.com/pytorch/ignite/pull/2780
#
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
mypy

# Download MNIST: https://github.com/pytorch/ignite/issues/1737
# to "/tmp" for unit tests
- name: Download MNIST
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ conda_build/

.neptune/
pytest.ini

.vscode/*
12 changes: 8 additions & 4 deletions ignite/handlers/clearml_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class ClearMLLogger(BaseLogger):

"""

_task: Any

def __init__(self, **kwargs: Any):
try:
from clearml import Task
Expand Down Expand Up @@ -823,6 +825,8 @@ class ClearMLSaver(DiskSaver):

"""

_task: Any

def __init__(
self,
logger: Optional[ClearMLLogger] = None,
Expand Down Expand Up @@ -858,7 +862,7 @@ def _setup_check_clearml(self, logger: ClearMLLogger, output_uri: str) -> None:
except ImportError:
try:
# Backwards-compatibility for legacy Trains SDK
from trains import Task
from trains import Task # type: ignore[no-redef]
except ImportError:
raise ModuleNotFoundError(
"This contrib module requires clearml to be installed. "
Expand Down Expand Up @@ -933,7 +937,7 @@ def __call__(self, checkpoint: Mapping, filename: str, metadata: Optional[Mappin
except ImportError:
try:
# Backwards-compatibility for legacy Trains SDK
from trains.binding.frameworks import WeightsFileHandler
from trains.binding.frameworks import WeightsFileHandler # type: ignore[no-redef]
except ImportError:
raise ModuleNotFoundError(
"This contrib module requires clearml to be installed. "
Expand All @@ -957,8 +961,8 @@ def __call__(self, checkpoint: Mapping, filename: str, metadata: Optional[Mappin
metadata=metadata,
)

pre_cb_id = WeightsFileHandler.add_pre_callback(cb_context.pre_callback)
post_cb_id = WeightsFileHandler.add_post_callback(cb_context.post_callback)
pre_cb_id = WeightsFileHandler.add_pre_callback(cb_context.pre_callback) # type: ignore[arg-type]
post_cb_id = WeightsFileHandler.add_post_callback(cb_context.post_callback) # type: ignore[arg-type]

try:
super(ClearMLSaver, self).__call__(checkpoint, filename, metadata)
Expand Down
Loading