From 2d26330950ec25feda70d6775c44cf1ab87f63ed Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Tue, 19 May 2026 18:37:58 +0200 Subject: [PATCH 1/3] Retry SwinUNETR init without img_size on TypeError Improve SwinUNETR_ initializer error handling: when parent_init raises a TypeError, check for an 'img_size' kwarg and, if present, log a warning about MONAI API compatibility, remove 'img_size' and retry initialization. The previous fallback that forced in_channels=1 has been removed. If 'img_size' is not present, the original TypeError is re-raised so other errors are not silently swallowed. --- .../code_models/models/model_SwinUNetR.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/napari_cellseg3d/code_models/models/model_SwinUNetR.py b/napari_cellseg3d/code_models/models/model_SwinUNetR.py index f90ef1df..8c59e93a 100644 --- a/napari_cellseg3d/code_models/models/model_SwinUNetR.py +++ b/napari_cellseg3d/code_models/models/model_SwinUNetR.py @@ -53,9 +53,15 @@ def __init__( try: parent_init(**init_kwargs) except TypeError as e: - logger.warning(f"Caught TypeError: {e}") - init_kwargs["in_channels"] = 1 - parent_init(**init_kwargs) + if "img_size" in init_kwargs: + logger.warning( + "Retrying SwinUNETR initialization without img_size due to " + f"MONAI API compatibility issue: {e}" + ) + init_kwargs.pop("img_size", None) + parent_init(**init_kwargs) + else: + raise # def forward(self, x_in): # y = super().forward(x_in) From a3ff603218d79a098ca5f38b63220b659b3a3d18 Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Tue, 19 May 2026 18:40:17 +0200 Subject: [PATCH 2/3] Pin jupyter-book to <2 in docs extras Restrict the docs extra to "jupyter-book<2" instead of an unbounded "jupyter-book" to prevent automatic upgrades to jupyter-book 2.x, which may introduce breaking changes to the docs build and toolchain compatibility. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d2f79565..9d392834 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,7 +148,7 @@ dev = [ "twine", ] docs = [ - "jupyter-book", + "jupyter-book<2", ] test = [ "pytest", From cc1a59f33795de219118da5f20b6e524089f3328 Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Tue, 19 May 2026 18:40:39 +0200 Subject: [PATCH 3/3] Revamp GitHub Actions docs workflow Replace the old single-job deploy workflow with a modern two-stage docs workflow: build and deploy. Adds path and pull_request triggers, workflow_dispatch support, concurrency, and read permissions for contents. The build job checks out code, sets up Python 3.12, installs docs dependencies, builds the Jupyter Book and uploads the HTML artifact (skip on PRs). The deploy job runs only on main (non-PR), requests pages and id-token permissions, sets the github-pages environment, and uses actions/deploy-pages@v4 to publish instead of the previous peaceiris action. Also modernizes action versions and enables pip caching. --- .github/workflows/build_docs.yml | 102 +++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index dc828c87..a6c915f5 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -1,39 +1,77 @@ -name: deploy +name: docs on: push: - branches: # branch to trigger deployment + branches: - main + paths: + - "docs/**" + - "napari_cellseg3d/**" + - "pyproject.toml" + - ".github/workflows/docs.yml" + pull_request: + branches: + - main + paths: + - "docs/**" + - "napari_cellseg3d/**" + - "pyproject.toml" + - ".github/workflows/docs.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pages-${{ github.ref }} + cancel-in-progress: true -# This job installs dependencies, build the book, and pushes it to `gh-pages` jobs: - build-and-deploy-book: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: [3.9] + build: + name: build docs + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.12" + cache: pip + + - name: Install docs dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[docs]" + + - name: Build Jupyter Book + run: | + jupyter-book build docs/ + + - name: Upload Pages artifact + if: github.event_name != 'pull_request' + uses: actions/upload-pages-artifact@v3 + with: + path: docs/_build/html + + deploy: + name: deploy docs + needs: build + runs-on: ubuntu-latest + + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: - - uses: actions/checkout@v2 - - # Install dependencies - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install jupyter-book - pip install -e . - - # Build the book - - name: Build the book - run: | - jupyter-book build docs/ - - # Deploy the book's HTML to gh-pages branch - - name: GitHub Pages action - uses: peaceiris/actions-gh-pages@v3.6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/_build/html + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4