SHACL¶
kurra.shacl
¶
SHACL functions.
validate(data: Path | Graph | list[Path] | list[Graph], shacl: Graph | Path | str | int, hide_warnings: bool = False) -> tuple[bool, Graph, str]
¶
Validates a data graph using a shapes graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Path | Graph | list[Path] | list[Graph]
|
The path to an RDF data file, a graph, a list of Paths or a list of Graphs to validate. List items will be merged |
required |
shacl
|
Graph | Path | str | int
|
The sHACL shapes to validate with |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, Graph, str]
|
Tuple[bool, Graph, str]: The validation status, results graph and message, all from pySHACL |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the ID of the SHACL validator is invalid |
RuntimeError
|
If the IRI of the SHACL validator cannot be resolved locally or against the Semantic Background's validators |
Source code in kurra/shacl.py
list_local_validators() -> dict[str, dict[str, int]] | None
¶
Lists SHACL validators - IRI & name - stored in the local system's calidator cache.
This function does not connect over the Internet.
Source code in kurra/shacl.py
sync_validators(http_client: httpx.Client | None = None)
¶
Checks the Semantic Background's read-only SPARQL Endpoint, currently https://fuseki.dev.kurrawong.ai/semback/sparql, for validators.
It then checks local storage, using list_local_calidators(), to see which, if any, of those validators are stored locally.
For any missing, it pulls down and stores a copy locally.
Source code in kurra/shacl.py
check_validator_known(validator_iri: str) -> bool
¶
Checks first locally and then in the Semantic Background to if a validator, identified by IRI, is known
Source code in kurra/shacl.py
infer(data: Graph | Path | str, rules: Graph | Path | str, include_base: bool = False) -> Graph
¶
Applies rules to the data graph and returns a graph of calculated results
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Graph | Path | str
|
the data to apply the rules to |
required |
rules
|
Graph | Path | str
|
the rules to apply, in SHACL Rules SPARQL syntax |
required |
include_base
|
bool
|
whether to include the data triples in output |
False
|
Returns: