Skip to content

Update pydantic to v2 #247

Closed
Closed

Description

@d-perl

We have been trying to move Hyperion and Dodal to Pydantic v2 for some time. We think that this is the only remaining dependency we have which is stuck on v1.

I'm happy do do any work needed if necessary.

Activity

  1. d-perl commented on Mar 7, 2024

    @d-perl
    Author

    I note that running the tests in a fresh environment with Pydantic upgraded to 2.6 doesn't result in any failures. Is there (still) a reason for it to be pinned? @ndevenish @graeme-winter

  2. ndevenish commented on Mar 27, 2024

    @ndevenish
    Contributor

    There was a reason, which was that v2 broke things and we needed to update the code. Noemi pointed out to me on Friday that they eventually added some backwards-compatibility to newer versions, so if the code doesn't need changing then there is no reason to pin.

    I'm not sure how much work this would be to verify, but I'd probably like to get things locked in for this run before changing everything round (next week is probably going to be busy!)

  3. added 2 commits that reference this issue on Mar 28, 2024
  4. d-perl commented on Mar 28, 2024

    @d-perl
    Author

    @ndevenish Yes, I also believe that it should be okay because of the retrospective addition of backwards compatibility (they caused a lot of annoyance breaking everything...). Looking at the pydantic classes here they appear very simple so I think the chances are pretty good that few if any changes should be needed.

    I was wrong about the tests though, there are a few which fail: test_api_exchange_declare, test_api_binding_declare and test_api_add_vhost. Each of these assert that puted requests contain some empty items ('arguments': {} and "tags": [] respectively) which seem to be explicitly excluded with exclude_defaults=True options passed to various model .dict() calls in rabbitmq.py - it kind of feels like this was a bug before already? (Since the empty list/dicts are created by the Field's default_factory)

    Here is a branch which is "working" and with some new tests which show the above change: https://github.com/dperl-dls/python-zocalo/tree/247_upgrade_pydantic but I'm not sure if this is correct/how to tell if those empty arguments are required by rabbitMQ. I would really appreciate if you could find time to take a look in the not too distant future but I understand it's Easter and busy startup etc.

  5. ndevenish commented on Jul 19, 2024

    @ndevenish
    Contributor

    Should be resolved with #255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions