Skip to content

PD-90 PD-92 Python to 3.13 and replace Gino with sqlalchemy#82

Merged
paulineribeyre merged 25 commits into
masterfrom
feat/3.13
Dec 23, 2025
Merged

PD-90 PD-92 Python to 3.13 and replace Gino with sqlalchemy#82
paulineribeyre merged 25 commits into
masterfrom
feat/3.13

Conversation

@paulineribeyre

@paulineribeyre paulineribeyre commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator

Link to JIRA ticket if there is one: https://ctds-planx.atlassian.net/browse/PD-90 and https://ctds-planx.atlassian.net/browse/PD-92

New Features

Breaking Changes

Bug Fixes

Improvements

  • Fix and re-enable database migrations unit tests

Dependency updates

  • Update Python from 3.9 to 3.13
  • Remove Gino, use sqlalchemy

Deployment changes

@github-actions

Copy link
Copy Markdown

The style in this PR agrees with black. ✔️

This formatting comment was generated automatically by a script in uc-cdis/wool.

@github-actions

Copy link
Copy Markdown
filepath passed SUBTOTAL
tests/test_client_credentials.py 1 1
tests/test_requestor.py 5 5
TOTAL 6 6

Please find the detailed integration test report here

Please find the Github Action logs here

@paulineribeyre
paulineribeyre marked this pull request as ready for review December 19, 2025 22:49
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))


def test_all_migrations_have_tests():

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

copied from gen3-workflow

Comment thread tests/conftest.py
Comment on lines +186 to +188
def access_token_patcher(client, request, access_token_patcher_param):
"""
Patch the `access_token` function. By default, this fixture is parametrized to return

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed the access token fixtures - the tests were previously running twice even when using access_token_user_only_patcher because of params ["user_token", "client_token"] in autoused access_token_user_client_patcher

@github-actions

Copy link
Copy Markdown

Failed to Prepare CI environment

Please find the Github Action logs here

@uc-cdis uc-cdis deleted a comment from github-actions Bot Dec 22, 2025
@uc-cdis uc-cdis deleted a comment from github-actions Bot Dec 22, 2025
@github-actions

Copy link
Copy Markdown
filepath passed SUBTOTAL
tests/test_client_credentials.py 1 1
tests/test_requestor.py 5 5
TOTAL 6 6

Please find the detailed integration test report here

Please find the Github Action logs here

@nss10 nss10 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.

I was able to review the code. It looks good with a few questions/suggestions. I will take another pass at the review to look into the '/tests/' -- Done 🟢

Comment thread docs/openapi.yaml
)
).one()
except IntegrityError as e:
if "asyncpg.exceptions.UniqueViolationError" in str(e):

@nss10 nss10 Dec 22, 2025

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.

This raised a question for me around the handling of request_id. My understanding is that the request_id is generated server-side as a UUID (here), not provided by the user.
In the unlikely event that a duplicate does occur, should we be returning a 4xx error to the user? From the user’s perspective, the request itself is valid, and the collision is a system-generated artifact rather than an issue with client input.

If that is the case, we might want to try a retry mechanism with a new request_id in such case.

Let me know if I misunderstood this somehow.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes a retry would be better. I would rather merge the PR asap and not make further changes but I could add a TODO

In any case, like you said this is very unlikely to happen

Comment thread src/requestor/routes/query.py Outdated
Comment thread src/requestor/app.py
def load_modules(app: FastAPI = None) -> None:
# FIXME: Identify the cause for duplicate entry points (PXP-8443)
# Added a set on entry points to dodge the intermittent duplicate modules issue
for ep in set(entry_points()["requestor.modules"]):

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.

Haven't gotten back to this issue in years. Did you investigate the issue during the course of this PR?

@paulineribeyre paulineribeyre Dec 23, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't reproduce it anymore so i took my chances and removed it!

Comment thread src/requestor/arborist.py
Comment on lines +198 to 200
"An error occured while updating role '{}': '{}'".format(
{role["id"]}, str(e)
)

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.

Why not change it to an f-string completely?

Comment thread src/requestor/config.py Outdated
Comment thread src/requestor/routes/manage.py

@nss10 nss10 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.

Reviewed tests as well. Tests look good overall.

raise


class MigrationRunner:

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.

Good abstraction. 👍

Comment thread tests/conftest.py
Comment thread tests/test_actions.py
with mock.patch("requestor.request_utils.requests") as mock_requests:
# update the request status
res = client.put(f"/request/{request_id}", json={"status": "APPROVED"})
assert res.status_code == 200, res.text

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.

Tests Fail early now. Good 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it makes more sense to check the status code before running assert_called_once_with and getting a weird error when the request failed

@paulineribeyre
paulineribeyre requested a review from nss10 December 23, 2025 16:27
@github-actions

Copy link
Copy Markdown
filepath passed SUBTOTAL
tests/test_client_credentials.py 1 1
tests/test_requestor.py 5 5
TOTAL 6 6

Please find the detailed integration test report here

Please find the Github Action logs here

@paulineribeyre
paulineribeyre merged commit 8387c82 into master Dec 23, 2025
10 checks passed
@paulineribeyre
paulineribeyre deleted the feat/3.13 branch December 23, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants