Skip to content

Code consistency#358

Merged
PGijsbers merged 15 commits into
mainfrom
code-consistency
Jul 11, 2026
Merged

Code consistency#358
PGijsbers merged 15 commits into
mainfrom
code-consistency

Conversation

@PGijsbers

Copy link
Copy Markdown
Contributor

Several changes to make the code base more consistent in naming, typing, and use of connection vs session.

@sourcery-ai sourcery-ai Bot 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.

Sorry @PGijsbers, your pull request is larger than the review limit of 150000 diff characters

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bbc17fa5-f480-4081-8396-c30cf8118862

📥 Commits

Reviewing files that changed from the base of the PR and between 19b9557 and 67d60f4.

📒 Files selected for processing (4)
  • docs/development/tests.md
  • src/routers/dependencies.py
  • src/routers/tasks.py
  • tests/conftest.py
💤 Files with no reviewable changes (1)
  • tests/conftest.py
✅ Files skipped from review due to trivial changes (1)
  • docs/development/tests.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/routers/dependencies.py
  • src/routers/tasks.py

Walkthrough

The pull request migrates database access from AsyncConnection to AsyncSession, including SQL parameter handling and shared identifier types. FastAPI dependencies, routers, schemas, user state, and response field mappings are updated accordingly. Test fixtures now provide connection and savepoint-backed session variants with dependency overrides, while database and router tests use the new fixtures. Test documentation is updated to describe transaction visibility and rollback behavior.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too generic and does not clearly describe the main change. Use a more specific title such as "Migrate database access from connections to sessions".
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is related to the changeset and accurately summarizes the consistency-focused refactor.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch code-consistency

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.80597% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.62%. Comparing base (7f6ace1) to head (67d60f4).

Files with missing lines Patch % Lines
src/routers/dependencies.py 50.00% 3 Missing ⚠️
src/database/users.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #358       +/-   ##
===========================================
+ Coverage   77.60%   94.62%   +17.01%     
===========================================
  Files          77       77               
  Lines        3774     3815       +41     
  Branches      247      248        +1     
===========================================
+ Hits         2929     3610      +681     
+ Misses        759      137      -622     
+ Partials       86       68       -18     

☔ 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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routers/datasets.py (1)

137-156: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Invalid Python 3 except clause except DatasetNotFoundError, DatasetNoAccessError: is syntax-invalid and will stop src/routers/datasets.py from loading. Use except (DatasetNotFoundError, DatasetNoAccessError): instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routers/datasets.py` around lines 137 - 156, Fix the invalid exception
syntax in the untag_dataset function by changing the except clause to catch
DatasetNotFoundError and DatasetNoAccessError as a tuple: except
(DatasetNotFoundError, DatasetNoAccessError):.
🧹 Nitpick comments (1)
src/database/tasks.py (1)

21-149: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Inconsistent DB-handle parameter naming (expdb vs session) undermines this PR's consistency goal.

Within this same file, most functions take expdb: AsyncSession (Lines 21, 35, 47, 61, 82, 104-106, 121, 135-137) while get_tags and tag take session: AsyncSession (Lines 152, 162). This split isn't tied to raw-SQL vs ORM usage either — src/database/setups.py's get() (also raw SQL via session.execute) uses session, while src/database/runs.py/flows.py's get() use expdb. Since this PR's explicit goal is naming/usage consistency, consider standardizing on one parameter name across all database helper modules.

Also applies to: 152-176

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/database/tasks.py` around lines 21 - 149, Standardize the database-handle
parameter name across the helper modules to match the consistency goal. Rename
the inconsistent `expdb`/`session` parameters in `get`, `get_task_types`,
`get_task_type`, `get_task_type_name`, `get_task_evaluation_measure`,
`get_input_for_task_type`, `get_input_for_task`,
`get_task_type_inout_with_template`, `get_tags`, and `tag`, updating all
internal references and call sites consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/development/tests.md`:
- Around line 95-106: Update the AsyncConnection.execute calls in
test_python_and_php to use the parameters= keyword instead of params= for both
the dataset INSERT and DELETE statements.

In `@src/routers/tasks.py`:
- Around line 472-474: In the loop building filled_templates, replace the unused
name variable in the input_templates iteration with an underscore while
retaining template for fill_template.

In `@tests/routers/users_delete_test.py`:
- Around line 55-61: Update the stale comment near the user setup in the test to
replace the old user_test fixture reference with userdb_session, and accurately
state that rollback is performed by the dependent userdb_connection fixture.
Keep the comment consistent with the current fixture names and behavior.

---

Outside diff comments:
In `@src/routers/datasets.py`:
- Around line 137-156: Fix the invalid exception syntax in the untag_dataset
function by changing the except clause to catch DatasetNotFoundError and
DatasetNoAccessError as a tuple: except (DatasetNotFoundError,
DatasetNoAccessError):.

---

Nitpick comments:
In `@src/database/tasks.py`:
- Around line 21-149: Standardize the database-handle parameter name across the
helper modules to match the consistency goal. Rename the inconsistent
`expdb`/`session` parameters in `get`, `get_task_types`, `get_task_type`,
`get_task_type_name`, `get_task_evaluation_measure`, `get_input_for_task_type`,
`get_input_for_task`, `get_task_type_inout_with_template`, `get_tags`, and
`tag`, updating all internal references and call sites consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4a86116c-015e-494e-8247-fbe17668d0cd

📥 Commits

Reviewing files that changed from the base of the PR and between 7f6ace1 and 19b9557.

📒 Files selected for processing (57)
  • docs/development/tests.md
  • src/core/access.py
  • src/database/datasets.py
  • src/database/evaluations.py
  • src/database/flows.py
  • src/database/qualities.py
  • src/database/runs.py
  • src/database/setups.py
  • src/database/studies.py
  • src/database/tasks.py
  • src/database/users.py
  • src/routers/datasets.py
  • src/routers/dependencies.py
  • src/routers/estimation_procedure.py
  • src/routers/evaluations.py
  • src/routers/flows.py
  • src/routers/qualities.py
  • src/routers/runs.py
  • src/routers/schemas/__init__.py
  • src/routers/schemas/core.py
  • src/routers/schemas/datasets.py
  • src/routers/schemas/flows.py
  • src/routers/schemas/runs.py
  • src/routers/schemas/setups.py
  • src/routers/schemas/study.py
  • src/routers/schemas/tasks.py
  • src/routers/setups.py
  • src/routers/study.py
  • src/routers/tasks.py
  • src/routers/tasktype.py
  • src/routers/users.py
  • tests/conftest.py
  • tests/database/flows_test.py
  • tests/database/runs_test.py
  • tests/dependencies/fetch_user_test.py
  • tests/routers/dataset_tag_test.py
  • tests/routers/dataset_untag_test.py
  • tests/routers/datasets_features_test.py
  • tests/routers/datasets_get_test.py
  • tests/routers/datasets_list_datasets_test.py
  • tests/routers/datasets_qualities_test.py
  • tests/routers/datasets_status_test.py
  • tests/routers/flows_exists_test.py
  • tests/routers/flows_get_test.py
  • tests/routers/qualities_list_test.py
  • tests/routers/runs_get_test.py
  • tests/routers/runs_trace_test.py
  • tests/routers/setups_get_test.py
  • tests/routers/setups_tag_test.py
  • tests/routers/setups_untag_test.py
  • tests/routers/study_attach_test.py
  • tests/routers/tag_test_helper.py
  • tests/routers/task_get_test.py
  • tests/routers/task_list_test.py
  • tests/routers/task_tag_test.py
  • tests/routers/task_type_get_test.py
  • tests/routers/users_delete_test.py

Comment thread docs/development/tests.md
Comment thread src/routers/tasks.py
Comment thread tests/routers/users_delete_test.py
@PGijsbers PGijsbers merged commit a1367c0 into main Jul 11, 2026
8 of 9 checks passed
@PGijsbers PGijsbers deleted the code-consistency branch July 11, 2026 11:49
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.

1 participant