diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 16ff38fd..d1d2d6f9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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: @@ -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 @@ -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: @@ -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/action-detect-and-tag-new-version@v2.0.3 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/ @@ -262,7 +302,7 @@ jobs: if: github.ref == 'refs/heads/main' uses: release-drafter/release-drafter@v6.0.0 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 }}' diff --git a/src/bioimageio/core/block_meta.py b/src/bioimageio/core/block_meta.py index b8246953..688463de 100644 --- a/src/bioimageio/core/block_meta.py +++ b/src/bioimageio/core/block_meta.py @@ -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)┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━➔ diff --git a/src/bioimageio/core/digest_spec.py b/src/bioimageio/core/digest_spec.py index 1f2ac895..5c920bf0 100644 --- a/src/bioimageio/core/digest_spec.py +++ b/src/bioimageio/core/digest_spec.py @@ -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