Skip to content

Commit 5f337f6

Browse files
authored
Merge pull request #718 from bioimage-io/dev
include bioimageio_schema.json in python package
2 parents 024d56a + bea2149 commit 5f337f6

File tree

18 files changed

+14151
-156
lines changed

18 files changed

+14151
-156
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
python-version: ["3.9", "3.10", "3.11","3.12", "3.13"]
16-
pydantic-version: ["2.10.3", "2.11.0"]
16+
pydantic-version: ["2.10.6", "2.11.9"]
1717
include:
18-
- python-version: "3.12"
19-
pydantic-version: "2.11.0"
18+
- python-version: "3.10"
19+
pydantic-version: "2.11.9"
2020
is-dev-version: true
2121
run-expensive-tests: true
2222
steps:
@@ -50,11 +50,11 @@ jobs:
5050
run: |
5151
pyright --version
5252
pyright -p pyproject.toml --pythonversion ${{ matrix.python-version }}
53-
- run: pytest --cov bioimageio --cov-report xml --cov-append --capture no
53+
- run: pytest --cov bioimageio --cov-append --capture no
5454
env:
5555
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
5656
RUN_EXPENSIVE_TESTS: ${{ matrix.run-expensive-tests && 'true' || 'false' }}
57-
- run: pytest --cov bioimageio --cov-report xml --cov-append --capture no scripts # also test docstrings in scripts for dev-version
57+
- run: pytest --cov bioimageio --cov-append --capture no scripts # also test docstrings in scripts for dev-version
5858
if: ${{matrix.is-dev-version}}
5959
env:
6060
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
@@ -64,35 +64,57 @@ jobs:
6464
with:
6565
path: bioimageio_cache
6666
key: "py${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}"
67-
- if: matrix.is-dev-version && github.event_name == 'pull_request'
68-
uses: orgoro/[email protected]
67+
68+
- run: cp .coverage .coverage.${{ matrix.python-version }}-${{ matrix.pydantic-version }}
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: .coverage.${{ matrix.python-version }}-${{ matrix.pydantic-version }}
72+
retention-days: 1
73+
path: .coverage.${{ matrix.python-version }}-${{ matrix.pydantic-version }}
74+
include-hidden-files: true
75+
coverage:
76+
needs: [test]
77+
if: github.event_name == 'pull_request'
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v4
81+
- uses: actions/setup-python@v6
82+
- run: |
83+
pip install coverage
84+
- uses: actions/download-artifact@v4
85+
with:
86+
pattern: .coverage.*
87+
- run: |
88+
ls -l
89+
coverage combine
90+
coverage xml -o coverage.xml
91+
- uses: orgoro/[email protected]
6992
with:
7093
coverageFile: coverage.xml
7194
token: ${{ secrets.GITHUB_TOKEN }}
7295
thresholdAll: 0.7
7396
thresholdNew: 0.9
7497
thresholdModified: 0.6
75-
- if: matrix.is-dev-version
98+
- name: generate coverage badge and html report
7699
run: |
77100
pip install genbadge[coverage]
78101
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg
79102
coverage html -d dist/coverage
80-
- if: matrix.is-dev-version
81-
uses: actions/upload-artifact@v4
103+
- uses: actions/upload-artifact@v4
82104
with:
83-
name: coverage
105+
name: coverage-summary
84106
retention-days: 1
85107
path: dist
86108

87109

88110
deploy:
89-
needs: [test]
111+
needs: [test,coverage]
90112
runs-on: ubuntu-latest
91113
steps:
92114
- uses: actions/checkout@v4
93115
- uses: actions/download-artifact@v4
94116
with:
95-
name: coverage
117+
name: coverage-summary
96118
path: dist
97119
- uses: actions/setup-python@v6
98120
with:
@@ -108,8 +130,6 @@ jobs:
108130
env:
109131
PYTHONPATH: "./scripts"
110132
run: python -m interactive_docs
111-
- name: Generate JSON schemas
112-
run: python scripts/generate_json_schemas.py
113133
- name: Generate JSON schema documentation
114134
run: python scripts/generate_json_schema_documentation.py
115135
- name: Generate developer docs
@@ -155,7 +175,7 @@ jobs:
155175
shell: bash -l {0}
156176
run: |
157177
mkdir -p ./pkgs/noarch
158-
conda-build -c conda-forge conda-recipe --no-test --output-folder ./pkgs
178+
conda-build -c conda-forge conda-recipe --output-folder ./pkgs
159179
160180
# rattler-build:
161181
# name: Build package
@@ -199,8 +219,7 @@ jobs:
199219
with:
200220
create-tag: false
201221
version-command: |
202-
python -c "from pathlib import Path;p = p_src if (p_src:=Path('src/bioimageio/spec/__init__.py')).exists() else Path('bioimageio/spec/__init__.py');print(p.read_text().split('__version__ = \"')[1].split('\"')[0])"
203-
222+
python -c "from pathlib import Path;print(p_version.read_text().split('VERSION = \"')[1].split('\"')[0] if (p_version:=Path('src/bioimageio/spec/_version.py')).exists() else Path('src/bioimageio/spec/__init__.py').read_text().split('__version__ = \"')[1].split('\"')[0])"
204223
- name: Push tag
205224
id: tag-version
206225
if: github.ref == 'refs/heads/main' && steps.check-version.outputs.previous-version != steps.check-version.outputs.current-version

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
pass_filenames: false
2323
- id: generate json schemas
2424
name: generate json schemas
25-
entry: python scripts/generate_json_schemas.py
25+
entry: python scripts/write_json_schema.py
2626
language: system
2727
always_run: true
2828
pass_filenames: false

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include README.md
22
include LICENSE
33
include src/bioimageio/spec/static/spdx_licenses.json
44
include src/bioimageio/spec/static/tag_categories.json
5+
include src/bioimageio/spec/static/bioimageio_schema.json

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ In this file we log both:
1010

1111
This changelog includes implementation details and my reference the [changes to the Resource Description Format](#changes-to-the-resource-description-format), e.g. in entry [bioimageio.spec 0.5.2](#bioimageiospec-052).
1212

13+
#### bioimageio.spec 0.5.5.4
14+
15+
- include bioimageio_schema.json in python package
16+
- fix issues with setuptools and importlib.metadata.version (by avoiding use of `importlib.metadata.version`)
17+
1318
#### bioimageio.spec 0.5.5.3
1419

1520
- Fix MANIFEST.in

conda-recipe/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% set pyproject = load_file_data('pyproject.toml') %}
22
{% set version_match = load_file_regex(
3-
load_file="src/bioimageio/spec/__init__.py",
4-
regex_pattern='__version__ = "(.+)"') %}
3+
load_file="src/bioimageio/spec/_version.py",
4+
regex_pattern='VERSION = "(.+)"') %}
55
{% set version = version_match[1] %}
66

77
package:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"numpy>=1.21",
1717
"packaging>=17.0",
1818
"platformdirs",
19+
"pydantic-core",
1920
"pydantic-settings>=2.5,<3",
2021
"pydantic>=2.10.3,<2.12",
2122
"python-dateutil",
@@ -64,7 +65,7 @@ build-backend = "setuptools.build_meta"
6465
where = ["src/"]
6566

6667
[tool.setuptools.dynamic]
67-
version = { attr = "bioimageio.spec.__version__" }
68+
version = { attr = "bioimageio.spec._version.VERSION" }
6869

6970
[tool.pyright]
7071
exclude = [

scripts/generate_json_schemas.py

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

scripts/interactive_docs/__main__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import sys
22
from pathlib import Path
33

4-
from typing_extensions import assert_never
4+
from typing_extensions import Final, assert_never
55

6-
from bioimageio.spec import SpecificResourceDescr
7-
from scripts.generate_json_schemas import MAJOR_MINOR_VERSION
6+
from bioimageio.spec import SpecificResourceDescr, __version__
87

98
from . import generate_docs
109

10+
MAJOR_MINOR_VERSION: Final[str] = "v" + "-".join(__version__.split(".")[0:2])
11+
12+
1113
html_result: "str | Exception" = generate_docs(
1214
raw_type=SpecificResourceDescr, root_path=["Delivery"]
1315
)

scripts/write_json_schema.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import json
2+
import sys
3+
from pathlib import Path
4+
5+
from bioimageio.spec._internal.json_schema import generate_json_schema
6+
7+
8+
def write_schema():
9+
schema = generate_json_schema()
10+
path = (
11+
Path(__file__).parent / "../src/bioimageio/spec/static/bioimageio_schema.json"
12+
)
13+
with path.open("w") as f:
14+
json.dump(schema, f, indent=2)
15+
16+
print(f"written `{path}")
17+
18+
19+
if __name__ == "__main__":
20+
sys.exit(write_schema())

src/bioimageio/spec/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
22
.. include:: ../../README.md
33
"""
4-
# ruff: noqa: E402
54

6-
__version__ = "0.5.5.3"
5+
# ruff: noqa: E402
76
from loguru import logger
87

98
logger.disable("bioimageio.spec")
@@ -47,6 +46,7 @@
4746
save_bioimageio_package_to_stream,
4847
)
4948
from ._upload import upload
49+
from ._version import VERSION as __version__
5050
from .application import AnyApplicationDescr, ApplicationDescr
5151
from .dataset import AnyDatasetDescr, DatasetDescr
5252
from .generic import AnyGenericDescr, GenericDescr

0 commit comments

Comments
 (0)