Skip to content

Commit 6f5b42b

Browse files
authored
Merge pull request #727 from bioimage-io/dev
minor improvements
2 parents 3d0897c + a5c68f2 commit 6f5b42b

File tree

5 files changed

+59
-25
lines changed

5 files changed

+59
-25
lines changed

.github/workflows/build.yaml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ jobs:
147147
branch: ${{ steps.get_branch.outputs.branch }}
148148
folder: dist
149149

150+
build:
151+
needs: test
152+
runs-on: ubuntu-latest
153+
steps:
154+
- uses: actions/checkout@v4
155+
- uses: actions/setup-python@v6
156+
with:
157+
python-version: '3.10'
158+
cache: 'pip'
159+
- name: Install dependencies
160+
run: |
161+
python -m pip install --upgrade pip
162+
pip --version
163+
pip install --upgrade build
164+
pip install .
165+
- name: Build package
166+
run: |
167+
python -m build
168+
- uses: actions/upload-artifact@v4
169+
with:
170+
path: dist/
171+
name: dist
172+
150173
conda-build:
151174
needs: test
152175
runs-on: ubuntu-latest
@@ -186,9 +209,8 @@ jobs:
186209
# with:
187210
# recipe-path: conda-recipe/recipe.yaml
188211

189-
pip-build:
190-
name: Build and publish to PyPI
191-
needs: [deploy, conda-build]
212+
publish:
213+
needs: [build, conda-build]
192214
runs-on: ubuntu-latest
193215
environment:
194216
name: release
@@ -200,17 +222,6 @@ jobs:
200222
uses: actions/checkout@v4
201223
with:
202224
fetch-depth: 2
203-
- name: Set up Python
204-
uses: actions/setup-python@v6
205-
with:
206-
python-version: '3.10'
207-
cache: 'pip'
208-
- name: Install dependencies
209-
run: |
210-
python -m pip install --upgrade pip
211-
pip --version
212-
pip install --upgrade build
213-
pip install .
214225
- name: Check if there is a parent commit
215226
id: check-parent-commit
216227
run: |
@@ -231,11 +242,10 @@ jobs:
231242
with:
232243
github_token: ${{ secrets.GITHUB_TOKEN }}
233244
custom_tag: ${{ steps.check-version.outputs.current-version }}
234-
235-
- name: Build package
236-
run: |
237-
python -m build
238-
245+
- uses: actions/download-artifact@v4
246+
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.new_tag
247+
with:
248+
name: dist
239249
- name: Publish package on PyPI
240250
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.new_tag
241251
uses: pypa/gh-action-pypi-publish@release/v1

example_descriptions/models/unet2d_multi_tensor/bioimageio.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ weights:
143143
in_channels: 2
144144
initial_features: 16
145145
out_channels: 2
146-
sha256: 89204f8f3513b3c227127a8137bedaec9eafe49925f7734c73c6650ec135b34e
146+
sha256: 74b6d27cd17b40560e70fde4d57b5675614979ffab4f1e0328a6c3a3f64a1ff2
147147
source: multi_tensor_unet.py
148148
pytorch_version: 1.6
149149
sha256: c498522b3f2b02429b41fe9dbcb722ce0d7ad4cae7fcf8059cee27857ae49b00

example_descriptions/models/unet2d_multi_tensor/multi_tensor_unet.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# type: ignore
2+
from typing import List, Optional
3+
24
import torch
35
import torch.nn as nn
46

@@ -75,11 +77,16 @@ def _apply_default(self, x):
7577

7678
return x
7779

78-
def forward(self, *x):
79-
assert isinstance(x, (list, tuple)), type(x)
80-
# fix issue in onnx export
81-
if isinstance(x[0], list) and len(x) == 1:
82-
x = x[0]
80+
def forward(
81+
self,
82+
x0: torch.Tensor,
83+
x1: Optional[torch.Tensor] = None,
84+
x2: Optional[torch.Tensor] = None,
85+
x3: Optional[torch.Tensor] = None,
86+
x4: Optional[torch.Tensor] = None,
87+
/,
88+
) -> List[torch.Tensor]:
89+
x = [x for x in [x0, x1, x2, x3, x4] if x is not None]
8390
assert len(x) == self.in_channels, f"{len(x)}, {self.in_channels}"
8491
x = torch.cat(x, dim=1)
8592
out = self._apply_default(x)

src/bioimageio/spec/model/v0_5.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
FileSource,
6767
WithSuffix,
6868
YamlValue,
69+
extract_file_name,
6970
get_reader,
7071
wo_special_file_name,
7172
)
@@ -2376,6 +2377,19 @@ class OnnxWeightsDescr(WeightsEntryDescrBase):
23762377
"""Source of the external ONNX data file holding the weights.
23772378
(If present **source** holds the ONNX architecture without weights)."""
23782379

2380+
@model_validator(mode="after")
2381+
def _validate_external_data_unique_file_name(self) -> Self:
2382+
if self.external_data is not None and (
2383+
extract_file_name(self.source)
2384+
== extract_file_name(self.external_data.source)
2385+
):
2386+
raise ValueError(
2387+
f"ONNX `external_data` file name '{extract_file_name(self.external_data.source)}'"
2388+
+ " must be different from ONNX `source` file name."
2389+
)
2390+
2391+
return self
2392+
23792393

23802394
class PytorchStateDictWeightsDescr(WeightsEntryDescrBase):
23812395
type = "pytorch_state_dict"

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77
from dotenv import load_dotenv
8+
from loguru import logger
89

910
from bioimageio.spec._internal.constants import (
1011
KNOWN_GITHUB_USERS,
@@ -18,6 +19,8 @@
1819

1920
_ = load_dotenv()
2021

22+
logger.enable("bioimageio")
23+
2124
EXAMPLE_DESCRIPTIONS = Path(__file__).parent / "../example_descriptions/"
2225
UNET2D_ROOT = EXAMPLE_DESCRIPTIONS / "models/unet2d_nuclei_broad"
2326

0 commit comments

Comments
 (0)