Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix *Urls serialization #6852

Merged
merged 8 commits into from
Nov 28, 2024

Conversation

giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Nov 27, 2024

What do these changes do?

After migration to Pydantic v2, all *Urls are not str anymore. This causes issues when serializing objects with fields of these types.

This PR enhances the json_dumps method to reproduce the previous behavior serializing all the *Urls new types as str.

Actually the error occurred was:

TypeError: Object of type 'AnyUrl' is not JSON serializable
The above exception was the direct cause of the following exception:
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/scu/.venv/lib/python3.11/site-packages/settings_library/utils_cli.py:1 │
│ 65 in settings                                                               │
│                                                                              │
│   162 │   │   pydantic_export_options: dict[str, Any] = {"exclude_unset": ex │
│   163 │   │                                                                  │
│   164 │   │   if as_json:                                                    │
│ ❱ 165 │   │   │   print_as_json(                                             │
│   166 │   │   │   │   settings_obj,                                          │
│   167 │   │   │   │   compact=compact,                                       │
│   168 │   │   │   │   show_secrets=show_secrets,                             │
│                                                                              │
│

...
TypeError: Type is not JSON serializable: AnyUrl

Related issue/s

How to test

Dev-ops checklist

@giancarloromeo giancarloromeo self-assigned this Nov 27, 2024
@giancarloromeo giancarloromeo changed the title 🐛 Fix Urls serialization 🐛 Fix *Urls serialization Nov 27, 2024
@giancarloromeo giancarloromeo marked this pull request as ready for review November 27, 2024 14:13
@giancarloromeo giancarloromeo added this to the Event Horizon milestone Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.38%. Comparing base (da8adc3) to head (9f9e42e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6852      +/-   ##
==========================================
+ Coverage   86.61%   89.38%   +2.77%     
==========================================
  Files        1491     1261     -230     
  Lines       59914    53241    -6673     
  Branches     2166      973    -1193     
==========================================
- Hits        51896    47592    -4304     
+ Misses       7701     5503    -2198     
+ Partials      317      146     -171     
Flag Coverage Δ
integrationtests 64.77% <ø> (+4.58%) ⬆️
unittests 86.97% <100.00%> (+0.80%) ⬆️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library 91.17% <100.00%> (+<0.01%) ⬆️
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration 70.00% <ø> (ø)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.36% <ø> (+19.69%) ⬆️
agent 97.00% <ø> (ø)
api_server 89.72% <ø> (ø)
autoscaling 95.21% <ø> (ø)
catalog 90.57% <ø> (∅)
clusters_keeper 98.73% <ø> (ø)
dask_sidecar 91.26% <ø> (ø)
datcore_adapter 93.17% <ø> (ø)
director 76.57% <ø> (+0.17%) ⬆️
director_v2 91.13% <ø> (+5.53%) ⬆️
dynamic_scheduler 96.59% <ø> (ø)
dynamic_sidecar 89.75% <ø> (ø)
efs_guardian 90.12% <ø> (ø)
invitations 93.44% <ø> (∅)
osparc_gateway_server 85.49% <ø> (ø)
payments 92.76% <ø> (ø)
resource_usage_tracker 90.79% <ø> (ø)
storage 89.66% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 88.70% <ø> (+1.55%) ⬆️

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 da8adc3...9f9e42e. Read the comment docs.

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

Thanks

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

thx!

@giancarloromeo giancarloromeo enabled auto-merge (squash) November 28, 2024 10:50
@pcrespov pcrespov disabled auto-merge November 28, 2024 13:06
@pcrespov pcrespov merged commit 573b7c3 into ITISFoundation:master Nov 28, 2024
84 of 86 checks passed
@giancarloromeo giancarloromeo deleted the fix-urls-serialization branch November 28, 2024 14:58
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.

5 participants