Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
64 changes: 52 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
branches: [main]
pull_request:
branches: ['**']
workflow_dispatch:
inputs:
force-publish:
description: 'Force publish even if no version change detected'
required: false
type: choice
options:
- 'true'
- 'false'
default: 'false'

defaults:
run:
Expand Down Expand Up @@ -143,11 +153,10 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: coverage-summary
retention-days: 1
path: dist

conda-build:
needs: test # only so we run tests even if the pinned bioimageio.spec version is not yet published on conda-forge yet
needs: [populate-cache, test] # only so we run tests even if the pinned bioimageio.spec version is not yet published on conda-forge
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -169,14 +178,20 @@ jobs:
pkgs/noarch
pkgs/channeldata.json
key: ${{ github.sha }}-packages
- uses: actions/cache@v4
with:
path: bioimageio_cache
key: ${{needs.populate-cache.outputs.cache-key}}
- name: linux conda build test
shell: bash -l {0}
run: |
mkdir -p ./pkgs/noarch
conda-build -c conda-forge conda-recipe --output-folder ./pkgs
env:
BIOIMAGEIO_CACHE_PATH: bioimageio_cache

docs:
needs: test
needs: [coverage, test]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -234,26 +249,51 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if there is a parent commit
id: check-parent-commit
fetch-tags: true
- name: Get parent commit
if: inputs.force-publish != 'true'
id: get-parent-commit
run: |
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
- id: get-existing-tag
if: inputs.force-publish == 'true'
run: echo "existing-tag=$(git tag --points-at HEAD 'v[0-9]*.[0-9]*.[0-9]*')" >> $GITHUB_OUTPUT

- name: Detect new version
- name: Detect new version from last commit and create tag
id: tag-version
if: github.ref == 'refs/heads/main' && steps.check-parent-commit.outputs.sha
if: github.ref == 'refs/heads/main' && steps.get-parent-commit.outputs.sha && inputs.force-publish != 'true'
uses: salsify/[email protected]
with:
create-tag: true
version-command: |
python -c "from pathlib import Path;import json;print(p_src.read_text().split('__version__ = \"')[1].split('\"')[0] if (p_src:=Path('src/bioimageio/core/__init__.py')).exists() else json.loads(Path('bioimageio/core/VERSION').read_text())['version'])"
python -c "from pathlib import Path; p = Path('src/bioimageio/core/__init__.py'); v = p.read_text().split('__version__ = \"')[1].split('\"')[0]; print(v)"
- shell: python
id: get-new-version
run: |
import os
from pathlib import Path



if "${{ inputs.force-publish }}" == "true":
existing_tag = "${{ steps.get-existing-tag.outputs.existing-tag }}"
valid = existing_tag.count("v") == 1 and existing_tag.count(".") == 2 and all(part.isdigit() for part in existing_tag.lstrip("v").split("."))
if not valid:
raise Exception(f"Current commit has invalid version tag {existing_tag}.")
new_version = existing_tag
else:
new_version = "${{ steps.tag-version.outputs.tag }}"

with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
print(f"new-version={new_version}", file=f)

- uses: actions/download-artifact@v4
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.tag
if: github.ref == 'refs/heads/main' && steps.get-new-version.outputs.new-version
with:
name: dist
path: dist
- name: Publish package on PyPI
if: github.ref == 'refs/heads/main' && steps.tag-version.outputs.tag
if: github.ref == 'refs/heads/main' && steps.get-new-version.outputs.new-version
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
Expand All @@ -262,7 +302,7 @@ jobs:
if: github.ref == 'refs/heads/main'
uses: release-drafter/[email protected]
with:
publish: "${{ steps.tag-version.outputs.tag != '' }}"
tag: '${{ steps.tag-version.outputs.tag }}'
publish: "${{ steps.get-new-version.outputs.new-version != '' }}"
tag: '${{ steps.get-new-version.outputs.new-version }}'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
2 changes: 1 addition & 1 deletion src/bioimageio/core/block_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BlockMeta:
The outer slice reaches from the sample member origin (0, 0) to the right halo point.

```terminal
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
╷ halo(left) ╷
╷ ╷
╷ (0, 0)┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━➔
Expand Down
12 changes: 7 additions & 5 deletions src/bioimageio/core/digest_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,15 @@ def get_input_halo(model: v0_5.ModelDescr, output_halo: PerMember[PerAxis[Halo]]
axis = axes[a]
ref_axis = {a.id: a for a in all_tensors[s.tensor_id].axes}[s.axis_id]

total_output_halo = sum(ah)
total_input_halo = total_output_halo * axis.scale / ref_axis.scale
assert (
total_input_halo == int(total_input_halo) and total_input_halo % 2 == 0
input_halo_left = ah.left * axis.scale / ref_axis.scale
input_halo_right = ah.right * axis.scale / ref_axis.scale
assert input_halo_left == int(input_halo_left), f"{input_halo_left} not int"
assert input_halo_right == int(input_halo_right), (
f"{input_halo_right} not int"
)

input_halo.setdefault(s.tensor_id, {})[a] = Halo(
int(total_input_halo // 2), int(total_input_halo // 2)
int(input_halo_left), int(input_halo_right)
)

return input_halo
Expand Down
Loading