Skip to content

cmem_client.models.validation¤

Validation models for SHACL batch validation processes.

A batch validation checks the resources of a context graph against the shapes of a shape graph and reports where they violate them. client.validations starts such a process and holds the running and finished ones, keyed by their batch ID. The aggregation is the summary a repository lists, while the result carries every single violation; note that client.validations does not fetch on creation, so call fetch_data() before iterating it.

Classes:

Attributes:

STATUS_CANCELLED¤

STATUS_CANCELLED = 'CANCELLED'

STATUS_ERROR¤

STATUS_ERROR = 'ERROR'

STATUS_FINISHED¤

STATUS_FINISHED = 'FINISHED'

STATUS_RUNNING¤

STATUS_RUNNING = 'RUNNING'

STATUS_SCHEDULED¤

STATUS_SCHEDULED = 'SCHEDULED'

ValidationAggregation¤

Bases: Model, ReadRepositoryItem

Summary view of a batch validation process.

Attributes:

  • id (str) – ID of the batch. This is the key of the repository.
  • state (str) – What the batch is doing, one of SCHEDULED, RUNNING, FINISHED, CANCELLED or ERROR.
  • context_graph_iri (str) – IRI of the graph whose resources are validated.
  • shape_graph_iri (str) – IRI of the graph holding the shapes.
  • execution_started (int | None) – When the validation started, as a Unix timestamp in milliseconds, or None while it is still scheduled.
  • execution_finished (int | None) – When it finished, or None while it is still running.
  • resource_count (int) – How many resources the batch covers.
  • resource_processed_count (int) – How many of them are done. Compare with resource_count to follow the progress of a running batch.
  • resources_with_violations_count (int) – How many resources violated at least one shape.
  • violations_count (int) – How many violations were found in total.
  • error (str | None) – Why the batch failed, set only in state ERROR.

Functions:

  • get_id – Get the batch validation process ID.

context_graph_iri¤

context_graph_iri: str = Field(alias='contextGraphIri')

error¤

error: str | None = Field(default=None)

execution_finished¤

execution_finished: int | None = Field(alias='executionFinished', default=None)

execution_started¤

execution_started: int | None = Field(alias='executionStarted', default=None)

get_id¤

get_id()

Get the batch validation process ID.

id¤

id: str

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

resource_count¤

resource_count: int = Field(alias='resourceCount', default=0)

resource_processed_count¤

resource_processed_count: int = Field(alias='resourceProcessedCount', default=0)

resources_with_violations_count¤

resources_with_violations_count: int = Field(alias='resourcesWithViolationsCount', default=0)

shape_graph_iri¤

shape_graph_iri: str = Field(alias='shapeGraphIri', default='')

state¤

state: str

violations_count¤

violations_count: int = Field(alias='violationsCount', default=0)

ValidationConstraintTemplate¤

Bases: Model

Constraint message template from a validation violation.

Attributes:

  • constraint_name (str) – Name of the SHACL constraint which was violated, e.g. MinCountConstraintComponent.

constraint_name¤

constraint_name: str = Field(alias='constraintName')

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

ValidationResourceResult¤

Bases: Model

Violations found for a single validated resource.

Attributes:

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

node_shapes¤

node_shapes: list[str] = Field(alias='nodeShapes', default_factory=list)

resource_iri¤

resource_iri: str = Field(alias='resourceIri')

violations¤

violations: list[ValidationViolation] = Field(default_factory=list)

ValidationResult¤

Bases: Model

Full result of a completed batch validation process.

Attributes:

  • id (str) – ID of the batch this result belongs to.
  • context_graph_iri (str) – IRI of the graph whose resources were validated.
  • shape_graph_iri (str) – IRI of the graph holding the shapes they were checked against.
  • execution_started (int | None) – When the validation started, as a Unix timestamp in milliseconds, or None while it is still scheduled.
  • execution_finished (int | None) – When it finished, as a Unix timestamp in milliseconds, or None while it is still running. The endpoint returns a result for a batch which has not finished yet, and leaves the field out then.
  • resources (list[str]) – IRIs of every validated resource, including those without a violation.
  • results (list[ValidationResourceResult]) – The per-resource violations. Resources which passed are not listed.

context_graph_iri¤

context_graph_iri: str = Field(alias='contextGraphIri')

execution_finished¤

execution_finished: int | None = Field(alias='executionFinished', default=None)

execution_started¤

execution_started: int | None = Field(alias='executionStarted', default=None)

id¤

id: str

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

resources¤

resources: list[str] = Field(default_factory=list)

results¤

results: list[ValidationResourceResult] = Field(default_factory=list)

shape_graph_iri¤

shape_graph_iri: str = Field(alias='shapeGraphIri')

ValidationViolation¤

Bases: Model

A single SHACL violation found during validation.

Attributes:

messages¤

messages: list[ValidationViolationMessage] = Field(default_factory=list)

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

path¤

path: str | None = None

report_entry_constraint_message_template¤

report_entry_constraint_message_template: ValidationConstraintTemplate = Field(alias='reportEntryConstraintMessageTemplate')

severity¤

severity: str | None = None

source¤

source: str | None = None

ValidationViolationMessage¤

Bases: Model

A single message attached to a validation violation.

Attributes:

  • value (str) – Text of the message.
  • lang (str) – Language tag of the message, empty if it carries none.

lang¤

lang: str = ''

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

value¤

value: str

Comments