Skip to content

Commit d0584da

Browse files
Merge pull request #1218 from computational-cell-analytics/dev
Preparation of new release
2 parents cb2f51b + 83e361b commit d0584da

53 files changed

Lines changed: 439 additions & 267 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/doc_env.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/build_docs.yaml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
name: build_documentation
22

3-
# build the documentation for a new release
3+
# Build and deploy the documentation:
4+
# - on each new release
5+
# - on pushes to main (keep the published docs in sync with main)
6+
# - manually via the Actions tab
47
on:
58
release:
69
types: created
7-
8-
# # for debugging
9-
# on: [push, pull_request]
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- "micro_sam/**/*.py" # Trigger on any changes in python files.
15+
- "doc/**/*.md" # And any changes in the doc files.
16+
workflow_dispatch:
1017

1118
# security: restrict permissions for CI jobs.
1219
permissions:
1320
contents: read
1421

15-
# NOTE: importing of napari fails with CI and I am not quite sure why
16-
# I tried to adjust it based on the napari CI tests, but that didn't seem to help
22+
# Allow only one concurrent Pages deployment; let in-progress runs finish.
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
1726

18-
# https://github.com/napari/napari/blob/main/.github/workflows/test_comprehensive.yml
1927
jobs:
2028
# Build the documentation and upload the static HTML files as an artifact.
2129
build:
@@ -27,18 +35,32 @@ jobs:
2735
- name: Setup micromamba
2836
uses: mamba-org/setup-micromamba@v1
2937
with:
30-
environment-file: .github/doc_env.yaml
38+
environment-file: environment.yaml
39+
40+
# pdoc imports the napari-based submodules (micro_sam.sam_annotator) while
41+
# generating the docs, so the Qt system libraries must be present.
42+
- uses: tlambert03/setup-qt-libs@v1
3143

3244
- name: Install package
3345
shell: bash -l {0}
3446
run: pip install --no-deps -e .
3547

36-
# We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here.
37-
- name: Run pdoc
48+
# pdoc is only needed to build the documentation, so we install it here
49+
# instead of adding it to the standard environment.yaml.
50+
- name: Install pdoc
3851
shell: bash -l {0}
39-
run: python build_doc.py --out
52+
run: pip install pdoc
53+
54+
# We use a custom build script for pdoc itself, ideally you just run
55+
# `pdoc -o docs/ ...` here. Run under a headless display so the napari
56+
# import succeeds in CI.
57+
- name: Run pdoc
58+
uses: aganders3/headless-gui@v2
59+
with:
60+
shell: bash -l {0}
61+
run: python build_doc.py --out
4062

41-
- uses: actions/upload-pages-artifact@v1
63+
- uses: actions/upload-pages-artifact@v3
4264
with:
4365
path: tmp/
4466

@@ -55,4 +77,4 @@ jobs:
5577
url: ${{ steps.deployment.outputs.page_url }}
5678
steps:
5779
- id: deployment
58-
uses: actions/deploy-pages@v2
80+
uses: actions/deploy-pages@v4
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: publish-testpypi
2+
3+
on:
4+
workflow_dispatch: # run by hand from the Actions tab to rehearse a release on TestPyPI
5+
6+
jobs:
7+
publish-testpypi:
8+
# Publish the package to TestPyPI for testing a release before it goes to PyPI.
9+
# Uses TestPyPI trusted publishing (OIDC) via pypa/gh-action-pypi-publish, so no API
10+
# tokens or passwords are stored as secrets. A trusted publisher for this repository
11+
# and workflow must be configured on TestPyPI beforehand (see the project release docs).
12+
runs-on: ubuntu-latest
13+
environment: testpypi
14+
permissions:
15+
id-token: write # required for OIDC trusted publishing
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
- name: Build distributions
23+
run: |
24+
python -m pip install --upgrade pip build
25+
python -m build
26+
- name: Publish to TestPyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1
28+
with:
29+
repository-url: https://test.pypi.org/legacy/
30+
skip-existing: true # tolerate re-runs at an already-uploaded version

.github/workflows/release_drafter.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
# branches to consider in the event; optional, defaults to all
66
branches:
7-
- master
7+
- main
88
# # pull_request event is required only for autolabeler
99
# pull_request:
1010
# # Only following types are handled by the action, but one can default to all as well
@@ -18,6 +18,8 @@ permissions:
1818

1919
jobs:
2020
update_release_draft:
21+
outputs:
22+
new_tag: ${{ steps.tag-version.outputs.new_tag }}
2123
permissions:
2224
# write permission is required to create a github release
2325
contents: write
@@ -48,7 +50,7 @@ jobs:
4850
github_token: ${{ secrets.GITHUB_TOKEN }}
4951
custom_tag: ${{ steps.check-version.outputs.current-version }}
5052

51-
# Drafts your next Release notes as Pull Requests are merged into "master"
53+
# Drafts your next Release notes as Pull Requests are merged into "main"
5254
- name: Publish the release notes
5355
uses: release-drafter/release-drafter@v6.0.0
5456
with:
@@ -59,30 +61,25 @@ jobs:
5961
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6062

6163
deploy:
62-
# This will upload a Python Package using Twine when a release is created
63-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
64-
#
65-
# This job will run when you have tagged a commit, starting with "v*"
66-
# or created a release in GitHub which includes a tag starting with "v*"
67-
# and requires that you have put your twine API key in your
68-
# github secrets (see readme for details)
64+
# Publish the package to PyPI when update_release_draft created a new tag/release.
65+
# Uses PyPI trusted publishing (OIDC) via pypa/gh-action-pypi-publish, so no API
66+
# tokens or passwords are stored as secrets. A trusted publisher for this repository
67+
# and workflow must be configured on PyPI beforehand (see the project release docs).
6968
needs: [update_release_draft]
7069
runs-on: ubuntu-latest
71-
if: contains(github.ref, 'tags')
70+
if: needs.update_release_draft.outputs.new_tag != ''
71+
environment: pypi
72+
permissions:
73+
id-token: write # required for OIDC trusted publishing
7274
steps:
7375
- uses: actions/checkout@v4
7476
- name: Set up Python
7577
uses: actions/setup-python@v5
7678
with:
7779
python-version: '3.x'
78-
- name: Install dependencies
79-
run: |
80-
python -m pip install --upgrade pip
81-
python -m pip install build twine
82-
- name: Build and publish
83-
env:
84-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
85-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
80+
- name: Build distributions
8681
run: |
82+
python -m pip install --upgrade pip build
8783
python -m build
88-
twine upload dist/*
84+
- name: Publish to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: test-pip-installation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
tags:
9+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
10+
pull_request: # run CI on commits to any open PR
11+
workflow_dispatch: # can manually trigger CI from GitHub actions tab
12+
13+
jobs:
14+
test-pip:
15+
name: pip-install ubuntu-latest ${{ matrix.python-version }}
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 60
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: ["3.12"]
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
# Setup Qt libraries so napari/PyQt5 import cleanly during test collection
33+
- uses: tlambert03/setup-qt-libs@v1
34+
35+
- name: Install dev requirements
36+
run: python -m pip install -r requirements-dev.txt
37+
38+
- name: Install micro-sam via pip (with dependencies)
39+
run: python -m pip install -e .
40+
41+
# MobileSAM (vit_t backend) is not on PyPI; install it from GitHub to keep vit_t coverage.
42+
- name: Install MobileSAM
43+
run: python -m pip install git+https://github.com/ChaoningZhang/MobileSAM.git
44+
45+
# A standalone mask prompt is build-dependent with the PyPI torch wheels used here;
46+
# MICRO_SAM_SKIP_STANDALONE_MASK_PROMPT skips that single assertion (see the test).
47+
# Set it via GITHUB_ENV so it is exported to the headless-gui step's environment.
48+
- name: Configure test environment
49+
run: echo "MICRO_SAM_SKIP_STANDALONE_MASK_PROMPT=1" >> "$GITHUB_ENV"
50+
51+
- name: Run non-gui tests
52+
uses: aganders3/headless-gui@v2
53+
with:
54+
run: pytest -m "not gui"

.github/workflows/test.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: test
33
on:
44
push:
55
branches:
6-
- master
76
- main
87
- dev
98
tags:
@@ -20,7 +19,7 @@ jobs:
2019
fail-fast: false
2120
matrix:
2221
os: [ubuntu-latest, windows-latest, macos-latest]
23-
python-version: ["3.11", "3.12"]
22+
python-version: ["3.12"]
2423

2524
steps:
2625
- name: Checkout
@@ -29,7 +28,7 @@ jobs:
2928
- name: Setup micromamba
3029
uses: mamba-org/setup-micromamba@v1
3130
with:
32-
environment-file: 'environment.yaml'
31+
environment-file: "environment.yaml"
3332
create-args: >-
3433
python=${{ matrix.python-version }}
3534

README.md

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

66
# Segment Anything for Microscopy
77

8-
<a href="https://github.com/computational-cell-analytics/micro-sam"><img src="https://github.com/computational-cell-analytics/micro-sam/blob/master/doc/logo/logo_and_text.png" width="300" align="right">
8+
<a href="https://github.com/computational-cell-analytics/micro-sam"><img src="https://github.com/computational-cell-analytics/micro-sam/blob/main/doc/logo/logo_and_text.png" width="300" align="right">
99

1010
Tools for segmentation and tracking in microscopy build on top of [Segment Anything](https://segment-anything.com/).
1111
Segment and track objects in microscopy images interactively with a few clicks!
@@ -60,4 +60,4 @@ We have also built follow-up work that is based on `micro_sam`:
6060

6161
## Release Overview
6262

63-
You can find an overview of changes introduced in previous releases [here](https://github.com/computational-cell-analytics/micro-sam/blob/master/RELEASE_OVERVIEW.md).
63+
You can find an overview of changes introduced in previous releases [here](https://github.com/computational-cell-analytics/micro-sam/blob/main/RELEASE_OVERVIEW.md).

build_doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def check_docs_completeness():
3636
parser.add_argument("--out", "-o", action="store_true")
3737
args = parser.parse_args()
3838

39-
logo_url = "https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/master/doc/logo/logo_and_text.png"
39+
logo_url = "https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/logo/logo_and_text.png"
4040
cmd = ["pdoc", "--docformat", "google", "--logo", logo_url]
4141

4242
if args.out:

development/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ This folder contains scripts used for developing more functionality.
33
- `tracking.py` to develop further tracking functionality
44

55
Note that the scripts here may change quite fast and might not yield good results or not work at all because the corresponding functionality is still under development.
6-
For how to run the napari annotation apps that implement the more stable and tested functionality check out the [examples](https://github.com/computational-cell-analytics/micro-sam/tree/master/examples)
6+
For how to run the napari annotation apps that implement the more stable and tested functionality check out the [examples](https://github.com/computational-cell-analytics/micro-sam/tree/main/examples)

development/apg_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def example_script_3d():
153153

154154
def debug_wsi():
155155
from micro_sam.inference import _stitch_segmentation
156-
from nifty.tools import blocking
156+
from bioimage_cpp.utils import Blocking
157157
from tqdm import tqdm
158158

159159
print("Load data for debugging ....")
@@ -168,7 +168,7 @@ def debug_wsi():
168168
shape = f.attrs["shape"]
169169
tile_shape = f.attrs["tile_shape"]
170170

171-
tiling = blocking([0, 0], shape, tile_shape)
171+
tiling = Blocking([0, 0], shape, tile_shape)
172172
print("Start stitching ...")
173173
seg = _stitch_segmentation(masks, tile_ids, tiling, halo, output_shape=shape)
174174
print(seg.shape)

0 commit comments

Comments
 (0)