Skip to content

Commit 35c5970

Browse files
authored
Merge pull request #714 from bioimage-io/dev
Housekeeping setup.py -> pyproject.toml and black -> ruff
2 parents bdad347 + bbb05cf commit 35c5970

39 files changed

+459
-528
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
key: "py${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}"
4242
- name: Check autogenerated imports
4343
run: python scripts/generate_version_submodule_imports.py check
44-
- run: black --check .
45-
if: matrix.is-dev-version
4644
- run: ruff check
4745
if: matrix.is-dev-version
46+
- run: ruff format
47+
if: matrix.is-dev-version
4848
- name: Run Pyright
4949
if: matrix.is-dev-version
5050
run: |
@@ -184,11 +184,13 @@ jobs:
184184
cache: 'pip'
185185
- name: Install dependencies
186186
run: |
187-
pip install --upgrade pip
188-
pip install wheel
189-
pip install -e .[tests]
187+
python -m pip install --upgrade pip
188+
pip --version
189+
pip install --upgrade build
190+
pip install .
191+
pip install pytest
190192
- name: Test with pytest
191-
run: pytest
193+
run: pytest --disable-pytest-warnings
192194
- name: Check version submodule imports
193195
run: python scripts/generate_version_submodule_imports.py check
194196
- name: Check if there is a parent commit
@@ -203,7 +205,7 @@ jobs:
203205
with:
204206
create-tag: false
205207
version-command: |
206-
bash -o pipefail -c "cat bioimageio/spec/VERSION | jq -r '.version'"
208+
python -c "from pathlib import Path;print(Path('bioimageio/spec/__init__.py').read_text().split('__version__ = \"')[1].split('\"')[0])"
207209
208210
- name: Push tag
209211
id: tag-version
@@ -215,7 +217,7 @@ jobs:
215217

216218
- name: Build package
217219
run: |
218-
python setup.py sdist bdist_wheel
220+
python -m build
219221
220222
- name: Publish package on PyPI
221223
if: steps.tag-version.outputs.new_tag

.pre-commit-config.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
repos:
2-
- repo: https://github.com/ambv/black
3-
rev: 25.1.0
4-
hooks:
5-
- id: black
62
- repo: https://github.com/astral-sh/ruff-pre-commit
73
rev: v0.12.8
84
hooks:
95
- id: ruff-check
106
args: [--fix, --show-fixes]
7+
- id: ruff-format
118
- repo: local
129
hooks:
1310
- id: pyright

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
include bioimageio/spec/VERSION
21
include README.md
32
include LICENSE
43
include bioimageio/spec/static/spdx_licenses.json

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![conda-version](https://anaconda.org/conda-forge/bioimageio.spec/badges/version.svg)](https://anaconda.org/conda-forge/bioimageio.spec/)
44
[![downloads](https://static.pepy.tech/badge/bioimageio.spec)](https://pepy.tech/project/bioimageio.spec)
55
[![conda-forge downloads](https://img.shields.io/conda/dn/conda-forge/bioimageio.spec.svg?label=conda-forge)](https://anaconda.org/conda-forge/bioimageio.spec/)
6-
![code style](https://img.shields.io/badge/code%20style-black-000000.svg)
6+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
77
[![coverage](https://bioimage-io.github.io/spec-bioimage-io/coverage/coverage-badge.svg)](https://bioimage-io.github.io/spec-bioimage-io/coverage/index.html)
88

99
# Specifications for bioimage.io
@@ -123,4 +123,4 @@ To keep the bioimageio.spec Python package version in sync with the (model) desc
123123

124124
## Δ Changelog
125125

126-
The changelog of the bioimageio.spec Python package and the changes to the resource description format it implements can be found [here](https://github.com/bioimage-io/spec-bioimage-io/blob/main/changelog.md).
126+
The changelog of the bioimageio.spec Python package and the changes to the resource description format it implements can be found in [changelog.md](https://github.com/bioimage-io/spec-bioimage-io/blob/main/changelog.md).

bioimageio/spec/VERSION

Lines changed: 0 additions & 3 deletions
This file was deleted.

bioimageio/spec/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
.. include:: ../../README.md
33
"""
44

5+
__version__ = "0.5.5.0"
6+
7+
58
from . import (
69
application,
710
common,
@@ -24,7 +27,6 @@
2427
from ._get_conda_env import BioimageioCondaEnv, get_conda_env
2528
from ._internal import settings
2629
from ._internal.common_nodes import InvalidDescr
27-
from ._internal.constants import VERSION
2830
from ._internal.validation_context import ValidationContext, get_validation_context
2931
from ._io import (
3032
load_dataset_description,
@@ -50,8 +52,6 @@
5052
from .pretty_validation_errors import enable_pretty_validation_errors_in_ipynb
5153
from .summary import ValidationSummary
5254

53-
__version__ = VERSION
54-
5555
__all__ = [
5656
"__version__",
5757
"AnyApplicationDescr",

bioimageio/spec/_get_conda_env.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ def _get_default_pytorch_env(
160160

161161
# avoid `undefined symbol: iJIT_NotifyEvent` from `torch/lib/libtorch_cpu.so`
162162
# see https://github.com/pytorch/pytorch/issues/123097
163-
if pytorch_version < Version(
164-
"2.1.0" # TODO: check if this is the correct cutoff where the fix is not longer needed
163+
if (
164+
pytorch_version
165+
< Version(
166+
"2.1.0" # TODO: check if this is the correct cutoff where the fix is not longer needed
167+
)
165168
):
166169
deps.append("mkl ==2024.0.0")
167170

bioimageio/spec/_internal/common_nodes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def __pydantic_init_subclass__(cls, **kwargs: Any):
205205
cls.implemented_format_version_tuple = (0, 0, 0)
206206
else:
207207
fv_tuple = get_format_version_tuple(cls.implemented_format_version)
208-
assert (
209-
fv_tuple is not None
210-
), f"failed to cast '{cls.implemented_format_version}' to tuple"
208+
assert fv_tuple is not None, (
209+
f"failed to cast '{cls.implemented_format_version}' to tuple"
210+
)
211211
cls.implemented_format_version_tuple = fv_tuple
212212

213213
@classmethod

bioimageio/spec/_internal/constants.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
from .utils import files
88

9-
with files("bioimageio.spec").joinpath("VERSION").open("r", encoding="utf-8") as f:
10-
VERSION: str = json.load(f)["version"]
11-
assert isinstance(VERSION, str), VERSION
12-
13-
149
DOI_REGEX = ( # lax DOI regex validating the first 7 DOI characters only
1510
r"^10\.[0-9]{4}.+$"
1611
)
@@ -20,8 +15,10 @@
2015
Or you can generate a SHA256 checksum with Python's `hashlib`,
2116
[here is a codesnippet](https://gist.github.com/FynnBe/e64460463df89439cff218bbf59c1100)."""
2217

23-
with files("bioimageio.spec").joinpath("static/tag_categories.json").open(
24-
"r", encoding="utf-8"
18+
with (
19+
files("bioimageio.spec")
20+
.joinpath("static/tag_categories.json")
21+
.open("r", encoding="utf-8")
2522
) as f:
2623
TAG_CATEGORIES: Mapping[str, Mapping[str, Sequence[str]]] = json.load(f)
2724

bioimageio/spec/_internal/gh_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ def set_github_warning(title: str, message: str):
2121
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
2222
print(
2323
f"::warning file={frameinfo.filename},"
24-
+ f"line={frameinfo.lineno},endLine={frameinfo.lineno+1},"
24+
+ f"line={frameinfo.lineno},endLine={frameinfo.lineno + 1},"
2525
+ f"title={title}::{message}"
2626
)

0 commit comments

Comments
 (0)