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
61 changes: 61 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: pre-commit (PR only on changed files)

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
detect_changes:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.changed_files.outputs.changed }}

steps:
- name: Checkout full history
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Detect changed files
id: changed_files
run: |
git fetch origin ${{ github.base_ref }}
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)

{
echo "changed<<EOF"
echo "$CHANGED_FILES"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Show changed files
run: |
echo "Changed files:"
echo "${{ steps.changed_files.outputs.changed }}"

precommit:
needs: detect_changes
runs-on: ubuntu-latest
if: ${{ needs.detect_changes.outputs.changed != '' }}

steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit (CI check-only stage) on changed files
env:
CHANGED_FILES: ${{ needs.detect_changes.outputs.changed }}
run: |
mapfile -t files <<< "$CHANGED_FILES"
pre-commit run --hook-stage manual --files "${files[@]}" --show-diff-on-failure
19 changes: 13 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-docstring-first
- id: check-added-large-files
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: name-tests-test
- id: trailing-whitespace
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v3.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
rev: v0.15.4
hooks:
# Run the formatter.
- id: ruff-format
# Run the linter.
- id: ruff-check
args: [--fix,--unsafe-fixes]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.16.2
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.25
hooks:
- id: validate-pyproject
- repo: https://github.com/tlambert03/napari-plugin-checks
rev: v0.3.0
hooks:
Expand Down
98 changes: 89 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,99 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools_scm"]
build-backend = "setuptools.build_meta"
requires = [ "setuptools>=77", "setuptools-scm[toml]>=7", "wheel" ]

[tool.ruff]
lint.select = ["E", "F", "B", "I", "UP"]
lint.ignore = ["E741"]
target-version = "py310"
fix = true
line-length = 120
[project]
name = "napari-deeplabcut"
description = "napari + DeepLabCut annotation tool"
readme = { file = "README.md", content-type = "text/markdown" }
license = "LGPL-3.0-only"
license-files = [ "LICENSE" ]
requires-python = ">=3.10"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Framework :: napari",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Scientific/Engineering :: Visualization",
]
# Using setuptools-scm -> version is derived from git tags
dynamic = [ "version" ]
dependencies = [
"dask-image",
"matplotlib>=3.3",
"napari==0.6.6",
"natsort",
"numpy>=1.18.5,<2",
"opencv-python-headless",
"pandas",
"pyside6>=6.4.2",
"pyyaml",
"qtpy>=2.4",
"scikit-image",
"scipy",
"tables",
]
[[project.authors]]
name = "Team DeepLabCut, led by Jessy Lauer"
email = "admin@deeplabcut.org"
[project.entry-points."napari.manifest"]
napari-deeplabcut = "napari_deeplabcut:napari.yaml"
[project.optional-dependencies]
testing = [
"pillow",
"pytest",
"pytest-cov",
"pytest-qt",
"tox",
]
[project.urls]
"Bug Tracker" = "https://github.com/DeepLabCut/napari-deeplabcut/issues"
Documentation = "https://github.com/DeepLabCut/napari-deeplabcut#README.md"
"Source Code" = "https://github.com/DeepLabCut/napari-deeplabcut"
"User Support" = "https://github.com/DeepLabCut/napari-deeplabcut/issues"

[tool.uv]
package = true
# ----------------------------
# setuptools configuration
# ----------------------------
[tool.setuptools]
include-package-data = true
[tool.setuptools.package-data]
napari_deeplabcut = [ "napari.yaml" ]
[tool.setuptools.package-dir]
"" = "src"
[tool.setuptools.packages.find]
where = [ "src" ]

[tool.setuptools_scm]
write_to = "src/napari_deeplabcut/_version.py"

[tool.uv]
package = true

# ----------------------------
# existing tool configuration
# ----------------------------
[tool.ruff]
target-version = "py310"
line-length = 120
fix = true
[tool.ruff.lint]
select = [ "E", "F", "B", "I", "UP" ]
ignore = [ "E741" ]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.pyproject-fmt]
max_supported_python = "3.12"
generate_python_version_classifiers = true
# Avoid collapsing tables to field.key = value format (less readable)
table_format = "long"

[tool.pytest.ini_options]
qt_api = "pyside6"
67 changes: 0 additions & 67 deletions setup.cfg

This file was deleted.

4 changes: 3 additions & 1 deletion src/napari_deeplabcut/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
# FIXME: Circumvent the need to access window.qt_viewer
warnings.filterwarnings("ignore", category=FutureWarning)

import re
import re # noqa: E402

# Suppress RuntimeWarnings caused by NaN values in dataframe
# (encountered during model-predicted labels refinement stage)
warnings.filterwarnings(
Expand All @@ -49,6 +50,7 @@
message=re.escape("invalid value encountered in cast"),
)


class VispyWarningFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
ignore_messages = (
Expand Down
2 changes: 1 addition & 1 deletion src/napari_deeplabcut/_tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def test_lazy_imread_grayscale_and_rgba(tmp_path):
gray = (np.random.rand(10, 10) * 255).astype(np.uint8)
rgba = (np.random.rand(10, 10, 4) * 255).astype(np.uint8)
p1, p2 = tmp_path / "g.png", tmp_path / "r.png"
cv2.imwrite(str(p1), gray) # cv2 writes grayscale as-is; color images are written as BGR
cv2.imwrite(str(p1), gray) # cv2 writes grayscale as-is; color images are written as BGR
cv2.imwrite(str(p2), cv2.cvtColor(rgba, cv2.COLOR_RGBA2BGRA))
res = _reader._lazy_imread([p1, p2], use_dask=False, stack=False)
assert all(img.shape[-1] == 3 for img in res)
Expand Down
2 changes: 1 addition & 1 deletion src/napari_deeplabcut/assets/napari_shortcuts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/napari_deeplabcut/assets/superanimal_quadruped.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@
707.5655627887081,
375.0788206592507
]
}
}
2 changes: 1 addition & 1 deletion src/napari_deeplabcut/assets/superanimal_topviewmouse.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@
117.41024099594408,
252.35239163633167
]
}
}
2 changes: 1 addition & 1 deletion src/napari_deeplabcut/styles/dark.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ axes.labelcolor : f0f1f2
axes.facecolor : none
axes.edgecolor : 414851
xtick.color : f0f1f2
ytick.color : f0f1f2
ytick.color : f0f1f2
2 changes: 1 addition & 1 deletion src/napari_deeplabcut/styles/light.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ axes.labelcolor : 3b3a39
axes.facecolor : none
axes.edgecolor : d6d0ce
xtick.color : 3b3a39
ytick.color : 3b3a39
ytick.color : 3b3a39