Skip to content
Snippets Groups Projects

missed updates and fixes for pydantic update

@erigler @swilbur

This MR fixes changes missed by the pydantic_update MR. The suggested mapping to pydantic v2 from v1 .dict() (converting python objects to dictionaries) is to use model_dump(). However, model_dump() serializes time into strings. The sqlalchemy_utc.UtcDateTime type used on the metadata_table expects an aware datetime.datetime type for created_time, updated_time, starttime, and endtime. Therefore, I'm using the @field_serializer decorator to give instructions to model_dump() to create the dictionary.

We also discussed how UTCDateTime does not care if the datetime.datetime object passed into it is aware or native. I added extra logic to add tzinfo=tz.tzutc() on input datetime.datetime objects.

I also added some unit tests around create_metadata.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading