Skip to content

[TST] Add test runners for Python 3.11-3.13 - #598

Merged
alyssadai merged 2 commits into
mainfrom
add-python-test-runners
Sep 11, 2026
Merged

alyssadai merged 2 commits into
mainfrom
add-python-test-runners

Conversation

@alyssadai

@alyssadai alyssadai commented Sep 10, 2026

Copy link
Copy Markdown
Contributor
  • Note: the README already had Python 3.10-3.13 specified as supported

Checklist

This section is for the PR reviewer

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see our Contributing Guidelines for more info)
  • PR has a label for the release changelog or skip-release (to be applied by maintainers only)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass
  • If the PR changes the SPARQL query template, the default Neurobagel query file has also been regenerated

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

Summary by Sourcery

Test the project across all supported Python versions and maintain compatibility with pandas below version 3.

Enhancements:

  • Expand the test workflow to run against Python 3.10 through 3.13.
  • Constrain the pandas dependency to versions below 3 for compatibility.

CI:

  • Run the test suite in parallel across the supported Python versions without stopping other matrix jobs after a failure.

Tests:

  • Add CI coverage for Python 3.11, 3.12, and 3.13.

@alyssadai alyssadai added the pr-tests Add or improve existing tests label Sep 10, 2026
@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The test workflow now runs the existing test job independently on Python 3.10, 3.11, 3.12, and 3.13, with uv configured from the matrix and failures isolated across versions.

File-Level Changes

Change Details Files
Expand the CI test workflow into a multi-version Python test matrix.
  • Add Python 3.10–3.13 versions to the job matrix.
  • Disable fail-fast so every Python version completes independently.
  • Parameterize uv setup with the matrix-selected Python version.
.github/workflows/test.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#546 Add CI test runners for Python 3.11, 3.12, and 3.13 while retaining testing on Python 3.10.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.20%. Comparing base (9971f37) to head (0e2be8b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #598   +/-   ##
=======================================
  Coverage   95.20%   95.20%           
=======================================
  Files          29       29           
  Lines        1355     1355           
  Branches       90       90           
=======================================
  Hits         1290     1290           
  Misses         36       36           
  Partials       29       29           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@surchs
surchs self-requested a review September 10, 2026 17:44

@surchs surchs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alyssadai. The fix looks good, but everything beyond 3.10 seems to fail. The bot thinks this section here is the culprit:

api/app/api/utility.py

Lines 428 to 437 in 9971f37

# TODO: Revisit this as there may be a more elegant solution.
# The following code replaces columns with all NaN values with values of None, to ensure they show up in the final JSON as `null`.
# This is needed as the above .agg() seems to turn NaN into None for object-type columns (which have some non-missing values)
# but not for columns with all NaN, which end up with a column type of float64. This is a problem because
# if the column corresponds to a SessionResponse attribute with an expected str type, then the column values will be converted
# to the string "nan" in the response JSON, which we don't want.
all_nan_columns = subject_data.columns[subject_data.isna().all()]
subject_data[all_nan_columns] = subject_data[all_nan_columns].replace(
{np.nan: None}
)

I didn't look into it more closely than that. But I'd say we fix it in this PR.

@alyssadai

alyssadai commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @surchs for flagging that. I think this is due to the new default type inference behaviour in pandas>=3 (which is used by default for Python>=3.11). Before pandas 3, string columns with some none-type values would be typed as object, but with pandas 3+, they are typed as str, with missing values being converted to np.nan. This breaks the type checking for some our current Pydantic models. I think a long-term fix would be to normalize missing values to None to ensure they are not interpreted as numeric, but for now I have pinned the pandas version.

@surchs surchs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks! 🧑‍🍳

@alyssadai
alyssadai merged commit 31e0cf5 into main Sep 11, 2026
16 checks passed
@alyssadai
alyssadai deleted the add-python-test-runners branch September 11, 2026 01:00
@neurobagel-bot

Copy link
Copy Markdown
Contributor

🚀 PR was released in v0.11.0 🚀

@neurobagel-bot neurobagel-bot Bot added the released This issue/pull request has been released. label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-tests Add or improve existing tests released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test runners for Python 3.11-3.13

2 participants