equinor / fmu-dataio

FMU data standard and data export with rich metadata in the FMU context
https://fmu-dataio.readthedocs.io/en/latest/
Apache License 2.0
10 stars 15 forks source link

Validate uuids against `pydantic.UUID4` #759

Closed mferrera closed 2 months ago

mferrera commented 2 months ago

Currently most models validate against the standard library uuid package.

from uuid import UUID

def SomeModel(BaseModel):
    some_id: UUID

We can be a bit more specific and with extra validation.

from pydantic import UUID4

def SomeModel(BaseModel):
    some_id: UUID4
equinor-ruaj commented 2 months ago

@mferrera This seems to have broken some of our automatic tests. For the tests we can update our static uuids as you have done, but are we guaranteed that e.g. SMDA always has valid uuids?

rwiker commented 2 months ago

This is not a valid change. uuid4 means that the value has been generated from a random number generator, while the uuids that we actually need to compare with are uuid1 from smda. The uuid for drogon is all zeroes, and not really a valid value, but it is a valid uuid ("Nil UUID").

TL;DR: You cannot make any assumptions on the format of uuids created by other systems.

mferrera commented 2 months ago

Okay, thanks very much for the ping about this, glad it was caught before going too far out. We can revert it.