-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model Sanity Checking #108
Comments
Note that some sanity checks are already in place, e.g. in
For example removing class Author(BaseModel):
gnd: str
surname: Annotated[str, SPARQLBinding("nameLabel")]
works: list[Work]
education: Annotated[list[str], SPARQLBinding("educated_atLabel")] rightfully crashes with And attempting to group by a name that does not exist, e.g. class Author(BaseModel):
model_config = ConfigDict(group_by="dne")
gnd: str
surname: Annotated[str, SPARQLBinding("nameLabel")]
works: list[Work]
education: Annotated[list[str], SPARQLBinding("educated_atLabel")] also crashes and lists the applicable (resolved) grouping keys: |
Or maybe there should be a |
Probably, model sanity checks should be centralized. The checks mentioned above run as part of Other model checks may need to run in other places though and generally a single model sanity checking pipeline with pluggable/extensible model checks would be preferable. |
Quick sketch for a model checker: def check_model(model: BaseModel) -> BaseModel:
model_group_by_value: str | None = model.model_config.get("group_by")
model_has_list_field: bool = any(
_is_list_type(value.annotation) for value in model.model_fields.values()
)
match model_group_by_value, model_has_list_field:
case None, True:
raise MissingModelConfigException(
f"Model '{model.__name__}' does not specify 'group_by' in its model_config."
)
case str(), False:
raise MissingGroupingTargetException(
f"Model '{model.__name__}' does not specify a grouping target (i.e. a list-annotated field)."
)
case str(), True:
if model_group_by_value not in model.model_fields.keys():
applicable_keys = [
k
for k, v in model.model_fields.items()
if not _is_list_type(v.annotation)
]
raise UnboundGroupingKeyException(
f"Requested grouping key '{model_group_by_value}' does not denote a model field.\n"
f"Applicable grouping keys: {', '.join(applicable_keys)}."
)
return model Obviously, the exception messages need to be much more informative. |
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
Some model sanity checking was implemented in the old ModelBindingsMapper, all checking should be done in a dedicated model sanity checking pipeline, see issue #108. So these tests - for now - are xfails.
As indicated in the docstring for ModelBindingsMapper, the class is somewhat coupled to SPARQLModelAdapter, because ModelBindinsMapper does not run model sanity by itself - sanity checking should happen in SPARQLModelAdapter, i.e. as early as possible. See issue #108. Once sanity checking is implemented, RDFProxy will make a public ModelBindingsMapper class available which will run model sanity checking itself.
rdfproxy.ModelBindingsMapper
should run general sanity checks on models.E.g. an error should be raised / a warning should be emitted if
a model defines
group_by
but doesn't specify alist
field (see #95)a model specifies a
list
field but doesn't define an applicablegroup_by
configa model does not define fields for all SPARQL bindings - this must not be an error condition, but a warning/info signal could be useful.
The text was updated successfully, but these errors were encountered: