From b951c2677e6463a0646b3030649080e424f97d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 10:25:00 +0100 Subject: [PATCH 1/8] Add workflow to build and deploy documentation --- .github/workflows/docs.yml | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..595ddbc7d --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,66 @@ +name: Build and deploy documentation + +on: + push: + +permissions: + contents: write + +concurrency: + group: docs-${{ github.ref }} + cancel-in-progress: true + +env: + FORCE_COLOR: 1 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v6 + + - name: Install just + uses: extractions/setup-just@v3 + + - name: Build docs + run: just build-docs + + - name: Upload docs to smokeshow + if: github.ref != 'refs/heads/main' + run: | + rm ./docs/build/html/_images/*.gif + rm ./docs/build/html/_images/*.png + uvx smokeshow upload ./docs/build/html + + - name: Upload artifacts using actions/upload-pages-artifact + if: github.ref == 'refs/heads/main' + id: deployment + uses: actions/upload-pages-artifact@v3 + with: + path: ./docs/build/html + + deploy: + if: github.ref == 'refs/heads/main' + + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + runs-on: ubuntu-latest + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From eabf6386f72f1460dcb4359e389c10a672bb75ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 10:36:17 +0100 Subject: [PATCH 2/8] Fix errors --- .github/workflows/docs.yml | 18 +++++++++++++++++- docs/source/data/image.rst | 1 + pyproject.toml | 1 + .../preprocessing/spatial/to_canonical.py | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 595ddbc7d..2f6bb7227 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -26,9 +26,24 @@ jobs: - name: Install just uses: extractions/setup-just@v3 + - name: Restore TorchIO cached data + id: cache-torchio-data-restore + uses: actions/cache/restore@v4 + with: + path: ~/.cache/torchio + key: ${{ runner.os }}-torchio-data + - name: Build docs - run: just build-docs + run: just build-docs && ls ~/.cache/torchio + + - name: Save TorchIO cached data + id: cache-torchio-data-save + uses: actions/cache@v4 + with: + path: ~/.cache/torchio + key: ${{ steps.cache-torchio-data-restore.outputs.cache-primary-key }} + # Uploade to smokeshow if not on main branch - name: Upload docs to smokeshow if: github.ref != 'refs/heads/main' run: | @@ -36,6 +51,7 @@ jobs: rm ./docs/build/html/_images/*.png uvx smokeshow upload ./docs/build/html + # Upload to GitHub Pages if on main branch - name: Upload artifacts using actions/upload-pages-artifact if: github.ref == 'refs/heads/main' id: deployment diff --git a/docs/source/data/image.rst b/docs/source/data/image.rst index bc170940e..45e358315 100644 --- a/docs/source/data/image.rst +++ b/docs/source/data/image.rst @@ -41,6 +41,7 @@ structure. .. autoclass:: ScalarImage + :members: .. autoclass:: LabelMap diff --git a/pyproject.toml b/pyproject.toml index 9e64d326e..5c36185cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,7 @@ dev = [ "pre-commit-uv==4.1.4", ] doc = [ + "distinctipy==1.3.4", "einops==0.8.0", "furo==2024.8.6", "matplotlib==3.9.4", diff --git a/src/torchio/transforms/preprocessing/spatial/to_canonical.py b/src/torchio/transforms/preprocessing/spatial/to_canonical.py index 75ee1bd98..e01f83fed 100644 --- a/src/torchio/transforms/preprocessing/spatial/to_canonical.py +++ b/src/torchio/transforms/preprocessing/spatial/to_canonical.py @@ -24,4 +24,4 @@ class ToCanonical(ToOrientation): """ def __init__(self, **kwargs): - super().__init__('RAS', **kwargs) + super().__init__(orientation='RAS', **kwargs) From 13faa7b20d7e6e97751f2c942ddb19c0e269b667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 10:39:28 +0100 Subject: [PATCH 3/8] Fix warning --- src/torchio/transforms/preprocessing/spatial/to_canonical.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/torchio/transforms/preprocessing/spatial/to_canonical.py b/src/torchio/transforms/preprocessing/spatial/to_canonical.py index e01f83fed..22503fc98 100644 --- a/src/torchio/transforms/preprocessing/spatial/to_canonical.py +++ b/src/torchio/transforms/preprocessing/spatial/to_canonical.py @@ -22,6 +22,3 @@ class ToCanonical(ToOrientation): .. _NiBabel docs about image orientation: https://nipy.org/nibabel/image_orientation.html """ - - def __init__(self, **kwargs): - super().__init__(orientation='RAS', **kwargs) From 229a1292ef646f0c8e9413ea58f4a60a0daa623d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 10:56:16 +0100 Subject: [PATCH 4/8] Improve workflow --- .github/workflows/docs.yml | 6 +++++- justfile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2f6bb7227..42c0768b5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,6 +23,9 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@v6 + - name: Install dependencies + run: uv sync --group doc + - name: Install just uses: extractions/setup-just@v3 @@ -34,9 +37,10 @@ jobs: key: ${{ runner.os }}-torchio-data - name: Build docs - run: just build-docs && ls ~/.cache/torchio + run: just build-docs - name: Save TorchIO cached data + if: steps.cache-torchio-data-restore.outputs.cache-hit != 'true' id: cache-torchio-data-save uses: actions/cache@v4 with: diff --git a/justfile b/justfile index 0e160d8d5..ad8e30521 100644 --- a/justfile +++ b/justfile @@ -153,7 +153,7 @@ docs_cmd := "uv run --group doc --directory docs" [positional-arguments] build-docs *args='': - {{docs_cmd}} -- sphinx-build -M html source build + {{docs_cmd}} -- sphinx-build -M html source build "$@" [positional-arguments] serve-docs *args='': From 3ecf1f9495874402e69206ecae91d2c78b7e9d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 11:05:23 +0100 Subject: [PATCH 5/8] Fix command to build docs --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index ad8e30521..0e160d8d5 100644 --- a/justfile +++ b/justfile @@ -153,7 +153,7 @@ docs_cmd := "uv run --group doc --directory docs" [positional-arguments] build-docs *args='': - {{docs_cmd}} -- sphinx-build -M html source build "$@" + {{docs_cmd}} -- sphinx-build -M html source build [positional-arguments] serve-docs *args='': From 535cf41c27a35719b4da639942e7579f7a5a443a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 11:15:14 +0100 Subject: [PATCH 6/8] Uncomment temporarily --- .github/workflows/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 42c0768b5..b4bdf4281 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -57,14 +57,14 @@ jobs: # Upload to GitHub Pages if on main branch - name: Upload artifacts using actions/upload-pages-artifact - if: github.ref == 'refs/heads/main' + # if: github.ref == 'refs/heads/main' id: deployment uses: actions/upload-pages-artifact@v3 with: path: ./docs/build/html deploy: - if: github.ref == 'refs/heads/main' + # if: github.ref == 'refs/heads/main' needs: build From 64ef7168f561ac947dd35cb1fe3890c7e7d0c230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 11:24:01 +0100 Subject: [PATCH 7/8] Rename documentation workflow --- .github/workflows/docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b4bdf4281..677af9d29 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: Build and deploy documentation +name: Documentation on: push: @@ -57,14 +57,14 @@ jobs: # Upload to GitHub Pages if on main branch - name: Upload artifacts using actions/upload-pages-artifact - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' id: deployment uses: actions/upload-pages-artifact@v3 with: path: ./docs/build/html deploy: - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' needs: build From cac43d2025585b89549cd38caed0d5e9895c775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 13 Jul 2025 11:29:10 +0100 Subject: [PATCH 8/8] Stop cancelling deployments in progress --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 677af9d29..4d3d87f13 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,7 @@ permissions: concurrency: group: docs-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: false env: FORCE_COLOR: 1