gtfierro/brick-builder

Using shacl with brick-builder

Closed this issue · 3 comments

Hi @gtfierro, I add the shacl vaildater to the make.py so it can vaildate the model, the template like this:

...
wkgo:$5 brick:hasLocation wkgo:WKGO_S_BF
wkgo:$6 brick:hasLocation wkgo:WKGO_S_BF
wkgo:$4 brick:hasLocation wkgo:WKGO_S_RF

wkgo:WKGO_S_BF rdf:type brick:Basement
wkgo:WKGO_S_RF rdf:type brick:Rooftop
...

However the vaildater shows that there are invaild relationship:

Graph is valid? False
Validation Report
Conforms: False
Results (39):
Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
        Severity: sh:Violation
        Source Shape: [ sh:class brick:Location ; sh:message Literal("A piece of Equipment can be located only at a Location") ; sh:path brick:hasLocation ]
        Focus Node: wkgo:CHWP-CP-BF-05
        Value Node: wkgo:WKGO_S_BF
        Result Path: brick:hasLocation
        Message: A piece of Equipment can be located only at a Location

Both brick:Basement and brick:Rooftop are under the class brick:Floor, the validater only recognize the subclass of brick:Location but not the sub-subclass such as basement and rooftop, the workaround for now is add brick:Floor to
both basement tag and rooftop tag:

wkgo:WKGO_S_BF rdf:type brick:Floor
wkgo:WKGO_S_BF rdf:type brick:Basement
wkgo:WKGO_S_RF rdf:type brick:Floor
wkgo:WKGO_S_RF rdf:type brick:Rooftop

I want to ask is it possible to create a ruleset that cover all components under the class brick:Location?

This should be working... Make sure that you have a recent version of Brick loaded into the graph when you do the validation (you may need to upgrade brickschema package; make sure you have at least Python 3.7), and make sure you have at least pyshacl==0.16.1.post1 installed too

Thanks @gtfierro! since I load the correct Brick model and the error is gone. There are some warning message after I upgrade the rdflib but I think it's the owlrl problem.

(venv) PS C:\Users\chihungchung\Desktop\brick-converter\brick-builder-custom> python .\make.py template1.txt:WKGO_Brick_TLInstance.csv
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\__init__.py:177: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from . import DatatypeHandling, Closure
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: length is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: maxExclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: maxInclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: maxLength is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: minExclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: minInclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: minLength is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\RDFSClosure.py:40: UserWarning: Code: pattern is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\OWLRL.py:53: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from .XsdDatatypes import OWL_RL_Datatypes, OWL_Datatype_Subsumptions
C:\Users\chihungchung\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\owlrl\OWLRLExtras.py:64: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from .RestrictedDatatype import extract_faceted_datatypes
Graph is valid? True

Yes, this is a known issue in RDFlib. It's actually been fixed in their master branch, but it hasn't been packaged into a release yet. Shouldn't affect correctness!