cmem_client.repositories.validations¤
Repository for the SHACL validation batches of Corporate Memory.
Provides ValidationsRepository for starting a validation of a context graph against a shape graph, for polling the batches which are running or finished, and for reading their aggregated or detailed results.
Examples:
Start a validation and read its result:
>>> from cmem_client.client import Client
>>> client = Client.from_env()
>>> batch_id = client.validations.start(
... context_graph="https://ns.eccenca.com/data/config/"
... )
>>> client.validations.get_aggregation(batch_id)
>>> client.validations.get_result(batch_id)
List the known batches and cancel a running one:
>>> client.validations.fetch_data()
>>> list(client.validations)
>>> client.validations.cancel(batch_id)
Classes:
- ValidationsRepository – Repository for managing SHACL batch validation processes.
ValidationsRepository¤
Bases: PlainListRepository[ValidationAggregation]
Repository for managing SHACL batch validation processes.
The dict is keyed by batch ID and insertion order reflects execution start time. Not auto-fetched on init — call fetch_data() explicitly to populate. Use get_aggregation() to refresh the state of a single validation process, e.g. when polling a running process.
Functions:
- cancel – Cancel a running validation process.
- fetch_data – Fetch simple list from a JSON endpoint via a type adapter
- get_aggregation – Fetch the aggregation summary of a single validation process fresh from the server.
- get_result – Get the full result of a validation process including all violations.
- items – Get the items of the repository
- keys – Get the keys of the repository
- start – Start a new batch validation process.
- values – Get the values of the repository
Attributes:
- logger (
Logger) – Gets the client logger
cancel¤
Cancel a running validation process.
Parameters:
- batch_id (
str) – The batch validation process identifier.
fetch_data¤
Fetch simple list from a JSON endpoint via a type adapter
Use this method to fetch data when your result set is an array of objects.
get_aggregation¤
Fetch the aggregation summary of a single validation process fresh from the server.
Parameters:
- batch_id (
str) – The batch validation process identifier.
Returns:
ValidationAggregation– The aggregation summary for the given process.
Raises:
RepositoryReadError– if an error occurs while fetching the aggregation.
get_result¤
Get the full result of a validation process including all violations.
Parameters:
- batch_id (
str) – The batch validation process identifier.
Returns:
ValidationResult– The full validation result with all resource results and violations.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
start¤
start(context_graph, shape_graph=None, query=None, result_graph=None, replace=False, ignore_graph=None)
Start a new batch validation process.
Parameters:
- context_graph (
str) – IRI of the data graph to validate. - shape_graph (
str | None) – IRI of the shape catalog graph. - query (
str | None) – SPARQL query to select resources for validation. - result_graph (
str | None) – IRI of a graph to write validation results to. - replace (
bool) – Whether to replace the result graph instead of appending. - ignore_graph (
list[str] | None) – Graph IRIs excluded from resource selection.
Returns:
str– The batch ID of the newly created validation process.
values¤
Get the values of the repository