Skip to content

Commit

Permalink
fix use of shacl path
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Dec 3, 2024
1 parent 2b44be7 commit c1f88dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 3 additions & 2 deletions buildingmotif/dataclasses/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import rdflib
from pyshacl.helper.path_helper import shacl_path_to_sparql_path
from pyshacl.shapes_graph import ShapesGraph
from rdflib import Graph, URIRef
from rdflib.collection import Collection
from rdflib.term import BNode, Node
Expand Down Expand Up @@ -224,7 +225,7 @@ def reason(self) -> str:
"""Human-readable explanation of this GraphDiff."""
# interpret a SHACL property path as a sparql property path
path = shacl_path_to_sparql_path(
self.graph, self.path, prefixes=dict(self.graph.namespaces())
ShapesGraph(self.graph), self.path, prefixes=dict(self.graph.namespaces())
)

classname = self.graph.qname(self.classname)
Expand Down Expand Up @@ -402,7 +403,7 @@ def from_validation_report(cls, report: Graph) -> List["RequiredPath"]:
def reason(self) -> str:
"""Human-readable explanation of this GraphDiff."""
path = shacl_path_to_sparql_path(
self.graph, self.path, prefixes=dict(self.graph.namespaces())
ShapesGraph(self.graph), self.path, prefixes=dict(self.graph.namespaces())
)
return self.format_count_error(self.maxc, self.minc, path)

Expand Down
16 changes: 10 additions & 6 deletions buildingmotif/ingresses/naming_convention.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ def __init__(
self.naming_convention = naming_convention

def dump_failed_labels(self):
sorted_groups = sorted(
analyze_failures(self.failures).items(),
key=lambda x: len(x[1]),
reverse=True,
)
for group, failures in sorted_groups:
for group, failures in self.sorted_failures:
print(f"Unparsed label: {group} ({len(failures)} failures)")
for failure in failures:
print(f"\t{failure}")
print()

@property
def sorted_failures(self) -> list:
return sorted(
analyze_failures(self.failures).items(),
key=lambda x: len(x[1]),
reverse=True,
)


@cached_property
def records(self) -> List[Record]:
results, failures = parse_list(
Expand Down
5 changes: 0 additions & 5 deletions buildingmotif/ingresses/semantic_graph_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ def graph(self, ns: Namespace) -> Graph:
graph = ev.body
else:
graph = ev
# remove all triples where either the subject or object is in the PARAM namespace
for s, p, o in graph:
if str(s).startswith(str(ns.PARAM)) or str(o).startswith(str(ns.PARAM)):
logger.info(f"Removing triple {s} {p} {o}")
graph.remove((s, p, o))
logger.info(f"Adding graph with {len(graph)} triples to output")
g += graph
return g

0 comments on commit c1f88dd

Please sign in to comment.