Skip to content

Commit 5515061

Browse files
committed
update build workflow
1 parent 7c5b528 commit 5515061

File tree

4 files changed

+116
-169
lines changed

4 files changed

+116
-169
lines changed

.github/workflows/build.yaml

+114-167
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
defaults:
1010
run:
11-
shell: micromamba-shell {0}
11+
shell: bash -el {0}
1212

1313
jobs:
1414
black:
@@ -26,42 +26,58 @@ jobs:
2626
runs-on: ubuntu-latest
2727
strategy:
2828
matrix:
29-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
3029
include:
31-
- python-version: '3.12'
30+
- python-version: '3.8'
31+
conda-env: py38
32+
- python-version: '3.9'
33+
conda-env: wo-python
34+
- python-version: '3.9'
35+
conda-env: tf
36+
- python-version: '3.10'
37+
conda-env: wo-python
38+
- python-version: '3.11'
39+
conda-env: full
3240
run-expensive-tests: true
41+
- python-version: '3.12'
42+
conda-env: wo-python
43+
- python-version: '3.13'
44+
conda-env: wo-python
3345
steps:
46+
- id: get-env-name
47+
run: |
48+
echo "env-name=conda-${{ matrix.conda-env }}-${{ matrix.python-version }}"
49+
echo "env-name=conda-${{ matrix.conda-env }}-${{ matrix.python-version }}" >> $GITHUB_OUTPUT
50+
shell: bash
3451
- uses: actions/checkout@v4
35-
- name: Install Conda environment with Micromamba
36-
if: matrix.python-version != '3.8'
37-
uses: mamba-org/setup-micromamba@v1
38-
with:
39-
cache-downloads: true
40-
cache-environment: true
41-
environment-file: dev/env-wo-python.yaml
42-
create-args: >-
43-
python=${{ matrix.python-version }}
44-
post-cleanup: 'all'
45-
env:
46-
PIP_NO_DEPS: true
47-
- name: Install py3.8 environment
48-
if: matrix.python-version == '3.8'
49-
uses: mamba-org/setup-micromamba@v1
52+
- uses: conda-incubator/setup-miniconda@v3
5053
with:
51-
cache-downloads: true
52-
cache-environment: true
53-
environment-file: dev/env-py38.yaml
54-
post-cleanup: 'all'
55-
env:
56-
PIP_NO_DEPS: true
57-
- name: additional setup
58-
run: pip install --no-deps -e .
54+
auto-update-conda: true
55+
auto-activate-base: true
56+
activate-environment: ${{steps.get-env-name.outputs.env-name}}
57+
channel-priority: strict
58+
miniforge-version: latest
5959
- name: Get Date
6060
id: get-date
6161
run: |
6262
echo "date=$(date +'%Y-%b')"
6363
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
64-
shell: bash
64+
echo "today=$(date -u '+%Y%m%d')"
65+
echo "today=$(date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
66+
- name: Cache env
67+
uses: actions/cache@v4
68+
with:
69+
path: ${{ env.CONDA }}/envs/${{steps.get-env-name.outputs.env-name}}
70+
key: >-
71+
conda-${{ runner.os }}-${{ runner.arch }}
72+
-${{steps.get-date.outputs.today }}
73+
-${{ hashFiles(matrix.conda-env) }}
74+
-${{env.CACHE_NUMBER }}
75+
env:
76+
CACHE_NUMBER: 0
77+
id: cache
78+
- name: Update env
79+
run: conda env update --name=${{steps.get-env-name.outputs.env-name}} --file=dev/env-${{matrix.conda-env}}.yaml python=${{matrix.python-version}}
80+
if: steps.cache.outputs.cache-hit != 'true'
6581
- uses: actions/cache@v4
6682
with:
6783
path: bioimageio_cache
@@ -77,148 +93,82 @@ jobs:
7793
runs-on: ubuntu-latest
7894
strategy:
7995
matrix:
80-
python-version: ['3.8', '3.12']
8196
include:
82-
- python-version: '3.12'
97+
- python-version: '3.8'
98+
conda-env: py3.8
99+
- python-version: '3.9'
100+
conda-env: tf
101+
- python-version: '3.11'
102+
conda-env: full
83103
report-coverage: true
84104
run-expensive-tests: true
85-
steps:
86-
- uses: actions/checkout@v4
87-
- name: Install Conda environment with Micromamba
88-
if: matrix.python-version != '3.8'
89-
uses: mamba-org/setup-micromamba@v1
90-
with:
91-
cache-downloads: true
92-
cache-environment: true
93-
environment-file: dev/env-wo-python.yaml
94-
create-args: >-
95-
python=${{ matrix.python-version }}
96-
post-cleanup: 'all'
97-
env:
98-
PIP_NO_DEPS: true
99-
- name: Install py3.8 environment
100-
if: matrix.python-version == '3.8'
101-
uses: mamba-org/setup-micromamba@v1
102-
with:
103-
cache-downloads: true
104-
cache-environment: true
105-
environment-file: dev/env-py38.yaml
106-
post-cleanup: 'all'
107-
env:
108-
PIP_NO_DEPS: true
109-
- name: additional setup spec
110-
run: |
111-
conda remove --yes --force bioimageio.spec || true # allow failure for cached env
112-
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
113-
- name: additional setup core
114-
run: pip install --no-deps -e .
115-
- name: Get Date
116-
id: get-date
117-
run: |
118-
echo "date=$(date +'%Y-%b')"
119-
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
120-
shell: bash
121-
- uses: actions/cache@v4
122-
with:
123-
path: bioimageio_cache
124-
key: "test-spec-main-${{ steps.get-date.outputs.date }}"
125-
- name: pytest-spec-main
126-
run: pytest --disable-pytest-warnings
127-
env:
128-
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
129-
RUN_EXPENSIVE_TESTS: ${{ matrix.run-expensive-tests && 'true' || 'false' }}
130-
- if: matrix.report-coverage && github.event_name == 'pull_request'
131-
uses: orgoro/[email protected]
132-
with:
133-
coverageFile: coverage.xml
134-
token: ${{ secrets.GITHUB_TOKEN }}
135-
- if: matrix.report-coverage && github.ref == 'refs/heads/main'
136-
run: |
137-
pip install genbadge[coverage]
138-
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg
139-
coverage html -d dist/coverage
140-
- if: matrix.report-coverage && github.ref == 'refs/heads/main'
141-
uses: actions/upload-artifact@v4
142-
with:
143-
name: coverage
144-
retention-days: 1
145-
path: dist
146-
147-
148-
test-spec-main-tf:
149-
runs-on: ubuntu-latest
150-
strategy:
151-
matrix:
152-
python-version: ['3.9', '3.12']
153-
steps:
154-
- uses: actions/checkout@v4
155-
- uses: mamba-org/setup-micromamba@v1
156-
with:
157-
cache-downloads: true
158-
cache-environment: true
159-
environment-file: dev/env-tf.yaml
160-
condarc: |
161-
channel-priority: flexible
162-
create-args: >-
163-
python=${{ matrix.python-version }}
164-
post-cleanup: 'all'
165-
env:
166-
PIP_NO_DEPS: true
167-
- name: additional setup spec
168-
run: |
169-
conda remove --yes --force bioimageio.spec || true # allow failure for cached env
170-
pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
171-
- name: additional setup core
172-
run: pip install --no-deps -e .
173-
- name: Get Date
174-
id: get-date
175-
run: |
176-
echo "date=$(date +'%Y-%b')"
177-
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
178-
shell: bash
179-
- uses: actions/cache@v4
180-
with:
181-
path: bioimageio_cache
182-
key: "test-spec-main-tf-${{ steps.get-date.outputs.date }}"
183-
- run: pytest --disable-pytest-warnings
184-
env:
185-
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
105+
- python-version: '3.12'
106+
conda-env: tf
186107

187-
test-spec-conda-tf:
188-
runs-on: ubuntu-latest
189-
strategy:
190-
matrix:
191-
python-version: ['3.9', '3.12']
192108
steps:
193-
- uses: actions/checkout@v4
194-
- uses: mamba-org/setup-micromamba@v1
195-
with:
196-
cache-downloads: true
197-
cache-environment: true
198-
environment-file: dev/env-tf.yaml
199-
condarc: |
200-
channel-priority: flexible
201-
create-args: >-
202-
python=${{ matrix.python-version }}
203-
post-cleanup: 'all'
204-
env:
205-
PIP_NO_DEPS: true
206-
- name: additional setup
207-
run: pip install --no-deps -e .
208-
- name: Get Date
209-
id: get-date
210-
run: |
211-
echo "date=$(date +'%Y-%b')"
212-
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT
213-
shell: bash
214-
- uses: actions/cache@v4
215-
with:
216-
path: bioimageio_cache
217-
key: "test-spec-conda-tf-${{ steps.get-date.outputs.date }}"
218-
- name: pytest-spec-tf
219-
run: pytest --disable-pytest-warnings
220-
env:
221-
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
109+
- id: get-env-name
110+
run: |
111+
echo "env-name=main-${{ matrix.conda-env }}-${{ matrix.python-version }}"
112+
echo "env-name=main-${{ matrix.conda-env }}-${{ matrix.python-version }}" >> $GITHUB_OUTPUT
113+
- uses: actions/checkout@v4
114+
- uses: conda-incubator/setup-miniconda@v3
115+
with:
116+
auto-update-conda: true
117+
auto-activate-base: true
118+
activate-environment: ${{steps.get-env-name.outputs.env-name}}
119+
channel-priority: strict
120+
miniforge-version: latest
121+
- name: Get Date
122+
id: get-date
123+
run: |
124+
echo "date=$(date +'%Y-week%U')"
125+
echo "date=$(date +'%Y-week%U')" >> $GITHUB_OUTPUT
126+
echo "today=$(date -u '+%Y%m%d')"
127+
echo "today=$(date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
128+
- name: Cache env
129+
uses: actions/cache@v4
130+
with:
131+
path: ${{ env.CONDA }}/envs/${{steps.get-env-name.outputs.env-name}}
132+
key: >-
133+
conda-${{ runner.os }}-${{ runner.arch }}
134+
-${{steps.get-date.outputs.today }}
135+
-${{ hashFiles(matrix.conda-env) }}
136+
-${{env.CACHE_NUMBER }}
137+
env:
138+
CACHE_NUMBER: 0
139+
id: cache
140+
- name: Update env
141+
run: |
142+
conda env update --name=${{steps.get-env-name.outputs.env-name}} --file=dev/env-${{matrix.conda-env}}.yaml python=${{matrix.python-version}}
143+
conda remove --yes --force bioimageio.spec
144+
if: steps.cache.outputs.cache-hit != 'true'
145+
- name: Install spec from main branch
146+
run: pip install --no-deps git+https://github.com/bioimage-io/spec-bioimage-io
147+
- uses: actions/cache@v4
148+
with:
149+
path: bioimageio_cache
150+
key: "test-spec-main-${{ steps.get-date.outputs.date }}"
151+
- name: pytest-spec-main
152+
run: pytest --disable-pytest-warnings
153+
env:
154+
BIOIMAGEIO_CACHE_PATH: bioimageio_cache
155+
RUN_EXPENSIVE_TESTS: ${{ matrix.run-expensive-tests && 'true' || 'false' }}
156+
- if: matrix.report-coverage && github.event_name == 'pull_request'
157+
uses: orgoro/[email protected]
158+
with:
159+
coverageFile: coverage.xml
160+
token: ${{ secrets.GITHUB_TOKEN }}
161+
- if: matrix.report-coverage && github.ref == 'refs/heads/main'
162+
run: |
163+
pip install genbadge[coverage]
164+
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg
165+
coverage html -d dist/coverage
166+
- if: matrix.report-coverage && github.ref == 'refs/heads/main'
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: coverage
170+
retention-days: 1
171+
path: dist
222172

223173
conda-build:
224174
needs: test-spec-conda
@@ -253,9 +203,6 @@ jobs:
253203
needs: [test-spec-main]
254204
if: github.ref == 'refs/heads/main'
255205
runs-on: ubuntu-latest
256-
defaults:
257-
run:
258-
shell: bash -l {0}
259206
steps:
260207
- uses: actions/checkout@v4
261208
- uses: actions/download-artifact@v4

bioimageio/core/stat_calculators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
import collections.abc
3+
import collections
44
import warnings
55
from itertools import product
66
from typing import (

bioimageio/core/weight_converters/pytorch_to_onnx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pathlib import Path
22

3-
import torch.jit
3+
import torch
44

55
from bioimageio.spec.model.v0_5 import ModelDescr, OnnxWeightsDescr
66

dev/env.yaml dev/env-full.yaml

File renamed without changes.

0 commit comments

Comments
 (0)