Skip to content

Commit 6a10672

Browse files
authored
Merge pull request #432 from bioimage-io/zipfile
support zipfile.ZipFile, improve docs and improve get_io_sample_block_metas
2 parents 9815139 + cf48411 commit 6a10672

36 files changed

+839
-604
lines changed

.github/workflows/build.yaml

Lines changed: 84 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,29 @@ jobs:
4949
post-cleanup: 'all'
5050
- name: additional setup
5151
run: pip install --no-deps -e .
52+
- name: Get Date
53+
id: get-date
54+
run: |
55+
echo "date=$(date +'%Y-%b')"
56+
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
57+
shell: bash
58+
- uses: actions/cache@v4
59+
with:
60+
path: bioimageio_cache
61+
key: "test-spec-conda-${{ steps.get-date.outputs.date }}"
5262
- name: pytest-spec-conda
5363
run: pytest --disable-pytest-warnings
64+
env:
65+
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
5466

5567
test-spec-main:
5668
runs-on: ubuntu-latest
5769
strategy:
5870
matrix:
5971
python-version: ['3.8', '3.12']
72+
include:
73+
- python-version: '3.12'
74+
is-dev-version: true
6075
steps:
6176
- uses: actions/checkout@v4
6277
- name: Install Conda environment with Micromamba
@@ -83,35 +98,83 @@ jobs:
8398
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
8499
- name: additional setup core
85100
run: pip install --no-deps -e .
101+
- name: Get Date
102+
id: get-date
103+
run: |
104+
echo "date=$(date +'%Y-%b')"
105+
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
106+
shell: bash
107+
- uses: actions/cache@v4
108+
with:
109+
path: bioimageio_cache
110+
key: "test-spec-main-${{ steps.get-date.outputs.date }}"
86111
- name: pytest-spec-main
87112
run: pytest --disable-pytest-warnings
88-
- if: matrix.python-version == '3.12' && github.event_name == 'pull_request'
113+
env:
114+
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
115+
- if: matrix.is-dev-version && github.event_name == 'pull_request'
89116
uses: orgoro/[email protected]
90117
with:
91118
coverageFile: coverage.xml
92119
token: ${{ secrets.GITHUB_TOKEN }}
93-
- if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main'
120+
- if: matrix.is-dev-version && github.ref == 'refs/heads/main'
94121
run: |
95122
pip install genbadge[coverage]
96123
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg
97124
coverage html -d dist/coverage
98-
- if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main'
125+
- if: matrix.is-dev-version && github.ref == 'refs/heads/main'
99126
uses: actions/upload-artifact@v4
100127
with:
101128
name: coverage
102129
retention-days: 1
103130
path: dist
104131

105132

106-
test-tf:
133+
test-spec-main-tf:
107134
runs-on: ubuntu-latest
108135
strategy:
109136
matrix:
110-
python-version: ['3.9', '3.11']
137+
python-version: ['3.9', '3.12']
111138
steps:
112139
- uses: actions/checkout@v4
113-
- name: Install Conda environment with Micromamba
114-
uses: mamba-org/setup-micromamba@v1
140+
- uses: mamba-org/setup-micromamba@v1
141+
with:
142+
cache-downloads: true
143+
cache-environment: true
144+
environment-file: dev/env-tf.yaml
145+
condarc: |
146+
channel-priority: flexible
147+
create-args: >-
148+
python=${{ matrix.python-version }}
149+
post-cleanup: 'all'
150+
- name: additional setup spec
151+
run: |
152+
conda remove --yes --force bioimageio.spec || true # allow failure for cached env
153+
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
154+
- name: additional setup core
155+
run: pip install --no-deps -e .
156+
- name: Get Date
157+
id: get-date
158+
run: |
159+
echo "date=$(date +'%Y-%b')"
160+
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
161+
shell: bash
162+
- uses: actions/cache@v4
163+
with:
164+
path: bioimageio_cache
165+
key: "test-spec-main-tf-${{ steps.get-date.outputs.date }}"
166+
- run: pytest --disable-pytest-warnings
167+
env:
168+
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
169+
170+
test-spec-conda-tf:
171+
runs-on: ubuntu-latest
172+
strategy:
173+
matrix:
174+
python-version: ['3.9', '3.12']
175+
steps:
176+
- uses: actions/checkout@v4
177+
- uses: mamba-org/setup-micromamba@v1
115178
with:
116179
cache-downloads: true
117180
cache-environment: true
@@ -123,8 +186,20 @@ jobs:
123186
post-cleanup: 'all'
124187
- name: additional setup
125188
run: pip install --no-deps -e .
189+
- name: Get Date
190+
id: get-date
191+
run: |
192+
echo "date=$(date +'%Y-%b')"
193+
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
194+
shell: bash
195+
- uses: actions/cache@v4
196+
with:
197+
path: bioimageio_cache
198+
key: "test-spec-conda-tf-${{ steps.get-date.outputs.date }}"
126199
- name: pytest-spec-tf
127200
run: pytest --disable-pytest-warnings
201+
env:
202+
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
128203

129204
conda-build:
130205
runs-on: ubuntu-latest
@@ -164,20 +239,11 @@ jobs:
164239
path: dist
165240
- uses: actions/setup-python@v5
166241
with:
167-
python-version: '3.12'
242+
python-version: '3.13'
168243
cache: 'pip'
169244
- run: pip install -e .[dev]
170-
- id: get_version
171-
run: python -c 'import bioimageio.core;print(f"version={bioimageio.core.__version__}")' >> $GITHUB_OUTPUT
172245
- name: Generate developer docs
173-
run: |
174-
pdoc \
175-
--docformat google \
176-
--logo https://bioimage.io/static/img/bioimage-io-logo.svg \
177-
--logo-link https://bioimage.io/ \
178-
--favicon https://bioimage.io/static/img/bioimage-io-icon-small.svg \
179-
--footer-text 'bioimageio.core ${{steps.get_version.outputs.version}}' \
180-
-o ./dist bioimageio.core
246+
run: ./scripts/pdoc/run.sh
181247
- run: cp README.md ./dist/README.md
182248
- name: copy rendered presentations
183249
run: |

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,24 @@ The model specification and its validation tools can be found at <https://github
375375

376376
## Changelog
377377

378+
### 0.7.0
379+
380+
- breaking:
381+
- bioimageio CLI now has implicit boolean flags
382+
- non-breaking:
383+
- use new `ValidationDetail.recommended_env` in `ValidationSummary`
384+
- improve `get_io_sample_block_metas()`
385+
- now works for sufficiently large, but not exactly shaped inputs
386+
- update to support `zipfile.ZipFile` object with bioimageio.spec==0.5.3.5
387+
- add io helpers `resolve` and `resolve_and_extract`
388+
- added `enable_determinism` function and **determinism** input argument for testing with seeded
389+
random generators and optionally (determinsim=="full") instructing DL frameworks to use
390+
deterministic algorithms.
391+
392+
### 0.6.10
393+
394+
- fix #423
395+
378396
### 0.6.9
379397

380398
- improve bioimageio command line interface (details in #157)

bioimageio/core/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "0.6.10"
2+
"version": "0.7.0"
33
}

bioimageio/core/__init__.py

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

5-
from bioimageio.core.stat_measures import Stat
65
from bioimageio.spec import (
76
build_description,
87
dump_description,
@@ -16,16 +15,38 @@
1615
validate_format,
1716
)
1817

19-
from . import digest_spec
18+
from . import (
19+
axis,
20+
block_meta,
21+
cli,
22+
commands,
23+
common,
24+
digest_spec,
25+
io,
26+
model_adapters,
27+
prediction,
28+
proc_ops,
29+
proc_setup,
30+
sample,
31+
stat_calculators,
32+
stat_measures,
33+
tensor,
34+
)
2035
from ._prediction_pipeline import PredictionPipeline, create_prediction_pipeline
21-
from ._resource_tests import load_description_and_test, test_description, test_model
36+
from ._resource_tests import (
37+
enable_determinism,
38+
load_description_and_test,
39+
test_description,
40+
test_model,
41+
)
2242
from ._settings import settings
2343
from .axis import Axis, AxisId
2444
from .block_meta import BlockMeta
2545
from .common import MemberId
2646
from .prediction import predict, predict_many
2747
from .sample import Sample
2848
from .stat_calculators import compute_dataset_measures
49+
from .stat_measures import Stat
2950
from .tensor import Tensor
3051
from .utils import VERSION
3152

@@ -34,19 +55,29 @@
3455

3556
# aliases
3657
test_resource = test_description
58+
"""alias of `test_description`"""
3759
load_resource = load_description
60+
"""alias of `load_description`"""
3861
load_model = load_model_description
62+
"""alias of `load_model_description`"""
3963

4064
__all__ = [
4165
"__version__",
66+
"axis",
4267
"Axis",
4368
"AxisId",
69+
"block_meta",
4470
"BlockMeta",
4571
"build_description",
72+
"cli",
73+
"commands",
74+
"common",
4675
"compute_dataset_measures",
4776
"create_prediction_pipeline",
4877
"digest_spec",
4978
"dump_description",
79+
"enable_determinism",
80+
"io",
5081
"load_dataset_description",
5182
"load_description_and_test",
5283
"load_description_and_validate_format_only",
@@ -55,15 +86,23 @@
5586
"load_model",
5687
"load_resource",
5788
"MemberId",
89+
"model_adapters",
5890
"predict_many",
5991
"predict",
92+
"prediction",
6093
"PredictionPipeline",
94+
"proc_ops",
95+
"proc_setup",
96+
"sample",
6197
"Sample",
6298
"save_bioimageio_package_as_folder",
6399
"save_bioimageio_package",
64100
"save_bioimageio_yaml_only",
65101
"settings",
102+
"stat_calculators",
103+
"stat_measures",
66104
"Stat",
105+
"tensor",
67106
"Tensor",
68107
"test_description",
69108
"test_model",

bioimageio/core/_prediction_pipeline.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,20 @@ def predict_sample_without_blocking(
164164
if out is not None
165165
},
166166
stat=sample.stat,
167-
id=self.get_output_sample_id(sample.id),
167+
id=sample.id,
168168
)
169169
if not skip_postprocessing:
170170
self.apply_postprocessing(output)
171171

172172
return output
173173

174174
def get_output_sample_id(self, input_sample_id: SampleId):
175-
if input_sample_id is None:
176-
return None
177-
else:
178-
return f"{input_sample_id}_" + (
179-
self.model_description.id or self.model_description.name
180-
)
175+
warnings.warn(
176+
"`PredictionPipeline.get_output_sample_id()` is deprecated and will be"
177+
+ " removed soon. Output sample id is equal to input sample id, hence this"
178+
+ " function is not needed."
179+
)
180+
return input_sample_id
181181

182182
def predict_sample_with_fixed_blocking(
183183
self,

0 commit comments

Comments
 (0)