calgo-lab / green-db

The monorepo that powers the GreenDB.
https://calgo-lab.github.io/green-db/
22 stars 2 forks source link

Update pydantic causing errors in product_classification image #145

Closed BigDatalex closed 10 months ago

BigDatalex commented 10 months ago

When deploying the latest product_classification image I received the following error:

...

2023-08-29 20:37:17 │ ❱  75 │   sustainability_labels: conlist(CertificateType, min_items=1)  # ty │
...

2023-08-29 20:37:17 TypeError: conlist() got an unexpected keyword argument 'min_items'

The error is related to recent changes in the pydantic package from V1 to V2 see: https://docs.pydantic.dev/latest/migration/

For me, it's weird that this occurred because our pydantic version is set within poetry to ^1.9.0 see: https://github.com/calgo-lab/green-db/blob/1669f9c27d8052f535986dbaa46d13d1ebe2fb6a/core/pyproject.toml#L17

and this means our pydantic version is intended to be >=1.9.0 and <2.0, so normally a migration should not be necessary.

However, I retrieved the above error. In order to resolve this, I tried to add pydantic using ^1.9.0 in the product_classification pyproject.toml which did not help. So in the end I migrated our pydantic version in the core package to 2.3.0 and updated all poetry lock files referencing the core package. For the migration, it was necessary to refactor some function/Variable names in the database packages, because they became deprecated e.g.: