RDFLib / pySHACL

A Python validator for SHACL
Apache License 2.0
241 stars 63 forks source link

Errors when asking for table output in CLI #145

Open RiX012 opened 2 years ago

RiX012 commented 2 years ago

All goes well until i ask for table output. Error message:

PS C:\GitHub\imbor> pyshacl -s "C:\GitHub\imbor\docs\uitwisseling_rdf\files\temp\shapes.ttl" -i rdfs -a -f table "C:\GitHub\imbor\docs\uitwisseling_rdf\files\temp\data.ttl"
+----------+
| Conforms |
+----------+
|  False   |
+----------+

Traceback (most recent call last):
  File "C:\Users\100288\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\100288\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\100288\AppData\Local\Programs\Python\Python310\Scripts\pyshacl.exe\__main__.py", line 7, in <module>
  File "C:\Users\100288\AppData\Local\Programs\Python\Python310\lib\site-packages\pyshacl\cli.py", line 285, in main
    r[SH.resultMessage],
KeyError: rdflib.term.URIRef('http://www.w3.org/ns/shacl#resultMessage')

I am not a coder, just trying to use the validator. What is wrong here?

ashleysommer commented 2 years ago

Hi @RiX012 Thanks for the report. The Table output is a relatively new feature in PySHACL, and it hasn't had much real-world testing. I can see where the problem lies, the table generator expects the SHACL constraint to define a sh:message, and it wants to print the message in the table. But in your case, where the shape's constraint does not have a message, the table generator fails. I can put a fix in the next release to address it.

Just out of curiosity, are you able to show the contents of your shapes.ttl file that you're using here? Most SHACL constraints have a default message built in, so I'd like to see which constraints you are using to see if I can add in another default message somewhere.

ashleysommer commented 2 years ago

@RiX012 This is now fixed in new release v0.19.1

RiX012 commented 2 years ago

Just out of curiosity, are you able to show the contents of your shapes.ttl file that you're using here? Most SHACL constraints have a default message built in, so I'd like to see which constraints you are using to see if I can add in another default message somewhere.

Thanks for fixing so fast. Works perfect now! No problem sharing:

@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix sh:    <http://www.w3.org/ns/shacl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix def:   <http://example.org/def/> .
@prefix nen2660: <https://w3id.org/nen2660/def#> .

def: a owl:Ontology .

nen2660:hasPart
  a owl:ObjectProperty ;
.

nen2660:RealObject
  a sh:NodeShape, owl:Class ;
  sh:property [
      sh:path nen2660:hasPart ;
      sh:class nen2660:RealObject 
    ] ;
.

def:Car
        rdf:type            sh:NodeShape , owl:Class ;
        rdfs:subClassOf     nen2660:RealObject ;
        sh:property  [ sh:path  nen2660:hasPart ;
                        sh:qualifiedMinCount 1 ;
                        sh:qualifiedMaxCount 1 ;
                        sh:qualifiedValueShape [ sh:class def:Wheel ] ;
                        ] ;
.

def:Wheel
        rdf:type            sh:NodeShape , owl:Class .

def:Door
        rdf:type            sh:NodeShape , owl:Class .