Skip to content

Commit

Permalink
report failing file on pydantic deserialise error
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed May 24, 2024
1 parent e7f4449 commit 65344ee
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ibek/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pydantic import create_model, field_validator
from pydantic.fields import FieldInfo
from pydantic_core import PydanticUndefined
from pydantic_core import PydanticUndefined, ValidationError
from ruamel.yaml.main import YAML

from .args import EnumArg, IdArg, ObjectArg
Expand Down Expand Up @@ -41,12 +41,16 @@ def make_entity_models(self, definition_yaml: List[Path]) -> List[Type[Entity]]:
for definition in definition_yaml:
support_dict = YAML(typ="safe").load(definition)

Support.model_validate(support_dict)
try:
Support.model_validate(support_dict)

# deserialize the support module definition file
support = Support(**support_dict)
# make Entity classes described in the support module definition file
self._make_entity_models(support)
# deserialize the support module definition file
support = Support(**support_dict)
# make Entity classes described in the support module definition file
self._make_entity_models(support)
except ValidationError:
print(f"PYDANTIC VALIDATION ERROR IN {definition}")
raise

return list(self._entity_models.values())

Expand Down

0 comments on commit 65344ee

Please sign in to comment.