Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support zipfile.ZipFile, improve docs and improve get_io_sample_block_metas #432

Merged
merged 49 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fa050eb
WIP update for download returning zipfile.Path
FynnBe Oct 31, 2024
29f45f2
expose submodules explicitly
FynnBe Nov 5, 2024
e38a79e
use resolve_and_extract in _import_from_file_impl
FynnBe Nov 5, 2024
5cef0f4
avoid circular imports
FynnBe Nov 5, 2024
6ef4a2d
update use of ValidationDetail
FynnBe Nov 5, 2024
eaa424f
update dev envs
FynnBe Nov 7, 2024
18bed26
add docstinrgs and annotations
FynnBe Nov 7, 2024
3fbf0c5
improve get_io_sample_block_metas
FynnBe Nov 7, 2024
2705e74
raise ValueError instead of assertion
FynnBe Nov 7, 2024
51b3fa3
update to spec changes
FynnBe Nov 7, 2024
3f81091
update python versions for tools
FynnBe Nov 7, 2024
f052891
add test case predict
FynnBe Nov 8, 2024
d315075
improve coverage reporting
FynnBe Nov 8, 2024
b1bf3d2
merge main
FynnBe Nov 8, 2024
4de7672
update pdoc doc generation
FynnBe Nov 8, 2024
b1225b7
pyright fixes
FynnBe Nov 11, 2024
25ac8d3
black
FynnBe Nov 11, 2024
4941dc1
ignore presentations folder
FynnBe Nov 11, 2024
07989d3
update test_bioimageio_spec_version
FynnBe Nov 11, 2024
20545fa
reenable test_get_block_transform
FynnBe Nov 11, 2024
29ed684
use new cli_implicit_flags config
FynnBe Nov 11, 2024
067f24d
use ZipPath instead of zipfile.Path
FynnBe Nov 11, 2024
fe993d0
fix test_bioimageio_spec_version
FynnBe Nov 11, 2024
f4efbaa
update CLI
FynnBe Nov 11, 2024
5f52b15
fix test predict --example command
FynnBe Nov 12, 2024
91f2b87
update get_example_command
FynnBe Nov 12, 2024
53596f6
update changelog
FynnBe Nov 12, 2024
815d87f
blockwise
FynnBe Nov 12, 2024
8a8cb00
add test_commands
FynnBe Nov 12, 2024
a9d1132
WIP add test_prediction
FynnBe Nov 12, 2024
c97a893
use bioimageio cache
FynnBe Nov 13, 2024
f9c3bf0
fix typo
FynnBe Nov 13, 2024
27ef747
WIP fix tests and cleanup
FynnBe Nov 13, 2024
0043abf
fix deprecation warning
FynnBe Nov 14, 2024
4da6766
fix assert_never import
FynnBe Nov 14, 2024
4cbf9ef
add explicit support for h5
FynnBe Nov 15, 2024
37acc79
improve error messages for split_multiple_shapes_into_blocks
FynnBe Nov 15, 2024
f155c9d
adapt test to multi tensor model
FynnBe Nov 15, 2024
150df64
fix docstring test
FynnBe Nov 15, 2024
b8bad0b
bump minor and spec
FynnBe Nov 15, 2024
a1b6f5c
add enable_determinism
FynnBe Nov 15, 2024
324f15c
use determinism and refactor decimal
FynnBe Nov 15, 2024
b40c0e5
update changelog
FynnBe Nov 15, 2024
e34ad21
pin tifffile
FynnBe Nov 18, 2024
e5deb74
test with py3.13 and for TF with spec-main
FynnBe Nov 18, 2024
ee80605
test up to py3.12 (onnxruntime and tf not available for py3.13)
FynnBe Nov 18, 2024
bcc905e
tf 2.15 requires py>=3.9
FynnBe Nov 18, 2024
07cc873
bump spec version
FynnBe Nov 18, 2024
cf48411
remove tifffile dep (now in spec)
FynnBe Nov 18, 2024
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
102 changes: 84 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,29 @@ jobs:
post-cleanup: 'all'
- name: additional setup
run: pip install --no-deps -e .
- name: Get Date
id: get-date
run: |
echo "date=$(date +'%Y-%b')"
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: bioimageio_cache
key: "test-spec-conda-${{ steps.get-date.outputs.date }}"
- name: pytest-spec-conda
run: pytest --disable-pytest-warnings
env:
BIOIMAGEIO_CACHE_PATH: bioimageio_cache

test-spec-main:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.12']
include:
- python-version: '3.12'
is-dev-version: true
steps:
- uses: actions/checkout@v4
- name: Install Conda environment with Micromamba
Expand All @@ -83,35 +98,83 @@ jobs:
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
- name: additional setup core
run: pip install --no-deps -e .
- name: Get Date
id: get-date
run: |
echo "date=$(date +'%Y-%b')"
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: bioimageio_cache
key: "test-spec-main-${{ steps.get-date.outputs.date }}"
- name: pytest-spec-main
run: pytest --disable-pytest-warnings
- if: matrix.python-version == '3.12' && github.event_name == 'pull_request'
env:
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
- if: matrix.is-dev-version && github.event_name == 'pull_request'
uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
- if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main'
- if: matrix.is-dev-version && github.ref == 'refs/heads/main'
run: |
pip install genbadge[coverage]
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg
coverage html -d dist/coverage
- if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main'
- if: matrix.is-dev-version && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: coverage
retention-days: 1
path: dist


test-tf:
test-spec-main-tf:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.11']
python-version: ['3.9', '3.12']
steps:
- uses: actions/checkout@v4
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
- uses: mamba-org/setup-micromamba@v1
with:
cache-downloads: true
cache-environment: true
environment-file: dev/env-tf.yaml
condarc: |
channel-priority: flexible
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: 'all'
- name: additional setup spec
run: |
conda remove --yes --force bioimageio.spec || true # allow failure for cached env
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
- name: additional setup core
run: pip install --no-deps -e .
- name: Get Date
id: get-date
run: |
echo "date=$(date +'%Y-%b')"
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: bioimageio_cache
key: "test-spec-main-tf-${{ steps.get-date.outputs.date }}"
- run: pytest --disable-pytest-warnings
env:
BIOIMAGEIO_CACHE_PATH: bioimageio_cache

test-spec-conda-tf:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.12']
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
cache-downloads: true
cache-environment: true
Expand All @@ -123,8 +186,20 @@ jobs:
post-cleanup: 'all'
- name: additional setup
run: pip install --no-deps -e .
- name: Get Date
id: get-date
run: |
echo "date=$(date +'%Y-%b')"
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: bioimageio_cache
key: "test-spec-conda-tf-${{ steps.get-date.outputs.date }}"
- name: pytest-spec-tf
run: pytest --disable-pytest-warnings
env:
BIOIMAGEIO_CACHE_PATH: bioimageio_cache

conda-build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -164,20 +239,11 @@ jobs:
path: dist
- uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'
cache: 'pip'
- run: pip install -e .[dev]
- id: get_version
run: python -c 'import bioimageio.core;print(f"version={bioimageio.core.__version__}")' >> $GITHUB_OUTPUT
- name: Generate developer docs
run: |
pdoc \
--docformat google \
--logo https://bioimage.io/static/img/bioimage-io-logo.svg \
--logo-link https://bioimage.io/ \
--favicon https://bioimage.io/static/img/bioimage-io-icon-small.svg \
--footer-text 'bioimageio.core ${{steps.get_version.outputs.version}}' \
-o ./dist bioimageio.core
run: ./scripts/pdoc/run.sh
- run: cp README.md ./dist/README.md
- name: copy rendered presentations
run: |
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,24 @@ The model specification and its validation tools can be found at <https://github

## Changelog

### 0.7.0

- breaking:
- bioimageio CLI now has implicit boolean flags
- non-breaking:
- use new `ValidationDetail.recommended_env` in `ValidationSummary`
- improve `get_io_sample_block_metas()`
- now works for sufficiently large, but not exactly shaped inputs
- update to support `zipfile.ZipFile` object with bioimageio.spec==0.5.3.5
- add io helpers `resolve` and `resolve_and_extract`
- added `enable_determinism` function and **determinism** input argument for testing with seeded
random generators and optionally (determinsim=="full") instructing DL frameworks to use
deterministic algorithms.

### 0.6.10

- fix #423

### 0.6.9

- improve bioimageio command line interface (details in #157)
Expand Down
2 changes: 1 addition & 1 deletion bioimageio/core/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.6.10"
"version": "0.7.0"
}
45 changes: 42 additions & 3 deletions bioimageio/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.. include:: ../../README.md
"""

from bioimageio.core.stat_measures import Stat
from bioimageio.spec import (
build_description,
dump_description,
Expand All @@ -16,16 +15,38 @@
validate_format,
)

from . import digest_spec
from . import (
axis,
block_meta,
cli,
commands,
common,
digest_spec,
io,
model_adapters,
prediction,
proc_ops,
proc_setup,
sample,
stat_calculators,
stat_measures,
tensor,
)
from ._prediction_pipeline import PredictionPipeline, create_prediction_pipeline
from ._resource_tests import load_description_and_test, test_description, test_model
from ._resource_tests import (
enable_determinism,
load_description_and_test,
test_description,
test_model,
)
from ._settings import settings
from .axis import Axis, AxisId
from .block_meta import BlockMeta
from .common import MemberId
from .prediction import predict, predict_many
from .sample import Sample
from .stat_calculators import compute_dataset_measures
from .stat_measures import Stat
from .tensor import Tensor
from .utils import VERSION

Expand All @@ -34,19 +55,29 @@

# aliases
test_resource = test_description
"""alias of `test_description`"""
load_resource = load_description
"""alias of `load_description`"""
load_model = load_model_description
"""alias of `load_model_description`"""

__all__ = [
"__version__",
"axis",
"Axis",
"AxisId",
"block_meta",
"BlockMeta",
"build_description",
"cli",
"commands",
"common",
"compute_dataset_measures",
"create_prediction_pipeline",
"digest_spec",
"dump_description",
"enable_determinism",
"io",
"load_dataset_description",
"load_description_and_test",
"load_description_and_validate_format_only",
Expand All @@ -55,15 +86,23 @@
"load_model",
"load_resource",
"MemberId",
"model_adapters",
"predict_many",
"predict",
"prediction",
"PredictionPipeline",
"proc_ops",
"proc_setup",
"sample",
"Sample",
"save_bioimageio_package_as_folder",
"save_bioimageio_package",
"save_bioimageio_yaml_only",
"settings",
"stat_calculators",
"stat_measures",
"Stat",
"tensor",
"Tensor",
"test_description",
"test_model",
Expand Down
14 changes: 7 additions & 7 deletions bioimageio/core/_prediction_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,20 @@ def predict_sample_without_blocking(
if out is not None
},
stat=sample.stat,
id=self.get_output_sample_id(sample.id),
id=sample.id,
)
if not skip_postprocessing:
self.apply_postprocessing(output)

return output

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

def predict_sample_with_fixed_blocking(
self,
Expand Down
Loading
Loading