Skip to content

Commit 75a3532

Browse files
authored
Merge pull request #474 from bioimage-io/dev
Improve testing in dedicated conda env
2 parents b30173f + 25c6ccb commit 75a3532

File tree

17 files changed

+563
-314
lines changed

17 files changed

+563
-314
lines changed

.github/workflows/build.yaml

Lines changed: 70 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
- name: Install dependencies
4545
if: steps.look-up.outputs.cache-hit != 'true'
4646
run: |
47-
pip install --upgrade pip
4847
pip install -e .[dev]
4948
- run: pytest --disable-pytest-warnings tests/test_bioimageio_collection.py::test_rdf_format_to_populate_cache
5049
if: steps.look-up.outputs.cache-hit != 'true'
@@ -94,7 +93,7 @@ jobs:
9493
path: bioimageio_cache
9594
key: ${{needs.populate-cache.outputs.cache-key}}
9695
- name: pytest
97-
run: pytest --cov bioimageio --cov-report xml --cov-append --capture no --disable-pytest-warnings
96+
run: pytest --cov bioimageio.core --cov-append --capture no --disable-pytest-warnings
9897
env:
9998
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
10099
RUN_EXPENSIVE_TESTS: ${{ matrix.run-expensive-tests && 'true' || 'false' }}
@@ -105,25 +104,50 @@ jobs:
105104
path: bioimageio_cache
106105
key: ${{needs.populate-cache.outputs.cache-key}}
107106

108-
- if: matrix.report-coverage && github.event_name == 'pull_request'
109-
uses: orgoro/[email protected]
107+
- run: cp .coverage .coverage.${{matrix.python-version}}-${{matrix.numpy-version}}
108+
- uses: actions/upload-artifact@v4
109+
with:
110+
name: .coverage.${{matrix.python-version}}-${{matrix.numpy-version}}
111+
retention-days: 1
112+
path: .coverage.${{matrix.python-version}}-${{matrix.numpy-version}}
113+
include-hidden-files: true
114+
115+
coverage:
116+
needs: [test]
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v4
120+
- uses: actions/setup-python@v6
121+
- run: |
122+
pip install coverage
123+
- uses: actions/download-artifact@v4
124+
with:
125+
pattern: .coverage.*
126+
merge-multiple: true
127+
- run: |
128+
ls -la .coverage*
129+
coverage combine
130+
coverage xml -o coverage.xml
131+
- uses: orgoro/[email protected]
110132
with:
111133
coverageFile: coverage.xml
112-
token: ${{secrets.GITHUB_TOKEN}}
113-
- if: matrix.report-coverage && github.ref == 'refs/heads/main'
134+
token: ${{ secrets.GITHUB_TOKEN }}
135+
thresholdAll: 0.7
136+
thresholdNew: 0.9
137+
thresholdModified: 0.6
138+
- name: generate coverage badge and html report
114139
run: |
115140
pip install genbadge[coverage]
116141
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg
117142
coverage html -d dist/coverage
118-
- if: matrix.report-coverage && github.ref == 'refs/heads/main'
119-
uses: actions/upload-artifact@v4
143+
- uses: actions/upload-artifact@v4
120144
with:
121-
name: coverage
145+
name: coverage-summary
122146
retention-days: 1
123147
path: dist
124148

125149
conda-build:
126-
needs: test
150+
needs: test # only so we run tests even if the pinned bioimageio.spec version is not yet published on conda-forge yet
127151
runs-on: ubuntu-latest
128152
steps:
129153
- uses: actions/checkout@v4
@@ -159,7 +183,7 @@ jobs:
159183
- uses: actions/checkout@v4
160184
- uses: actions/download-artifact@v4
161185
with:
162-
name: coverage
186+
name: coverage-summary
163187
path: dist
164188
- uses: actions/setup-python@v6
165189
with:
@@ -179,65 +203,66 @@ jobs:
179203
branch: gh-pages
180204
folder: dist
181205

182-
pip-build:
183-
name: Build with pip and publish to PyPI
184-
needs: [test, conda-build]
206+
build:
185207
runs-on: ubuntu-latest
186208
steps:
187-
- name: Check out the repository
188-
uses: actions/checkout@v4
189-
with:
190-
fetch-depth: 2
191-
192-
- name: Set up Python
193-
uses: actions/setup-python@v6
209+
- uses: actions/checkout@v4
210+
- uses: actions/setup-python@v6
194211
with:
195212
python-version: '3.10'
213+
cache: 'pip'
196214
- name: Install dependencies
197-
run: |
198-
python -m pip install --upgrade pip
199-
pip --version
200-
pip install --upgrade build
201-
pip install .
215+
run: pip install --upgrade build
202216
- name: Build package
203-
run: |
204-
python -m build
217+
run: python -m build
218+
- uses: actions/upload-artifact@v4
219+
with:
220+
path: dist/
221+
name: dist
205222

223+
publish:
224+
needs: [test, build, conda-build, docs]
225+
runs-on: ubuntu-latest
226+
environment:
227+
name: release
228+
url: https://pypi.org/project/bioimageio.core/
229+
permissions:
230+
contents: write # required for tag creation
231+
id-token: write # required for pypi publish action
232+
steps:
233+
- name: Check out the repository
234+
uses: actions/checkout@v4
235+
with:
236+
fetch-depth: 2
206237
- name: Check if there is a parent commit
207238
id: check-parent-commit
208239
run: |
209240
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
210241
211242
- name: Detect new version
212-
id: check-version
243+
id: tag-version
213244
if: github.ref == 'refs/heads/main' && steps.check-parent-commit.outputs.sha
214245
uses: salsify/[email protected]
215246
with:
216-
create-tag: false
247+
create-tag: true
217248
version-command: |
218249
python -c "from pathlib import Path;import json;print(p_src.read_text().split('__version__ = \"')[1].split('\"')[0] if (p_src:=Path('src/bioimageio/core/__init__.py')).exists() else json.loads(Path('bioimageio/core/VERSION').read_text())['version'])"
219-
220-
- name: Push tag
221-
id: tag-version
222-
if: github.ref == 'refs/heads/main' && steps.check-version.outputs.previous-version != steps.check-version.outputs.current-version
223-
uses: mathieudutour/[email protected]
250+
- uses: actions/download-artifact@v4
251+
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.tag
224252
with:
225-
github_token: ${{ secrets.GITHUB_TOKEN }}
226-
custom_tag: ${{ steps.check-version.outputs.current-version }}
227-
253+
name: dist
254+
path: dist
228255
- name: Publish package on PyPI
229-
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.new_tag
230-
uses: pypa/gh-action-pypi-publish@release/v1.12
256+
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.tag
257+
uses: pypa/gh-action-pypi-publish@release/v1
231258
with:
232-
user: __token__
233-
password: '${{ secrets.PYPI_TOKEN }}'
234259
packages-dir: dist/
235-
verbose: true
260+
236261
- name: Publish the release notes
237262
if: github.ref == 'refs/heads/main'
238263
uses: release-drafter/[email protected]
239264
with:
240-
publish: "${{ steps.tag-version.outputs.new_tag != '' }}"
241-
tag: '${{ steps.tag-version.outputs.new_tag }}'
265+
publish: "${{ steps.tag-version.outputs.tag != '' }}"
266+
tag: '${{ steps.tag-version.outputs.tag }}'
242267
env:
243268
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,24 @@ stats: inputs/dataset_statistics.json
347347
348348
## Set up Development Environment
349349
350-
To set up a development conda environment run the following commands:
350+
To set up a development environment run the following commands:
351351
352352
```console
353-
conda env create -f dev/env.yaml
353+
conda create -n core python=$(grep -E '^requires-python' pyproject.toml | grep -oE '[0-9]+\.[0-9]+')
354354
conda activate core
355-
pip install -e . --no-deps
355+
pip install -e .[dev,partners]
356356
```
357357

358-
There are different environment files available that only install tensorflow or pytorch as dependencies, see [dev folder](https://github.com/bioimage-io/core-bioimage-io-python/tree/main/dev).
358+
### Joint development of bioimageio.spec and bioimageio.core
359+
360+
Assuming [spec-bioimage-io](https://github.com/bioimage-io/spec-bioimage-io) is cloned to the parent folder
361+
a joint development environment can be created with the following commands:
362+
363+
```console
364+
conda create -n core python=$(grep -E '^requires-python' pyproject.toml | grep -oE '[0-9]+\.[0-9]+')
365+
conda activate core
366+
pip install -e .[dev,partners] -e ../spec-bioimage-io[dev]
367+
```
359368

360369
## Logging level
361370

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 0.9.5
2+
3+
- bump bioimageio.spec library version to 0.5.6.0
4+
- improved ONNX export from pytorch state dict or torchscript using torch dynamo
5+
- default `opset_version` for `pytorch_to_onnx`/`torchscript_for_onnx` conversions bumped to 18.
6+
17
### 0.9.4
28

39
- bump bioimageio.spec library version to 0.5.5.6

conda-recipe/meta.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ test:
5454
- tests
5555
requires:
5656
{% for dep in pyproject['project']['optional-dependencies']['dev'] %}
57-
{% if dep.startswith('torch>=') %} # pip: torch -> conda: pytorch
58-
- py{{ dep.lower() }}
59-
{% else %}
57+
{% if 'torch' not in dep %} # can't install pytorch>=2.8 from conda-forge smh
6058
- {{ dep.lower().replace('_', '-') }}
6159
{% endif %}
6260
{% endfor %}

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ requires-python = ">=3.9"
66
readme = "README.md"
77
dynamic = ["version"]
88
dependencies = [
9-
"bioimageio.spec ==0.5.5.6",
9+
"bioimageio.spec ==0.5.6.0",
1010
"h5py",
1111
"imagecodecs",
1212
"imageio>=2.10",
@@ -40,7 +40,7 @@ Documentation = "https://bioimage-io.github.io/core-bioimage-io-python/bioimagei
4040
Source = "https://github.com/bioimage-io/core-bioimage-io-python"
4141

4242
[project.optional-dependencies]
43-
onnx = ["onnxruntime"]
43+
onnx = ["onnxruntime", "onnxscript"]
4444
pytorch = ["torch>=1.6,<3", "torchvision>=0.21", "keras>=3.0,<4"]
4545
tensorflow = ["tensorflow", "keras>=2.15,<4"]
4646
partners = [
@@ -59,10 +59,11 @@ dev = [
5959
"numpy",
6060
"onnx",
6161
"onnxruntime",
62+
"onnxscript",
6263
"packaging>=17.0",
6364
"pdoc",
6465
"pre-commit",
65-
"pyright==1.1.404",
66+
"pyright==1.1.407",
6667
"pytest-cov",
6768
"pytest",
6869
"python-dotenv",
@@ -124,7 +125,6 @@ testpaths = ["src", "tests"]
124125

125126
[tool.ruff]
126127
line-length = 88
127-
target-version = "py39"
128128
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
129129
exclude = [
130130
"presentations",

src/bioimageio/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
# ruff: noqa: E402
55

6-
__version__ = "0.9.4"
6+
__version__ = "0.9.5"
77
from loguru import logger
88

99
logger.disable("bioimageio.core")

0 commit comments

Comments
 (0)