Skip to content

Commit

Permalink
Merge pull request #432 from bioimage-io/zipfile
Browse files Browse the repository at this point in the history
support zipfile.ZipFile, improve docs and improve get_io_sample_block_metas
  • Loading branch information
FynnBe authored Nov 18, 2024
2 parents 9815139 + cf48411 commit 6a10672
Show file tree
Hide file tree
Showing 36 changed files with 839 additions and 604 deletions.
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

0 comments on commit 6a10672

Please sign in to comment.