Skip to content

Commit

Permalink
add comment re schema error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Jul 17, 2023
1 parent 1a727d5 commit 3605365
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ibek/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,21 @@ class Entity(BaseSettings):
)
__definition__: Definition

@model_validator(mode="after") # type: ignore
@model_validator(mode="before") # type: ignore
def add_ibek_attributes(cls, entity: Entity):
"""Whole Entity model validation"""
"""
Whole Entity model validation
TODO at present an object reference to an ID where the referred object violates
schema is seen as "KeyError: "object XXX not found in [...]" which hides the
schema violation error.
This could potentially be fixed by doing the validation here instead
(removing extra:forbid from the model_config). BUT, at present passing
the info arg to this function receives a dict of the IOC instance
that created this entity, not the entity itself. This may be a
pydantic bug?
"""

# find the id field in this Entity if it has one
ids = set(a.name for a in entity.__definition__.args if isinstance(a, IdArg))
Expand Down
1 change: 1 addition & 0 deletions tests/samples/generate_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export DEFS=${SAMPLES_DIR}/../../ibek-defs
# this is so relative schema mode lines work
cd $SAMPLES_DIR

set -x
echo making the support yaml schema
ibek ibek-schema ${SAMPLES_DIR}/schemas/ibek.defs.schema.json

Expand Down

0 comments on commit 3605365

Please sign in to comment.