Skip to content

Commit b30173f

Browse files
authored
Merge pull request #473 from bioimage-io/dev
avoid 'conda activate' and update xarray pin
2 parents 91eec0d + a6cbf75 commit b30173f

File tree

8 files changed

+152
-117
lines changed

8 files changed

+152
-117
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- name: Install dependencies
8383
run: |
8484
pip install --upgrade pip
85-
pip install -e .[dev] numpy==${{matrix.numpy-version}}.*
85+
pip install -e .[dev,partners] numpy==${{matrix.numpy-version}}.*
8686
- name: Pyright
8787
if: matrix.run-expensive-tests # pyright is not expensive, but we only want to run it once due to otherwise inconsistent typing
8888
run: |
@@ -165,7 +165,7 @@ jobs:
165165
with:
166166
python-version: '3.12'
167167
cache: 'pip'
168-
- run: pip install -e .[dev]
168+
- run: pip install -e .[dev,partners]
169169
- name: Generate developer docs
170170
run: ./scripts/pdoc/run.sh
171171
- run: cp README.md ./dist/README.md

README.md

Lines changed: 8 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -361,108 +361,15 @@ There are different environment files available that only install tensorflow or
361361

362362
`bioimageio.spec` and `bioimageio.core` use [loguru](https://github.com/Delgan/loguru) for logging, hence the logging level
363363
may be controlled with the `LOGURU_LEVEL` environment variable.
364+
The `bioimageio` CLI has logging enabled by default.
365+
To activate logging when using bioimageio.spec/bioimageio.core as a library, add
364366

365-
## Changelog
366-
367-
### 0.9.3
368-
369-
- bump bioimageio.spec library version to 0.5.5.5
370-
- more robust test model reporting
371-
- improved user input axis intepretation
372-
- fixed conda subprocess calls
373-
374-
### 0.9.2
375-
376-
- fix model inference tolerance reporting
377-
378-
### 0.9.1
379-
380-
- fixes:
381-
- CLI
382-
- improved handling of summary argument to not create a path with brackets when given a list of paths.
383-
- improved backward compatibility when runnig tests for models specifying an older bioimageio.core version in their environment.
384-
This is relevant when using `runtime_env="as-described"`.
385-
It works by simply trying option `--summary` (new option name) and `--summary-path` (outdated option name)
386-
387-
### 0.9.0
388-
389-
- update to [bioimageio.spec 0.5.4.3](https://github.com/bioimage-io/spec-bioimage-io/blob/main/changelog.md#bioimageiospec-0543)
390-
391-
### 0.8.0
392-
393-
- breaking: removed `decimals` argument from bioimageio CLI and `bioimageio.core.commands.test()`
394-
- New feature: `bioimageio.core.test_description` accepts **runtime_env** and **run_command** to test a resource
395-
using the conda environment described by that resource (or another specified conda env)
396-
- new CLI command: `bioimageio add-weights` (and utility function: bioimageio.core.add_weights)
397-
- removed `bioimageio.core.proc_ops.get_proc_class` in favor of `bioimageio.core.proc_ops.get_proc`
398-
- new CLI command: `bioimageio update-format`
399-
- new CLI command: `bioimageio update-hashes`
400-
401-
### 0.7.0
402-
403-
- breaking:
404-
- bioimageio CLI now has implicit boolean flags
405-
- non-breaking:
406-
- use new `ValidationDetail.recommended_env` in `ValidationSummary`
407-
- improve `get_io_sample_block_metas()`
408-
- now works for sufficiently large, but not exactly shaped inputs
409-
- update to support `zipfile.ZipFile` object with bioimageio.spec==0.5.3.5
410-
- add io helpers `resolve` and `resolve_and_extract`
411-
- added `enable_determinism` function and **determinism** input argument for testing with seeded
412-
random generators and optionally (determinsim=="full") instructing DL frameworks to use
413-
deterministic algorithms.
414-
415-
### 0.6.10
416-
417-
- fix #423
418-
419-
### 0.6.9
420-
421-
- improve bioimageio command line interface (details in #157)
422-
- add `predict` command
423-
- package command input `path` is now required
424-
425-
### 0.6.8
367+
```python
368+
from loguru import logger
426369

427-
- testing model inference will now check all weight formats
428-
(previously only the first one for which model adapter creation succeeded had been checked)
429-
- fix predict with blocking (Thanks @thodkatz)
430-
431-
### 0.6.7
432-
433-
- `predict()` argument `inputs` may be sample
434-
435-
### 0.6.6
436-
437-
- add aliases to match previous API more closely
438-
439-
### 0.6.5
440-
441-
- improve adapter error messages
442-
443-
### 0.6.4
444-
445-
- add `bioimageio validate-format` command
446-
- improve error messages and display of command results
447-
448-
### 0.6.3
449-
450-
- Fix [#386](https://github.com/bioimage-io/core-bioimage-io-python/issues/386)
451-
- (in model inference testing) stop assuming model inputs are tileable
452-
453-
### 0.6.2
454-
455-
- Fix [#384](https://github.com/bioimage-io/core-bioimage-io-python/issues/384)
456-
457-
### 0.6.1
458-
459-
- Fix [#378](https://github.com/bioimage-io/core-bioimage-io-python/pull/378) (with [#379](https://github.com/bioimage-io/core-bioimage-io-python/pull/379))*
460-
461-
### 0.6.0
462-
463-
- add compatibility with new bioimageio.spec 0.5 (0.5.2post1)
464-
- improve interfaces
370+
logger.enable("bioimageio")
371+
```
465372

466-
### 0.5.10
373+
## Changelog
467374

468-
- [Fix critical bug in predict with tiling](https://github.com/bioimage-io/core-bioimage-io-python/pull/359)
375+
See [changelog.md](changelog.md)

changelog.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
### 0.9.4
2+
3+
- bump bioimageio.spec library version to 0.5.5.6
4+
- Replace `conda activate <env name>` with `conda run -n <env name> python --version` when checking if a conda environment exists
5+
(This is closer to the actual `conda run` command we need and avoids requests by conda to rerun `conda init` (in CI).)
6+
- remove upper xarray pin (use ops from xarray.computation.ops, fallback to xarray.core.ops for older xarray versions)
7+
8+
### 0.9.3
9+
10+
- bump bioimageio.spec library version to 0.5.5.5
11+
- more robust test model reporting
12+
- improved user input axis intepretation
13+
- fixed conda subprocess calls
14+
15+
### 0.9.2
16+
17+
- fix model inference tolerance reporting
18+
19+
### 0.9.1
20+
21+
- fixes:
22+
- CLI
23+
- improved handling of summary argument to not create a path with brackets when given a list of paths.
24+
- improved backward compatibility when runnig tests for models specifying an older bioimageio.core version in their environment.
25+
This is relevant when using `runtime_env="as-described"`.
26+
It works by simply trying option `--summary` (new option name) and `--summary-path` (outdated option name)
27+
28+
### 0.9.0
29+
30+
- update to [bioimageio.spec 0.5.4.3](https://github.com/bioimage-io/spec-bioimage-io/blob/main/changelog.md#bioimageiospec-0543)
31+
32+
### 0.8.0
33+
34+
- breaking: removed `decimals` argument from bioimageio CLI and `bioimageio.core.commands.test()`
35+
- New feature: `bioimageio.core.test_description` accepts **runtime_env** and **run_command** to test a resource
36+
using the conda environment described by that resource (or another specified conda env)
37+
- new CLI command: `bioimageio add-weights` (and utility function: bioimageio.core.add_weights)
38+
- removed `bioimageio.core.proc_ops.get_proc_class` in favor of `bioimageio.core.proc_ops.get_proc`
39+
- new CLI command: `bioimageio update-format`
40+
- new CLI command: `bioimageio update-hashes`
41+
42+
### 0.7.0
43+
44+
- breaking:
45+
- bioimageio CLI now has implicit boolean flags
46+
- non-breaking:
47+
- use new `ValidationDetail.recommended_env` in `ValidationSummary`
48+
- improve `get_io_sample_block_metas()`
49+
- now works for sufficiently large, but not exactly shaped inputs
50+
- update to support `zipfile.ZipFile` object with bioimageio.spec==0.5.3.5
51+
- add io helpers `resolve` and `resolve_and_extract`
52+
- added `enable_determinism` function and **determinism** input argument for testing with seeded
53+
random generators and optionally (determinsim=="full") instructing DL frameworks to use
54+
deterministic algorithms.
55+
56+
### 0.6.10
57+
58+
- fix #423
59+
60+
### 0.6.9
61+
62+
- improve bioimageio command line interface (details in #157)
63+
- add `predict` command
64+
- package command input `path` is now required
65+
66+
### 0.6.8
67+
68+
- testing model inference will now check all weight formats
69+
(previously only the first one for which model adapter creation succeeded had been checked)
70+
- fix predict with blocking (Thanks @thodkatz)
71+
72+
### 0.6.7
73+
74+
- `predict()` argument `inputs` may be sample
75+
76+
### 0.6.6
77+
78+
- add aliases to match previous API more closely
79+
80+
### 0.6.5
81+
82+
- improve adapter error messages
83+
84+
### 0.6.4
85+
86+
- add `bioimageio validate-format` command
87+
- improve error messages and display of command results
88+
89+
### 0.6.3
90+
91+
- Fix [#386](https://github.com/bioimage-io/core-bioimage-io-python/issues/386)
92+
- (in model inference testing) stop assuming model inputs are tileable
93+
94+
### 0.6.2
95+
96+
- Fix [#384](https://github.com/bioimage-io/core-bioimage-io-python/issues/384)
97+
98+
### 0.6.1
99+
100+
- Fix [#378](https://github.com/bioimage-io/core-bioimage-io-python/pull/378) (with [#379](https://github.com/bioimage-io/core-bioimage-io-python/pull/379))*
101+
102+
### 0.6.0
103+
104+
- add compatibility with new bioimageio.spec 0.5 (0.5.2post1)
105+
- improve interfaces
106+
107+
### 0.5.10
108+
109+
- [Fix critical bug in predict with tiling](https://github.com/bioimage-io/core-bioimage-io-python/pull/359)

pyproject.toml

Lines changed: 9 additions & 7 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.5",
9+
"bioimageio.spec ==0.5.5.6",
1010
"h5py",
1111
"imagecodecs",
1212
"imageio>=2.10",
@@ -18,7 +18,7 @@ dependencies = [
1818
"scipy",
1919
"tqdm",
2020
"typing-extensions",
21-
"xarray>=2023.01,<2025.3.0",
21+
"xarray>=2023.01",
2222
]
2323
classifiers = [
2424
"Development Status :: 3 - Alpha",
@@ -43,16 +43,19 @@ Source = "https://github.com/bioimage-io/core-bioimage-io-python"
4343
onnx = ["onnxruntime"]
4444
pytorch = ["torch>=1.6,<3", "torchvision>=0.21", "keras>=3.0,<4"]
4545
tensorflow = ["tensorflow", "keras>=2.15,<4"]
46-
dev = [
46+
partners = [
4747
# "biapy", # pins core exactly
4848
"careamics",
49-
"cellpose", # for model testing
49+
# "stardist", # for model testing and stardist postprocessing # TODO: add updated stardist to partners env
50+
]
51+
dev = [
52+
"cellpose", # for model testing
5053
"crick",
5154
"httpx",
5255
"jupyter",
5356
"keras>=3.0,<4",
5457
"matplotlib",
55-
"monai", # for model testing
58+
"monai", # for model testing
5659
"numpy",
5760
"onnx",
5861
"onnxruntime",
@@ -63,8 +66,7 @@ dev = [
6366
"pytest-cov",
6467
"pytest",
6568
"python-dotenv",
66-
"segment-anything", # for model testing
67-
# "stardist", # for model testing and stardist postprocessing # TODO: add updated stardist to dev env
69+
"segment-anything", # for model testing
6870
"tensorflow",
6971
"timm", # for model testing
7072
"torch>=1.6,<3",

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.3"
6+
__version__ = "0.9.4"
77
from loguru import logger
88

99
logger.disable("bioimageio.core")

src/bioimageio/core/_magic_tensor_ops.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
from typing import Any, Callable
77

88
from typing_extensions import Self
9-
from xarray.core import nputils, ops
9+
from xarray.core import nputils
10+
11+
try:
12+
# xarray >= 2025.03
13+
from xarray.computation import ops
14+
except ImportError:
15+
# xarray < 2025.03
16+
from xarray.core import ops # type: ignore
1017

1118

1219
class MagicTensorOpsMixin:

src/bioimageio/core/_resource_tests.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ def test_description(
260260
else:
261261
assert_never(runtime_env)
262262

263+
try:
264+
run_command(["thiscommandshouldalwaysfail", "please"])
265+
except Exception:
266+
pass
267+
else:
268+
raise RuntimeError(
269+
"given run_command does not raise an exception for a failing command"
270+
)
271+
263272
td_kwargs: Dict[str, Any] = (
264273
dict(ignore_cleanup_errors=True) if sys.version_info >= (3, 10) else {}
265274
)
@@ -387,8 +396,8 @@ def _test_in_env(
387396
raise RuntimeError("Conda not available") from e
388397

389398
try:
390-
run_command([CONDA_CMD, "activate", env_name])
391-
except Exception:
399+
run_command([CONDA_CMD, "run", "-n", env_name, "python", "--version"])
400+
except Exception as e:
392401
working_dir.mkdir(parents=True, exist_ok=True)
393402
path = working_dir / "env.yaml"
394403
try:
@@ -405,7 +414,8 @@ def _test_in_env(
405414
]
406415
+ (["--quiet"] if settings.CI else [])
407416
)
408-
run_command([CONDA_CMD, "activate", env_name])
417+
# double check that environment was created successfully
418+
run_command([CONDA_CMD, "run", "-n", env_name, "python", "--version"])
409419
except Exception as e:
410420
summary = descr.validation_summary
411421
summary.add_detail(

tests/test_bioimageio_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def depends_on(dep: str) -> bool:
101101

102102
for skip_if_depends_on in (
103103
"biapy",
104-
"git+https://github.com/CAREamics/careamics.git",
105-
"careamics",
104+
"git+https://github.com/CAREamics/careamics.git", # TODO: include tests depending on careamics
105+
"careamics", # TODO: include tests depending on careamics
106106
"inferno",
107107
"plantseg",
108108
):

0 commit comments

Comments
 (0)