buildingmotif.dataclasses.validation#
Functions
|
Combine GraphDiff by focus node to generate a list of templates that reconcile what is "wrong" with the Graph with respect to the GraphDiffs. |
Classes
|
Represents a graph that is missing an expected number of instances of the given class. |
|
An abstraction of a SHACL Validation Result that can produce a template that resolves the difference between the expected and actual graph. |
|
Represents an entity that is missing one of several possible shapes, via sh:or |
|
Represents an entity missing paths to objects of a given type: $this <path> <object> . |
|
Represents an entity missing paths to objects that match a given shape. |
|
Represents an entity that should be an instance of the class. |
|
Represents an entity missing a required property. |
|
Holds the necessary information for processing the results of SHACL validation. |
- class GraphDiff(focus: Optional[URIRef], validation_result: Graph, graph: Graph)[source]#
An abstraction of a SHACL Validation Result that can produce a template that resolves the difference between the expected and actual graph.
Each GraphDiff has a ‘focus’ that is the node in the model that the GraphDiff is about. If ‘focus’ is None, then the GraphDiff is about the model itself rather than a specific node
- focus: Optional[URIRef]#
- validation_result: Graph#
- graph: Graph#
- resolve(lib: Library) List[Template] [source]#
Produces a list of templates to resolve this GraphDiff.
- property failed_shape: Optional[URIRef]#
The URI of the Shape that failed
- property failed_component: Optional[URIRef]#
The Constraint Component of the Shape that failed
- format_count_error(max_count, min_count, path, object_type: Optional[str] = None) str [source]#
Format a count error message for a given object type and path.
- Parameters:
max_count (int) – the maximum number of objects expected
min_count (int) – the minimum number of objects expected
object_type (str) – the type of object expected
path (str) – the path to the object
- Returns:
the formatted error message
- Return type:
str
- class OrShape(focus: Optional[URIRef], validation_result: Graph, graph: Graph, shapes: Tuple[URIRef])[source]#
Represents an entity that is missing one of several possible shapes, via sh:or
- shapes: Tuple[URIRef]#
- class PathClassCount(focus: Optional[URIRef], validation_result: Graph, graph: Graph, path: URIRef, minc: Optional[int], maxc: Optional[int], classname: URIRef)[source]#
Represents an entity missing paths to objects of a given type: $this <path> <object> . <object> a <classname> .
- path: URIRef#
- minc: Optional[int]#
- maxc: Optional[int]#
- classname: URIRef#
- classmethod from_validation_report(report: Graph) List[PathClassCount] [source]#
Construct PathClassCount objects from a SHACL validation report.
- Parameters:
report (Graph) – the SHACL validation report
- Returns:
a list of PathClassCount objects
- Return type:
List[PathClassCount]
- class PathShapeCount(focus: Optional[URIRef], validation_result: Graph, graph: Graph, path: URIRef, minc: Optional[int], maxc: Optional[int], shapename: URIRef, extra_body: Optional[Graph], extra_deps: Optional[Tuple])[source]#
Represents an entity missing paths to objects that match a given shape. $this <path> <object> . <object> a <shapename> .
- path: URIRef#
- minc: Optional[int]#
- maxc: Optional[int]#
- shapename: URIRef#
- extra_body: Optional[Graph]#
- extra_deps: Optional[Tuple]#
- classmethod from_validation_report(report: Graph) Generator[PathShapeCount, None, None] [source]#
Construct PathShapeCount objects from a SHACL validation report.
- Parameters:
report (Graph) – the SHACL validation report
- Returns:
a list of PathShapeCount objects
- Return type:
List[PathShapeCount]
- class RequiredPath(focus: Optional[URIRef], validation_result: Graph, graph: Graph, path: URIRef, minc: Optional[int], maxc: Optional[int])[source]#
Represents an entity missing a required property.
- path: URIRef#
- minc: Optional[int]#
- maxc: Optional[int]#
- classmethod from_validation_report(report: Graph) List[RequiredPath] [source]#
Construct RequiredPath objects from a SHACL validation report.
- Parameters:
report (Graph) – the SHACL validation report
- Returns:
a list of RequiredPath objects
- Return type:
List[RequiredPath]
- class RequiredClass(focus: Optional[URIRef], validation_result: Graph, graph: Graph, classname: URIRef)[source]#
Represents an entity that should be an instance of the class.
- classname: URIRef#
- class GraphClassCardinality(focus: Optional[URIRef], validation_result: Graph, graph: Graph, classname: URIRef, expectedCount: int)[source]#
Represents a graph that is missing an expected number of instances of the given class.
- classname: URIRef#
- expectedCount: int#
- class ValidationContext(shape_collections: List[ShapeCollection], shapes_graph: Graph, valid: bool, report: Graph, report_string: str, model: Model)[source]#
Holds the necessary information for processing the results of SHACL validation.
- shape_collections: List[ShapeCollection]#
- shapes_graph: Graph#
- valid: bool#
- report: Graph#
- report_string: str#
- property diffset: Dict[Optional[URIRef], Set[GraphDiff]]#
The unordered set of GraphDiffs produced from interpreting the input SHACL validation report.
- as_templates() List[Template] [source]#
Produces the set of templates that reconcile the GraphDiffs from the SHACL validation report.
- Returns:
reconciling templates
- Return type:
List[Template]
- get_broken_entities() Set[URIRef] [source]#
Get the set of entities that are broken in the model.
- Returns:
set of entities that are broken
- Return type:
Set[URIRef]
- get_diffs_for_entity(entity: URIRef) Set[GraphDiff] [source]#
Get the set of diffs for a specific entity.
- Parameters:
entity (URIRef) – the entity to get diffs for
- Returns:
set of diffs for the entity
- Return type:
Set[GraphDiff]
- get_reasons_with_severity(severity: Union[URIRef, str]) Dict[Optional[URIRef], Set[GraphDiff]] [source]#
Like diffset, but only includes ValidationResults with the given severity. Permitted values are: - SH.Violation or “Violation” for violations - SH.Warning or “Warning” for warnings - SH.Info or “Info” for info
- Parameters:
severity (Union[URIRef|str]) – the severity to filter by
- Returns:
a dictionary of focus nodes to the reasons with the given severity
- Return type:
Dict[Optional[URIRef], Set[GraphDiff]]