From 42dcd2b1ae0cee37cb6d5d6e91df2d366d985350 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 12 Dec 2024 21:54:05 -0500 Subject: [PATCH 1/9] chore(deps): Update minimum dependencies --- pyproject.toml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6af2e831..678c5cb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,24 +19,24 @@ classifiers = [ license = {file = "LICENSE"} requires-python = ">=3.10" dependencies = [ - "acres", + "acres >= 0.2.0", "looseversion", "nibabel >= 4.0.1", "nipype >= 1.8.5", - "nireports >= 23.2.2", + "nireports >= 24.0.3", "nitime", - "nitransforms >= 24.0.2", - "niworkflows >= 1.11.0", - "numpy >= 1.22", - "packaging", + "nitransforms >= 24.1.0", + "niworkflows >= 1.12.1", + "numpy >= 1.24", + "packaging >= 24", "pandas", "psutil >= 5.4", - "pybids >= 0.15.2", + "pybids >= 0.16", "requests", "sdcflows >= 2.10.0", "smriprep >= 0.16.0", "tedana >= 23.0.2", - "templateflow >= 24.1.0", + "templateflow >= 24.2.2", "transforms3d", "toml", "codecarbon", @@ -59,7 +59,7 @@ doc = [ "sphinx_rtd_theme>=0.5.2", ] dev = [ - "ruff ~= 0.4.3", + "ruff", "pre-commit", ] duecredit = ["duecredit"] @@ -75,11 +75,11 @@ telemetry = [ "sentry-sdk >= 1.3", ] test = [ - "coverage[toml]", - "pytest", - "pytest-cov", + "coverage[toml] >= 5.2.1", + "pytest >= 8.1", + "pytest-cov >= 2.11", "pytest-env", - "pytest-xdist", + "pytest-xdist >= 2.5", ] maint = [ "fuzzywuzzy", From 2d75ec9cb448e12e8243b67f97db9964747749fe Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 08:46:30 -0500 Subject: [PATCH 2/9] test: Use legacy print options for doctests --- fmriprep/conftest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fmriprep/conftest.py b/fmriprep/conftest.py index c72c7cc1..18ca708a 100644 --- a/fmriprep/conftest.py +++ b/fmriprep/conftest.py @@ -26,6 +26,11 @@ def copytree_or_skip(source, target): pytest.skip(f'Cannot copy {data_dir!r} into {target / data_dir.name}. Probably in a zip.') +@pytest.fixture(scope='session', autouse=True) +def _legacy_printoptions(): + np.set_printoptions(legacy='1.21') + + @pytest.fixture(autouse=True) def _populate_namespace(doctest_namespace, tmp_path): doctest_namespace['copytree_or_skip'] = copytree_or_skip From 66a61a06e56262cb675569a9d01bba2561894e96 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 08:57:26 -0500 Subject: [PATCH 3/9] chore(deps): More minimum dependencies, use uv_resolution --- pyproject.toml | 16 ++++++++-------- tox.ini | 12 +++--------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 678c5cb1..6469d770 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,27 +20,27 @@ license = {file = "LICENSE"} requires-python = ">=3.10" dependencies = [ "acres >= 0.2.0", - "looseversion", + "looseversion >= 1.3", "nibabel >= 4.0.1", "nipype >= 1.8.5", "nireports >= 24.0.3", - "nitime", + "nitime >= 0.9", "nitransforms >= 24.1.0", "niworkflows >= 1.12.1", "numpy >= 1.24", "packaging >= 24", - "pandas", + "pandas >= 1.2", "psutil >= 5.4", "pybids >= 0.16", - "requests", + "requests >= 2.27", "sdcflows >= 2.10.0", "smriprep >= 0.16.0", "tedana >= 23.0.2", "templateflow >= 24.2.2", - "transforms3d", - "toml", - "codecarbon", - "APScheduler", + "transforms3d >= 0.4", + "toml >= 0.10", + "codecarbon >= 2", + "APScheduler >= 3.10", ] dynamic = ["version"] diff --git a/tox.ini b/tox.ini index 7b9fb682..81ef8c77 100644 --- a/tox.ini +++ b/tox.ini @@ -40,16 +40,10 @@ pass_env = PYTHON_GIL extras = test setenv = + pre: UV_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pre: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple -deps = - min: nibabel == 4.0.1 - min: nipype == 1.8.5 - min: nitransforms == 21.0.0 - min: numpy == 1.22 - min: psutil == 5.4 - min: pybids == 0.15.2 - min: tedana == 23.0.2 - min: templateflow == 24.1.0 +uv_resolution = + min: lowest-direct commands_pre = python scripts/fetch_templates.py From 209eb8322d409a75075aaa4ea88623ad7a8a31d0 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 08:58:57 -0500 Subject: [PATCH 4/9] chore(ci): Use tox-uv to run tests --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c58288f..bf93cef2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,6 +57,8 @@ jobs: run: | sudo apt update sudo apt install -y --no-install-recommends graphviz + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -65,14 +67,12 @@ jobs: run: python -c "import sys; print(sys.version)" - name: Install tox run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions + uv tool install --with=tox-uv --with=tox-gh-actions tox - name: Show tox config run: tox c - name: Run tox run: tox -v --exit-and-dump-after 1200 - uses: codecov/codecov-action@v5 with: - file: coverage.xml token: ${{ secrets.CODECOV_TOKEN }} if: ${{ always() }} From 600ae7cb1df5c9232636371befe8ce302133c726 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 08:59:59 -0500 Subject: [PATCH 5/9] chore(tox): Test py313 with unreleased traits --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index 81ef8c77..69458280 100644 --- a/tox.ini +++ b/tox.ini @@ -38,6 +38,8 @@ pass_env = CLICOLOR CLICOLOR_FORCE PYTHON_GIL +deps = + py313: traits @ git+https://github.com/enthought/traits.git@10954eb extras = test setenv = pre: UV_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple From 0244297fc322b4047db5b43598c1ad0a71f2a196 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 09:24:26 -0500 Subject: [PATCH 6/9] sty: Apply UP031 to fmriprep --- fmriprep/cli/tests/test_parser.py | 6 +++--- fmriprep/config.py | 7 +++---- fmriprep/interfaces/reports.py | 6 +++--- fmriprep/utils/telemetry.py | 2 +- fmriprep/workflows/bold/stc.py | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fmriprep/cli/tests/test_parser.py b/fmriprep/cli/tests/test_parser.py index ce84fb60..d68ea2bb 100644 --- a/fmriprep/cli/tests/test_parser.py +++ b/fmriprep/cli/tests/test_parser.py @@ -82,9 +82,9 @@ def test_parser_valid(tmp_path, args): ('1000MB', 1), ('1T', 1000), ('1TB', 1000), - ('%dK' % 1e6, 1), - ('%dKB' % 1e6, 1), - ('%dB' % 1e9, 1), + ('1000000K', 1), + ('1000000KB', 1), + ('1000000000B', 1), ], ) def test_memory_arg(tmp_path, argval, gb): diff --git a/fmriprep/config.py b/fmriprep/config.py index 6ba0ae1c..b89e9ad3 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -149,11 +149,10 @@ # Just get so analytics track one hit from contextlib import suppress - from requests import ConnectionError, ReadTimeout - from requests import get as _get_url + import requests - with suppress((ConnectionError, ReadTimeout)): - _get_url('https://rig.mit.edu/et/projects/nipy/nipype', timeout=0.05) + with suppress((requests.ConnectionError, requests.ReadTimeout)): + requests.get('https://rig.mit.edu/et/projects/nipy/nipype', timeout=0.05) # Execution environment _exec_env = os.name diff --git a/fmriprep/interfaces/reports.py b/fmriprep/interfaces/reports.py index 8f26c374..6d199cce 100644 --- a/fmriprep/interfaces/reports.py +++ b/fmriprep/interfaces/reports.py @@ -242,13 +242,13 @@ def _generate_segment(self): reg = { 'FSL': [ 'FSL flirt with boundary-based registration' - ' (BBR) metric - %d dof' % dof, + f' (BBR) metric - {dof} dof', 'FSL flirt rigid registration - 6 dof', ], 'FreeSurfer': [ 'FreeSurfer bbregister ' - '(boundary-based registration, BBR) - %d dof' % dof, - 'FreeSurfer mri_coreg - %d dof' % dof, + f'(boundary-based registration, BBR) - {dof} dof', + f'FreeSurfer mri_coreg - {dof} dof', ], }[self.inputs.registration][self.inputs.fallback] diff --git a/fmriprep/utils/telemetry.py b/fmriprep/utils/telemetry.py index bfbdf29c..33116f76 100644 --- a/fmriprep/utils/telemetry.py +++ b/fmriprep/utils/telemetry.py @@ -116,7 +116,7 @@ def process_crashfile(crashfile): scope.set_extra(k, strv[0]) else: for i, chunk in enumerate(strv): - scope.set_extra('%s_%02d' % (k, i), chunk) + scope.set_extra(f'{k}_{i:02d}', chunk) fingerprint = '' issue_title = f'{node_name}: {gist}' diff --git a/fmriprep/workflows/bold/stc.py b/fmriprep/workflows/bold/stc.py index 20047418..90c9593c 100644 --- a/fmriprep/workflows/bold/stc.py +++ b/fmriprep/workflows/bold/stc.py @@ -106,7 +106,7 @@ def init_bold_stc_wf( frac = config.workflow.slice_time_ref tzero = np.round(first + frac * (last - first), 3) - afni_ver = ''.join('%02d' % v for v in afni.Info().version() or []) + afni_ver = ''.join(f'{v:02d}' for v in afni.Info().version() or []) workflow = Workflow(name=name) workflow.__desc__ = f"""\ BOLD runs were slice-time corrected to {tzero:0.3g}s ({frac:g} of slice acquisition range From 05621c6595deefb1ab1fab0429f0d0216785914b Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 09:26:02 -0500 Subject: [PATCH 7/9] sty: Apply UP031 to .maint scripts --- .maint/paper_author_list.py | 4 ++-- .maint/update_authors.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.maint/paper_author_list.py b/.maint/paper_author_list.py index c10bd5c7..fbd52ba8 100755 --- a/.maint/paper_author_list.py +++ b/.maint/paper_author_list.py @@ -38,7 +38,7 @@ def _aslist(inlist): aff_indexes = [ ', '.join( [ - '%d' % (affiliations.index(a) + 1) + str(affiliations.index(a) + 1) for a in _aslist(author.get('affiliation', 'Unaffiliated')) ] ) @@ -52,7 +52,7 @@ def _aslist(inlist): file=sys.stderr, ) - print('Authors (%d):' % len(author_matches)) + print(f'Authors ({len(author_matches)}):') print( '{}.'.format( '; '.join( diff --git a/.maint/update_authors.py b/.maint/update_authors.py index 55e526e9..b439db17 100755 --- a/.maint/update_authors.py +++ b/.maint/update_authors.py @@ -259,7 +259,7 @@ def _aslist(value): aff_indexes = [ ', '.join( [ - '%d' % (affiliations.index(a) + 1) + str(affiliations.index(a) + 1) for a in _aslist(author.get('affiliation', 'Unaffiliated')) ] ) @@ -272,7 +272,7 @@ def _aslist(value): file=sys.stderr, ) - print('Authors (%d):' % len(hits)) + print(f'Authors ({len(hits)}):') print( '{}.'.format( '; '.join( From b44752087ab2403f88a1b547ebc8f5446b4568df Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 09:29:59 -0500 Subject: [PATCH 8/9] chore(ci): Run checks via tox --- .github/workflows/test.yml | 20 ++++++++++++++++++++ tox.ini | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf93cef2..70648e7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,3 +76,23 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} if: ${{ always() }} + + checks: + runs-on: "ubuntu-latest" + continue-on-error: true + strategy: + matrix: + check: ["style", "spellcheck"] + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v4 + - name: Install tox + run: uv tool install tox --with=tox-uv + - name: Show tox config + run: tox c -e ${{ matrix.check }} + - name: Run check + run: tox -e ${{ matrix.check }} diff --git a/tox.ini b/tox.ini index 69458280..69547839 100644 --- a/tox.ini +++ b/tox.ini @@ -48,7 +48,8 @@ uv_resolution = min: lowest-direct commands_pre = - python scripts/fetch_templates.py + # Use py* to disable for other environments + py3{10,11,12,13}: python scripts/fetch_templates.py commands = pytest --cov-report term-missing --durations=20 --durations-min=1.0 {posargs:-n auto} From e6b5fcb34a741cd038cfe5d3a836b00f1704c55d Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 09:30:20 -0500 Subject: [PATCH 9/9] chore(ci): Remove redundant workflow --- .github/workflows/contrib.yml | 38 ----------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/contrib.yml diff --git a/.github/workflows/contrib.yml b/.github/workflows/contrib.yml deleted file mode 100644 index 266ea29a..00000000 --- a/.github/workflows/contrib.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Contribution checks - -on: - push: - branches: - - master - pull_request: - branches: - - master - -defaults: - run: - shell: bash - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - style: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: pipx run ruff check . - - run: pipx run ruff format --diff . - - codespell: - name: Check for spelling errors - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Codespell - uses: codespell-project/actions-codespell@v2