Skip to content

Commit

Permalink
Merge branch 'main' into 1222-fix-memory-leak
Browse files Browse the repository at this point in the history
  • Loading branch information
fepegar committed Jan 27, 2025
2 parents f8335ef + c7f3b82 commit 3c1a7ff
Show file tree
Hide file tree
Showing 71 changed files with 598 additions and 495 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,15 @@
"contributions": [
"code"
]
},
{
"login": "sravan953",
"name": "Keerthi Sravan Ravi",
"avatar_url": "https://avatars.githubusercontent.com/u/6049061?v=4",
"profile": "https://github.com/sravan953",
"contributions": [
"bug"
]
}
],
"contributorsPerLine": 7,
Expand Down
8 changes: 0 additions & 8 deletions .bumpversion.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fetch-depth: 0

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
Expand Down
81 changes: 42 additions & 39 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
# Adapted from https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish

on: push

# https://github.com/fepegar/torchio/actions/runs/6076955855/job/17283217522?pr=1103
permissions:
id-token: write

jobs:
Build-and-publish:
name: Build and publish if needed
build:
name: Build the package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true

# Publish only tagged commits
- name: Publish package to PyPI, if tagged
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
run: uv build

- name: Upload dist directory
uses: actions/upload-artifact@v4
with:
verbose: true
name: dist
path: dist

publish:
name: Publish the package
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: Print ref
run: echo ${{ github.ref }}

- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Install uv if commit is tagged
if: startsWith(github.ref, 'refs/tags')
uses: astral-sh/setup-uv@v5

- name: Publish package to PyPI if commit is tagged
# Publish only tagged commits
if: startsWith(github.ref, 'refs/tags')
run: uv publish --verbose
7 changes: 3 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
windows-latest,
]
python: [
'3.8',
'3.9',
'3.10',
'3.11',
Expand All @@ -41,7 +40,7 @@ jobs:
fetch-depth: 0

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
Expand Down Expand Up @@ -73,7 +72,7 @@ jobs:

- name: Upload coverage reports to Codecov
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python == '3.12' }}
uses: codecov/codecov-action@v4.6.0
uses: codecov/codecov-action@v5.3.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -90,7 +89,7 @@ jobs:
fetch-depth: 0

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ instance/

# Sphinx documentation
docs/_build/
docs/build/
docs/source/sg_execution_times.rst

# PyBuilder
target/
Expand Down Expand Up @@ -110,3 +112,6 @@ ENV/
*DS_Store
.pylintrc
auto_examples

# uv
uv.lock
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: trailing-whitespace # Trims trailing whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.9.3
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -34,10 +34,10 @@ repos:
- id: rst-inline-touching-normal # detect mistake of inline code touching normal text in rst

- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
rev: v3.19.1
hooks:
- id: pyupgrade
args: ['--py38-plus', '--keep-runtime-typing']
args: ['--py39-plus', '--keep-runtime-typing']

- repo: https://github.com/PyCQA/doc8
rev: v1.1.2
Expand Down
13 changes: 6 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version: 2
# Don't publish the docs if there are any warnings, as they might be relevant
# https://github.com/readthedocs/readthedocs.org/issues/6837#issuecomment-607229633
sphinx:
configuration: docs/source/conf.py
fail_on_warning: true

# Formats of the documentation to be built
Expand All @@ -19,10 +20,8 @@ build:
os: ubuntu-22.04
tools:
python: "3.12"

python:
install:
- method: pip
path: .
extra_requirements:
- doc
jobs:
install:
- pip install .
- pip install dependency-groups
- pip-install-dependency-groups doc
31 changes: 18 additions & 13 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
Types of contributions
----------------------

Report Bugs
Report bugs
~~~~~~~~~~~

Report bugs
Expand All @@ -24,26 +24,26 @@ If you are reporting a bug, please include:
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
Fix bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.

Implement Features
Implement features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.

Write Documentation
Write documentation
~~~~~~~~~~~~~~~~~~~

TorchIO could always use more documentation, whether as part of the
official TorchIO docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
Submit feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/fepegar/torchio/issues.
Expand All @@ -55,7 +55,7 @@ If you are proposing a feature:
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
Get started!
------------

Ready to contribute? Here's how to set up ``torchio`` for local development.
Expand All @@ -80,12 +80,12 @@ already be implemented.
4) Install your local copy into a virtual environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you use ``conda``, this is how you can set up your fork for local development::
`uv <https://docs.astral.sh/uv/>`_ is recommended for development.
You can use `just <https://just.systems/>`_ to set up the development environment.
This will 1) install ``uv`` if not found and 2) install ``torchio`` and all its
dependencies::

conda create --name torchioenv python --yes
conda activate torchioenv
pip install --editable ".[all]"
pre-commit install
just setup

5) Create a branch for local development using the issue number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -102,7 +102,7 @@ Now you can make your changes locally.
When you're done making changes, check that your changes pass the tests
using ``pytest``::

pytest -x
uv run pytest -x

7) Commit your changes and push your branch to GitHub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -130,6 +130,11 @@ time you modify them and reload them in the browser::

make livehtml

If you prefer to activate your environment manually or not use ``uv``,
add ``PREFIX=""`` to the command::

make html PREFIX=""

9) Submit a pull request on GitHub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ Thanks goes to all these people ([emoji key](https://allcontributors.org/docs/en
<td align="center" valign="top" width="14.28%"><a href="https://github.com/marius-sm"><img src="https://avatars.githubusercontent.com/u/40166021?v=4?s=100" width="100px;" alt="marius-sm"/><br /><sub><b>marius-sm</b></sub></a><br /><a href="#ideas-marius-sm" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/haarisr"><img src="https://avatars.githubusercontent.com/u/122410226?v=4?s=100" width="100px;" alt="haarisr"/><br /><sub><b>haarisr</b></sub></a><br /><a href="https://github.com/fepegar/torchio/commits?author=haarisr" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/c-winder"><img src="https://avatars.githubusercontent.com/u/50587864?v=4?s=100" width="100px;" alt="Chris Winder"/><br /><sub><b>Chris Winder</b></sub></a><br /><a href="https://github.com/fepegar/torchio/issues?q=author%3Ac-winder" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/ricky-walsh/"><img src="https://avatars.githubusercontent.com/u/70853488?v=4?s=100" width="100px;" alt="Ricky Walsh"/><br /><sub><b>Ricky Walsh</b></sub></a><br /> <a href="https://github.com/fepegar/torchio/commits?author=rickymwalsh" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/ricky-walsh/"><img src="https://avatars.githubusercontent.com/u/70853488?v=4?s=100" width="100px;" alt="Ricky Walsh"/><br /><sub><b>Ricky Walsh</b></sub></a><br /><a href="https://github.com/fepegar/torchio/commits?author=rickymwalsh" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sravan953"><img src="https://avatars.githubusercontent.com/u/6049061?v=4?s=100" width="100px;" alt="Keerthi Sravan Ravi"/><br /><sub><b>Keerthi Sravan Ravi</b></sub></a><br /><a href="https://github.com/fepegar/torchio/issues?q=author%3Asravan953" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>
Expand Down
16 changes: 9 additions & 7 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXAUTOBUILD = sphinx-autobuild
SOURCEDIR = source
BUILDDIR = build
PREFIX = uv run

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(PREFIX) $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(PREFIX) $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

livehtml:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(PREFIX) $(SPHINXAUTOBUILD) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/examples/plot_3d_to_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def plot_batch(sampler):
loader = tio.SubjectsLoader(queue, batch_size=16)
batch = tio.utils.get_first_item(loader)

fig, axes = plt.subplots(4, 4, figsize=(12, 10))
_, axes = plt.subplots(4, 4, figsize=(12, 10))
for ax, im in zip(axes.flatten(), batch['t1']['data']):
ax.imshow(im.squeeze(), cmap='gray')
plt.suptitle(sampler.__class__.__name__)
Expand Down
3 changes: 1 addition & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import os
import sys
from datetime import date
from typing import List

sys.path.insert(0, os.path.abspath('../../src'))
import torchio # noqa: E402
Expand Down Expand Up @@ -83,7 +82,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List[str] = []
exclude_patterns: list[str] = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'friendly'
Expand Down
Loading

0 comments on commit 3c1a7ff

Please sign in to comment.