Skip to content

Conversation

@pcrespov
Copy link
Member

@pcrespov pcrespov commented Nov 17, 2025

What do these changes do?

This PR unifies ordering for listing operations in rest APIs. It also refines type annotation and documentation practices, and enhances overall code robustness and clarity. These changes are used in a follow up PR but submitted them separately for clarity and to facilitate the review.

Here are some of details (AI generated):

Ordering and Query Parameter Improvements

  • Added new OrderClause, OrderDirection, and check_ordering_list utilities in list_operations.py to support robust, type-safe ordering for API queries, including duplicate and conflict detection.
  • Refactored rest_ordering.py to use the new ordering utilities, introduced generic OrderingQueryParams for flexible multi-field ordering from query strings, and improved validation and parsing logic. [1] [2]
  • Added comprehensive tests for ordering logic and query parameter parsing, including duplicate handling, conflict detection, and validation against allowed fields. [1] [2] [3]

Type Annotation and Documentation Enhancements

  • Updated Python coding instructions to require use of annotated_types.doc() for documenting non-obvious parameter and return types, with clear examples and conventions for concise docstrings.
  • Refactored invitations.py models to use Annotated types and validators for improved clarity and type safety, including lower-casing of email fields and explicit handling of optional values. [1] [2] [3] [4]

String Type Improvements

  • Updated string type definitions to enforce lower-casing for case-insensitive matching, improving consistency and safety in user input handling. [1] [2]

Miscellaneous Fixes and Enhancements

  • Improved error messages in _common.py for assertion failures related to default factories.
  • Minor HTML template update for notification emails to fix formatting and add PO center link.

Related issue/s

How to test

cd packages/models-library
make install-dev
pytest -vv test_list_operations.py
pytest -vv test_rest_ordering.py
cd services/invitations
make install-dev
pytest -vv tests/unit/test_invitations.py

Dev-ops

@pcrespov pcrespov changed the title ♻️✨ Robust Ordering, Query Parsing, and Type Annotation Refinements 🎨 Robust Ordering, Query Parsing, and Type Annotation Refinements Nov 17, 2025
@pcrespov pcrespov changed the title 🎨 Robust Ordering, Query Parsing, and Type Annotation Refinements 🎨 Ordering, Query Parsing, and Type Annotation Refinements and Unification Nov 17, 2025
@pcrespov pcrespov self-assigned this Nov 17, 2025
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 90.78947% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.83%. Comparing base (1a89829) to head (200695f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8599      +/-   ##
==========================================
+ Coverage   87.13%   88.83%   +1.70%     
==========================================
  Files        2012     1595     -417     
  Lines       79110    66285   -12825     
  Branches     1404      560     -844     
==========================================
- Hits        68930    58884   -10046     
+ Misses       9786     7254    -2532     
+ Partials      394      147     -247     
Flag Coverage Δ *Carryforward flag
integrationtests 60.47% <ø> (-2.91%) ⬇️ Carriedforward from 1a89829
unittests 87.90% <90.78%> (+1.64%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library 92.83% <89.39%> (-0.07%) ⬇️
pkg_notifications_library 85.20% <ø> (ø)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration 72.76% <ø> (ø)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 84.89% <ø> (+19.70%) ⬆️
agent 93.44% <ø> (ø)
api_server 91.37% <ø> (ø)
autoscaling 95.83% <ø> (ø)
catalog 92.06% <ø> (ø)
clusters_keeper 99.14% <ø> (ø)
dask_sidecar 91.72% <ø> (ø)
datcore_adapter 97.95% <ø> (ø)
director 75.72% <ø> (ø)
director_v2 85.67% <ø> (-5.61%) ⬇️
dynamic_scheduler 96.66% <ø> (ø)
dynamic_sidecar 90.83% <ø> (ø)
efs_guardian 89.83% <ø> (ø)
invitations 90.90% <ø> (ø)
payments 92.70% <ø> (ø)
resource_usage_tracker 92.11% <ø> (+0.21%) ⬆️
storage 86.34% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 86.81% <100.00%> (+0.03%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a89829...200695f. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pcrespov pcrespov marked this pull request as ready for review November 17, 2025 10:09
@pcrespov pcrespov added this to the Imparable milestone Nov 17, 2025
@mergify
Copy link
Contributor

mergify bot commented Nov 17, 2025

🧪 CI Insights

Here's what we observed from your CI run for 200695f.

✅ Passed Jobs With Interesting Signals

Pipeline Job Signal Health on master Retries 🔍 CI Insights 📄 Logs
CI system-tests You had a 36% chance of failing… lucky you! 🎲 Flaky Configure an automatic retry View View
unit-tests Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR unifies ordering for listing operations in REST APIs, refines type annotation and documentation practices using annotated_types.doc(), and enhances code robustness and clarity through improved validation and utility functions.

  • Introduces new ordering utilities (OrderClause, OrderDirection, check_ordering_list) with comprehensive validation for duplicates and conflicts
  • Updates Python coding guidelines to require annotated_types.doc() for documenting non-obvious parameters and returns
  • Refactors invitation models to use Annotated types with validators for improved type safety, including case-insensitive email handling

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/models-library/src/models_library/list_operations.py New module defining ordering operations including OrderDirection, OrderClause, and check_ordering_list utility
packages/models-library/src/models_library/rest_ordering.py Refactored to use new ordering utilities, added generic OrderingQueryParams for flexible multi-field ordering
packages/models-library/src/models_library/invitations.py Updated to use Annotated types, added email lower-casing validator, replaced timezone.utc with UTC
packages/models-library/src/models_library/string_types.py Added to_lower=True for case-insensitive string matching
packages/models-library/tests/test_list_operations.py New tests for ordering validation, duplicate handling, and conflict detection
packages/models-library/tests/test_rest_ordering.py Added tests for OrderingQueryParams parsing and validation
services/invitations/tests/unit/test_invitations.py Added test verifying consecutive invitations have different timestamps
services/invitations/tests/unit/conftest.py Updated to test case-insensitive email handling
services/web/server/src/simcore_service_webserver/users/_accounts_service.py Refactored to use annotated_types.doc() for parameter documentation
services/web/server/src/simcore_service_webserver/login_accounts/_service.py Fixed host URL formatting to strip trailing slashes
services/web/server/src/simcore_service_webserver/templates/common/request_account.jinja2 Added PO center link to email template
services/web/server/tests/unit/with_dbs/03/test_users_rest_search.py Updated test to verify case-insensitive email search
packages/notifications-library/src/notifications_library/templates/on_account_requested.email.content.* Added PO center link and fixed HTML formatting
api/specs/web-server/_common.py Improved assertion error message for default factories
.github/instructions/python.instructions.md Added comprehensive guidelines for using annotated_types.doc() and documentation best practices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

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

Very cool! Thanks a lot

@pcrespov pcrespov force-pushed the is23/pre-changes-for-po-center branch from e6ff38b to 200695f Compare November 18, 2025 10:34
@pcrespov pcrespov enabled auto-merge (squash) November 18, 2025 10:35
@pcrespov
Copy link
Member Author

@mergify queue

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

queue

🟠 Waiting for conditions to match

Details
  • -closed [📌 queue requirement]
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • label=🤖-automerge
      • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
      • #approved-reviews-by>=2
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
      • #review-threads-unresolved=0
      • -conflict
      • -draft
      • base=master
      • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
      • label!=🤖-do-not-merge
      • any of: [🛡 GitHub branch protection]
        • check-skipped = deploy to dockerhub
        • check-neutral = deploy to dockerhub
        • check-success = deploy to dockerhub
      • any of: [🛡 GitHub branch protection]
        • check-success = system-tests
        • check-neutral = system-tests
        • check-skipped = system-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = unit-tests
        • check-neutral = unit-tests
        • check-skipped = unit-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = check OAS' are up to date
        • check-neutral = check OAS' are up to date
        • check-skipped = check OAS' are up to date
      • any of: [🛡 GitHub branch protection]
        • check-success = integration-tests
        • check-neutral = integration-tests
        • check-skipped = integration-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = build-test-images (frontend) / build-test-images
        • check-neutral = build-test-images (frontend) / build-test-images
        • check-skipped = build-test-images (frontend) / build-test-images
      • any of: [🛡 GitHub branch protection]
        • check-success = SonarCloud Code Analysis
        • check-neutral = SonarCloud Code Analysis
        • check-skipped = SonarCloud Code Analysis
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed

@sonarqubecloud
Copy link

Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

thanks

@pcrespov pcrespov merged commit a93bbd3 into ITISFoundation:master Nov 18, 2025
94 of 95 checks passed
@pcrespov pcrespov deleted the is23/pre-changes-for-po-center branch November 18, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants