Skip to content

Commit 942656d

Browse files
authored
Merge pull request #530 from bioimage-io/faster_ci
Improve CI speed with lighter/cached (mamba) environments
2 parents 334fb5d + 0c0ab7e commit 942656d

File tree

5 files changed

+77
-27
lines changed

5 files changed

+77
-27
lines changed

.github/workflows/auto_update_main.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,21 @@ jobs:
5454
ref: gh-pages
5555
path: gh-pages
5656
- name: install script deps
57-
run: pip install requests typer bioimageio.spec lxml
57+
uses: mamba-org/provision-with-micromamba@main
58+
with:
59+
cache-downloads: true
60+
cache-env: true
61+
environment-file: false
62+
environment-name: scriptenv
63+
channels: conda-forge
64+
extra-specs: | # script dependencies
65+
bioimageio.spec
66+
lxml
67+
requests
68+
typer
5869
- name: update external resources
5970
id: update_external
71+
shell: bash -l {0}
6072
run: python scripts/update_external_resources.py --max-resource-count 15 ${{ github.event_name == 'pull_request' && '--no-ignore-status-5xx' || '--ignore-status-5xx' }}
6173
- name: "Upload collection update"
6274
uses: actions/upload-artifact@v3
@@ -71,6 +83,7 @@ jobs:
7183
mkdir dist
7284
mv tmp_download_counts.json dist/download_counts.json
7385
- name: update partner resources
86+
shell: bash -l {0}
7487
run: python scripts/update_partner_resources.py
7588
- name: Upload preview of updated partner resources
7689
if: github.event_name == 'pull_request'
@@ -114,8 +127,21 @@ jobs:
114127
ref: gh-pages
115128
path: gh-pages
116129
- name: install script deps
117-
run: pip install typer bioimageio.spec boltons lxml requests
130+
uses: mamba-org/provision-with-micromamba@main
131+
with:
132+
cache-downloads: true
133+
cache-env: true
134+
environment-file: false
135+
environment-name: scriptenv
136+
channels: conda-forge
137+
extra-specs: | # script dependencies
138+
bioimageio.spec
139+
boltons
140+
lxml
141+
requests
142+
typer
118143
- name: generate collection rdf
144+
shell: bash -l {0}
119145
run: python scripts/generate_collection_rdf.py
120146
- name: Upload preview of collection.json
121147
if: github.event_name == 'pull_request'
@@ -169,8 +195,6 @@ jobs:
169195
mkdir -p "collection/${{ matrix.update.resource_id }}"
170196
cp -r "collection-update/${{ matrix.update.resource_id }}"/* "collection/${{ matrix.update.resource_id }}"
171197
rm -rf collection-update
172-
- name: install script deps
173-
run: pip install requests
174198
- name: get urls of previous PRs
175199
id: pr_urls
176200
run: python scripts/get_previous_pr_urls.py ${{ matrix.update.resource_id }}

.github/workflows/reset_pending_auto_update.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10-
- name: install script deps
11-
run: pip install typer
1210
- id: detect_auto_updates
1311
run: python scripts/detect_auto_updates.py auto-update-
1412
- name: Delete auto-update-* branches

.github/workflows/validate_resources.yaml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,22 @@ jobs:
3939
ref: gh-pages
4040
path: gh-pages
4141
- name: install script deps
42-
run: pip install typer bioimageio.spec lxml bioimageio.core packaging
42+
uses: mamba-org/provision-with-micromamba@main
43+
with:
44+
cache-downloads: true
45+
cache-env: true
46+
environment-file: false
47+
environment-name: scriptenv
48+
channels: conda-forge
49+
extra-specs: | # script dependencies
50+
bioimageio.core
51+
bioimageio.spec
52+
lxml
53+
packaging
54+
typer
4355
- name: update RDFs
4456
id: update_rdfs
57+
shell: bash -l {0}
4558
run: python scripts/update_rdfs.py --branch ${{ github.head_ref || github.ref }}
4659
- name: check pending versions limit
4760
if: inputs.check_validation == 'yes' && steps.pending.outputs.retrigger == 'yes'
@@ -50,6 +63,7 @@ jobs:
5063
- name: static validation
5164
if: steps.update_rdfs.outputs.has_pending_matrix_bioimageio == 'yes'
5265
id: static_validation
66+
shell: bash -l {0}
5367
run: python scripts/static_validation.py '${{ steps.update_rdfs.outputs.pending_matrix_bioimageio }}'
5468
- name: Upload static validation summaries and conda envs
5569
if: steps.update_rdfs.outputs.has_pending_matrix_bioimageio == 'yes'
@@ -60,6 +74,7 @@ jobs:
6074
retention-days: 1
6175
- name: check if validation passed
6276
if: steps.update_rdfs.outputs.has_pending_matrix_bioimageio == 'yes' && inputs.check_validation == 'yes'
77+
shell: bash -l {0}
6378
run: python scripts/check_validation_passed.py dist/static_validation_artifact
6479

6580
dynamic-validation:
@@ -86,33 +101,29 @@ jobs:
86101
environment-file: artifacts/static_validation_artifact/${{ matrix.resource_id }}/${{ matrix.version_id }}/conda_env_${{ matrix.weight_format }}.yaml
87102
extra-specs: | # script dependencies
88103
typer
89-
bioimageio.spec
104+
conda-forge::bioimageio.spec
90105
continue-on-error: true # we inspect this step's outcome in dynamic_validation.py
91106
timeout-minutes: 60
92-
# atm bioimageio.core imports directly from tqdm, PR to import from spec is on the way...
93-
# todo: remove tqdm to avoid spamming logs
94-
# - name: remove tqdm to avoid spamming logs
95-
# shell: bash -l {0}
96-
# run: conda remove --yes --force tqdm
97-
# continue-on-error: true
107+
- name: remove tqdm to avoid spamming logs
108+
shell: bash -l {0}
109+
run: conda remove --yes --force tqdm
110+
continue-on-error: true
98111
- name: get artifact name wo forward slashes
99112
id: artifact_name
100113
run: echo ::set-output name=name::dynamic_validation_artifact_$(echo ${{ matrix.resource_id }}_${{ matrix.version_id }}_${{ matrix.weight_format }} | sed 's#/##g')
101114
- name: dynamic validation
102115
shell: bash -l {0}
103-
timeout-minutes: 60
104116
run: python scripts/dynamic_validation.py dist/dynamic_validation_artifact ${{ matrix.resource_id }} ${{ matrix.version_id }} ${{ matrix.weight_format }} --create-env-outcome ${{ steps.create_env.outcome }} --${{ contains(inputs.deploy_to, 'gh-pages') && 'no-ignore' || 'ignore' }}-rdf-source-field-in-validation
117+
timeout-minutes: 60
105118
- name: Upload validation summary
106119
uses: actions/upload-artifact@v3
107120
with:
108121
name: ${{ steps.artifact_name.outputs.name }}
109122
path: dist/dynamic_validation_artifact/${{ matrix.resource_id }}/${{ matrix.version_id }}/${{ matrix.weight_format }}
110123
retention-days: 1
111-
- name: install script deps
112-
if: steps.create_env.outcome == 'success' && inputs.check_validation == 'yes'
113-
run: pip install typer bioimageio.spec
114124
- name: check if validation passed
115125
if: inputs.check_validation == 'yes'
126+
shell: bash -l {0}
116127
run: python scripts/check_validation_passed.py dist/dynamic_validation_artifact/${{ matrix.resource_id }}/${{ matrix.version_id }}/${{ matrix.weight_format }}
117128

118129
deploy:
@@ -131,10 +142,24 @@ jobs:
131142
with:
132143
path: artifacts
133144
- name: install script deps
134-
run: pip install typer packaging numpy bioimageio.spec lxml
145+
uses: mamba-org/provision-with-micromamba@main
146+
with:
147+
cache-downloads: true
148+
cache-env: true
149+
environment-file: false
150+
environment-name: scriptenv
151+
channels: conda-forge
152+
extra-specs: | # script dependencies
153+
bioimageio.spec
154+
lxml
155+
numpy
156+
packaging
157+
typer
135158
- name: download partner test summaries
159+
shell: bash -l {0}
136160
run: python scripts/download_partner_test_summaries.py
137161
- name: prepare to deploy
162+
shell: bash -l {0}
138163
run: python scripts/prepare_to_deploy.py --branch ${{ github.head_ref || github.ref }}
139164
- name: Deploy to gh-pages 🚀
140165
if: contains(inputs.deploy_to, 'gh-pages')
@@ -145,6 +170,7 @@ jobs:
145170
folder: dist/gh_pages_update
146171
- name: add documentation files to preview
147172
if: contains(inputs.deploy_to, 'preview') # only download documentation for preview to ease review
173+
shell: bash -l {0}
148174
run: python scripts/download_documentation.py --folder dist/gh_pages_update
149175
- name: Upload preview
150176
if: contains(inputs.deploy_to, 'preview')

scripts/detect_auto_updates.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import argparse
12
import subprocess
23
from pprint import pprint
34

4-
import typer
5-
65
from bare_utils import set_gh_actions_output
76

87

@@ -19,4 +18,10 @@ def main(prefix: str):
1918

2019

2120
if __name__ == "__main__":
22-
typer.run(main)
21+
parser = argparse.ArgumentParser()
22+
parser.add_argument(
23+
"prefix",
24+
help="prefix to identify branches, e.g. 'auto-update-'",
25+
)
26+
args = parser.parse_args()
27+
main(args.prefix)

scripts/static_validation.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ def get_env_from_deps(deps: Dependencies):
3636
dep_file_content = r.text
3737
if deps.manager == "conda":
3838
conda_env = yaml.load(dep_file_content)
39-
# add bioimageio.core if not present
40-
channels = conda_env.get("channels", [])
41-
if "conda-forge" not in channels:
42-
conda_env["channels"] = channels + ["conda-forge"]
4339

40+
# add bioimageio.core to dependencies
4441
deps = conda_env.get("dependencies", [])
4542
if not isinstance(deps, list):
4643
raise TypeError(f"expected dependencies in conda environment.yaml to be a list, but got: {deps}")
4744
if not any(isinstance(d, str) and d.startswith("bioimageio.core") for d in deps):
48-
conda_env["dependencies"] = deps + ["bioimageio.core"]
45+
conda_env["dependencies"] = deps + ["conda-forge::bioimageio.core"]
4946
elif deps.manager == "pip":
5047
pip_req = [d for d in dep_file_content.split("\n") if not d.strip().startswith("#")]
5148
conda_env["dependencies"].append("pip")

0 commit comments

Comments
 (0)