Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Influence of meta_shacl #168

Closed
volkerjaenisch opened this issue Nov 19, 2022 · 2 comments
Closed

Influence of meta_shacl #168

volkerjaenisch opened this issue Nov 19, 2022 · 2 comments

Comments

@volkerjaenisch
Copy link

Dear RDFlib people!

I have a combination of SHACL shapes.
With "meta_shacl= True" they are processed but leaving a trace in the wake.

With "meta_shacl= False" I get only a stack trace.

Evidence below.

I do not understand this behavior. Can anyone please shed light. I would have expect the behavior reversed.

Cheers,
Volker

Setting meta_shacl= True :

/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/bin/python /home/volker/workspace/PYTHON5/SHACL_validation/shacl/validate.py 
Shacl File does not validate against the Shacl Shapes Shacl file.
Validation Report
Conforms: False
Results (21):
Constraint Violation in MaxCountConstraintComponent (http://www.w3.org/ns/shacl#MaxCountConstraintComponent):
	Severity: sh:Violation
	Source Shape: [ sh:maxCount Literal("0", datatype=xsd:integer) ; sh:path sh:path ]
	Focus Node: [ sh:hasValue <http://publications.europa.eu/resource/dataset/planned-availability> ; sh:path skos:inScheme ]
	Result Path: sh:path
	Message: More than 0 values on [ sh:hasValue <http://publications.europa.eu/resource/dataset/planned-availability> ; sh:path skos:inScheme ]->sh:path
Constraint Violation in MaxCountConstraintComponent (http://www.w3.org/ns/shacl#MaxCountConstraintComponent):
	Severity: sh:Violation
	Source Shape: [ sh:maxCount Literal("0", datatype=xsd:integer) ; sh:path sh:path ]
	Focus Node: [ sh:hasValue <http://dcat-ap.de/def/licenses> ; sh:path skos:inScheme ]
	Result Path: sh:path
	Message: More than 0 values on [ sh:hasValue <http://dcat-ap.de/def/licenses> ; sh:path skos:inScheme ]->sh:path
Constraint Violation in MaxCountConstraintComponent (http://www.w3.org/ns/shacl#MaxCountConstraintComponent):
	Severity: sh:Violation
	Source Shape: [ sh:maxCount Literal("0", datatype=xsd:integer) ; sh:path sh:path ]
	Focus Node: [ sh:hasValue <http://publications.europa.eu/resource/dataset/planned-availability> ; sh:path skos:inScheme ]
	Result Path: sh:path
	Message: More than 0 values on [ sh:hasValue <http://publications.europa.eu/resource/dataset/planned-availability> ; sh:path skos:inScheme ]->sh:path

then a trace.

Setting meta_shacl= False :

/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/bin/python /home/volker/workspace/PYTHON5/SHACL_validation/shacl/validate.py 
Traceback (most recent call last):
  File "/home/volker/workspace/PYTHON5/SHACL_validation/shacl/validate.py", line 31, in <module>
    conforms, report_graph, report_text = pyshacl.validate(
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/validate.py", line 435, in validate
    conforms, report_graph, report_text = validator.run()
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/validate.py", line 265, in run
    _is_conform, _reports = s.validate(
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/shape.py", line 511, in validate
    _is_conform, _reports = c.evaluate(target_graph, focus_value_nodes, _e_p)
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/constraints/core/shape_based_constraints.py", line 108, in evaluate
    _nc, _r = _evaluate_property_shape(p_shape)
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/constraints/core/shape_based_constraints.py", line 102, in _evaluate_property_shape
    _is_conform, _r = prop_shape.validate(target_graph, focus=v, _evaluation_path=_evaluation_path[:])
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/shape.py", line 511, in validate
    _is_conform, _reports = c.evaluate(target_graph, focus_value_nodes, _e_p)
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/constraints/core/shape_based_constraints.py", line 196, in evaluate
    _nc, _r = _evaluate_node_shape(n_shape)
  File "/home/volker/workspace/venvs/shacl-v-H5Zt4z-py3.9/lib/python3.9/site-packages/pyshacl/constraints/core/shape_based_constraints.py", line 182, in _evaluate_node_shape
    raise ReportableRuntimeError(
pyshacl.errors.ReportableRuntimeError: Shape pointed to by sh:node does not exist or is not a well-formed SHACL NodeShape.

Process finished with exit code 1
@ashleysommer
Copy link
Collaborator

ashleysommer commented Nov 22, 2022

Hi @volkerjaenisch
The answer to this question is simple.

The meta_shacl mode causes PySHACL to run a validation check on the SHACL Shapefile itself, before using the Shapefile to validate your DataGraph.

In this case, when you use meta_shacl=True, the preliminary check on the SHACL Shapefile fails, it finds your SHACL Shapefile to be invalid, and it does not proceed to validate your datagraph. (The error appears that one of your Shapes has a PropertyShape that has sh:path as the value of the sh:path predicate, that is invalid).

When you use meta_shacl=False, that preliminary check is skipped, the valdiator goes straight to validate your datagraph, and you get a shacl runtime error (that itself should be caught by the Meta-shacl check, but is not part of the tests, it is only possible to trigger this error at Datagraph Validation runtime.)

It might be possible to add the sh:node and sh:property value-shape existence checks to the Meta-SHACL preliminary test, but for now, it only validates your SHACL Shapefile against the SHACL-SHACL.ttl shapefile, no further checks than that.

@volkerjaenisch
Copy link
Author

Thanks for the useful information.

Have a look at.
GovDataOfficial/DCAT-AP.de-SHACL-Validation#19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants