Skip to content

Commit 7e2c424

Browse files
authored
Merge pull request #337 from bioimage-io/fix-tests
Fix tests
2 parents d435fcd + ed64b7d commit 7e2c424

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
tool_name: blackfmt
2424

25-
test-base-bioimage-spec-conda:
25+
test-spec-conda:
2626
runs-on: ubuntu-latest
2727
strategy:
2828
matrix:
@@ -33,18 +33,18 @@ jobs:
3333
uses: mamba-org/provision-with-micromamba@main
3434
with:
3535
cache-downloads: true
36-
cache-env: true
36+
cache-env: false # debugging: torch does not detect onnxruntime
3737
environment-file: dev/environment-torch.yaml
3838
extra-specs: |
3939
python=${{ matrix.python-version }}
4040
- name: additional setup
4141
shell: bash -l {0}
4242
run: pip install --no-deps -e .
43-
- name: pytest-base-bioimage-spec-conda
43+
- name: pytest-spec-conda
4444
shell: bash -l {0}
4545
run: pytest --disable-pytest-warnings
4646

47-
test-base-bioimage-spec-main:
47+
test-spec-main:
4848
runs-on: ubuntu-latest
4949
strategy:
5050
matrix:
@@ -55,7 +55,7 @@ jobs:
5555
uses: mamba-org/provision-with-micromamba@main
5656
with:
5757
cache-downloads: true
58-
cache-env: true
58+
cache-env: false # todo: detect env cache hit and adapt(skip?) additional setup (conda remove?)
5959
environment-file: dev/environment-torch.yaml
6060
extra-specs: |
6161
python=${{ matrix.python-version }}
@@ -65,11 +65,11 @@ jobs:
6565
conda remove --yes --force bioimageio.spec
6666
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
6767
pip install --no-deps -e .
68-
- name: pytest-base-bioimage-spec-main
68+
- name: pytest-spec-main
6969
shell: bash -l {0}
7070
run: pytest --disable-pytest-warnings
71-
72-
test-base-bioimage-spec-tf:
71+
72+
test-spec-tf:
7373
runs-on: ubuntu-latest
7474
strategy:
7575
matrix:
@@ -80,7 +80,7 @@ jobs:
8080
uses: mamba-org/provision-with-micromamba@main
8181
with:
8282
cache-downloads: true
83-
cache-env: true
83+
cache-env: false # todo: detect env cache hit and adapt(skip?) additional setup (conda remove?)
8484
environment-file: dev/environment-tf.yaml
8585
channel-priority: flexible
8686
extra-specs: |
@@ -91,11 +91,11 @@ jobs:
9191
conda remove --yes --force bioimageio.spec
9292
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
9393
pip install --no-deps -e .
94-
- name: pytest-base-bioimage-spec-tf
94+
- name: pytest-spec-tf
9595
shell: bash -l {0}
9696
run: pytest --disable-pytest-warnings
9797

98-
test-base-bioimage-spec-tf-legacy:
98+
test-spec-tf-legacy:
9999
runs-on: ubuntu-latest
100100
strategy:
101101
matrix:
@@ -106,7 +106,7 @@ jobs:
106106
uses: mamba-org/provision-with-micromamba@main
107107
with:
108108
cache-downloads: true
109-
cache-env: true
109+
cache-env: false # todo: detect env cache hit and adapt(skip?) additional setup (conda remove?)
110110
environment-file: dev/environment-tf-legacy.yaml
111111
channel-priority: flexible
112112
extra-specs: |
@@ -117,13 +117,13 @@ jobs:
117117
conda remove --yes --force bioimageio.spec
118118
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
119119
pip install --no-deps -e .
120-
- name: pytest-base-bioimage-spec-tf-legacy
120+
- name: pytest-spec-tf-legacy
121121
shell: bash -l {0}
122122
run: pytest --disable-pytest-warnings
123123

124124
conda-build:
125125
runs-on: ubuntu-latest
126-
needs: test-base-bioimage-spec-conda
126+
needs: test-spec-conda
127127
steps:
128128
- name: checkout
129129
uses: actions/checkout@v3

bioimageio/core/build_spec/build_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ def _get_dependencies(dependencies, root):
279279

280280

281281
def _get_deepimagej_macro(name, kwargs, export_folder):
282-
283282
# macros available in deepimagej
284283
macro_names = ("binarize", "scale_linear", "scale_range", "zero_mean_unit_variance")
285284
if name == "scale_linear":
@@ -536,7 +535,7 @@ def grid_im(im0, im1):
536535

537536
n, m = im_shape
538537
x, y = ims_per_row * n, n_rows * m
539-
out = np.zeros((3, y, x))
538+
out = np.zeros((3, y, x), dtype=im0.dtype)
540539
images = [im0] + [np.repeat(im1[i : i + 1], 3, axis=0) for i in range(n_chan)]
541540

542541
i, j = 0, 0

dev/environment-base.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies:
1414
- python >=3.7,<3.8 # this environment is only available for python 3.7
1515
- xarray
1616
- pytorch
17+
- onnx
1718
- onnxruntime
1819
- tensorflow >=1.12,<2.0
1920
- tifffile <=2022.4.8 # pin fixes Syntax error; see https://github.com/bioimage-io/core-bioimage-io-python/pull/259

dev/environment-torch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies:
1313
- python >=3.7
1414
- xarray
1515
- pytorch
16+
- onnx
1617
- onnxruntime
1718
- tifffile <=2022.4.8 # pin fixes Syntax error; see https://github.com/bioimage-io/core-bioimage-io-python/pull/259
1819

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def unet2d_fixed_shape_or_not(request):
200200
return pytest.model_packages[request.param]
201201

202202

203-
@pytest.fixture(params=[] if skip_torch else ["unet2d_nuclei_broad_model", "unet2d_multi_tensor"])
204-
def unet2d_multi_tensor_or_not(request):
203+
@pytest.fixture(params=[] if skip_onnx or skip_torch else ["unet2d_nuclei_broad_model", "unet2d_multi_tensor"])
204+
def convert_to_onnx(request):
205205
return pytest.model_packages[request.param]
206206

207207

tests/weight_converter/torch/test_onnx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44

55
# todo: test with 'any_torch_model'
6-
def test_onnx_converter(unet2d_multi_tensor_or_not, tmp_path):
6+
def test_onnx_converter(convert_to_onnx, tmp_path):
77
from bioimageio.core.weight_converter.torch.onnx import convert_weights_to_onnx
88

99
out_path = tmp_path / "weights.onnx"
10-
ret_val = convert_weights_to_onnx(unet2d_multi_tensor_or_not, out_path, test_decimal=3)
10+
ret_val = convert_weights_to_onnx(convert_to_onnx, out_path, test_decimal=3)
1111
assert os.path.exists(out_path)
1212
if not pytest.skip_onnx:
1313
assert ret_val == 0 # check for correctness is done in converter and returns 0 if it passes

0 commit comments

Comments
 (0)