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

Add additional ontology imports #501

Merged
merged 29 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5ac2bcd
fix/compare_versions_tool
filippiscada Jan 20, 2023
bf72428
Merge branch 'master' of github.com:filiphl/Brick into filiphl-master
gtfierro Feb 6, 2023
ea41792
Merge branch 'filiphl-master'
gtfierro Feb 6, 2023
4887a63
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Feb 6, 2023
c3f97a0
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Feb 13, 2023
702642f
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Mar 1, 2023
09e983e
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Mar 25, 2023
68ef2c1
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Mar 26, 2023
11f6fa7
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Apr 7, 2023
cbd88a9
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Apr 24, 2023
8337812
Merge branch 'master' of github.com:BrickSchema/Brick
gtfierro Apr 26, 2023
80b2a62
add ref schema and REC imports
gtfierro Apr 26, 2023
5bfe6de
add brickpatches
gtfierro Apr 28, 2023
ceabc1b
fixing up location haspart constraints
gtfierro Apr 28, 2023
8e71ca6
Merge remote-tracking branch 'origin/master' into add-ref-schema-rec-…
gtfierro Aug 1, 2023
41e4a68
updating REC
gtfierro Sep 27, 2023
bb59de8
Merge remote-tracking branch 'origin/master' into add-ref-schema-rec-…
gtfierro Dec 12, 2023
2d4982c
bump deps
gtfierro Dec 14, 2023
09cc7c2
Merge remote-tracking branch 'origin/master' into add-ref-schema-rec-…
gtfierro Dec 14, 2023
105d79f
working on rec/brick
gtfierro Dec 30, 2023
78b81b3
Merge remote-tracking branch 'origin/master' into add-ref-schema-rec-…
gtfierro Jan 11, 2024
2647a73
Merge branch 'master' of github.com:BrickSchema/Brick into add-ref-sc…
gtfierro Jan 11, 2024
a0b9f71
fixing prefixes and rules
gtfierro Jan 14, 2024
29f9edf
bump ontoenv
gtfierro Jan 14, 2024
8fb39e1
initialie quantities
gtfierro Jan 14, 2024
97810df
Merging quantities
gtfierro Jan 14, 2024
5ed21ff
fixing use of ontoenv
gtfierro Jan 14, 2024
154ce3b
fix ontoenv usage for tests
gtfierro Jan 14, 2024
16a44e1
more rec changes
gtfierro Jan 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bricksrc/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,10 @@
},
"constraints": {
BRICK.hasPart: [
BRICK.Room,
BRICK.Space,
BRICK.Wing,
BRICK.Outdoor_Area,
BRICK.Floor,
],
},
},
Expand Down
2 changes: 2 additions & 0 deletions bricksrc/namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
SOSA = Namespace("http://www.w3.org/ns/sosa/")
VCARD = Namespace("http://www.w3.org/2006/vcard/ns#")
S223 = Namespace("http://data.ashrae.org/standard223#")
REC = Namespace("https://w3id.org/rec#")

# QUDT namespaces
QUDT = Namespace("http://qudt.org/schema/qudt/")
Expand Down Expand Up @@ -52,3 +53,4 @@ def bind_prefixes(g):
g.bind("bacnet", BACNET)
g.bind("ifc", IFC)
g.bind("s223", S223)
g.bind("rec", REC)
11 changes: 9 additions & 2 deletions bricksrc/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rdflib import Literal, BNode, URIRef
from rdflib.collection import Collection

from .namespaces import DCTERMS, SDO, RDFS, RDF, OWL, BRICK, SH, XSD, REF
from .namespaces import DCTERMS, SDO, RDFS, RDF, OWL, BRICK, SH, XSD, REF, REC
from .version import BRICK_VERSION, BRICK_FULL_VERSION

# defines metadata about the Brick ontology
Expand Down Expand Up @@ -38,11 +38,14 @@
"qudtoverlay": "http://qudt.org/2.1/schema/shacl/overlay/qudt",
"unit": "http://qudt.org/2.1/vocab/unit",
"bacnet": "http://data.ashrae.org/bacnet/2020",
"ref": "https://brickschema.org/schema/Brick/ref",
"rec": "https://w3id.org/rec",
"recimports": "https://w3id.org/rec/recimports",
"brickpatches": "https://w3id.org/rec/brickpatches",
"quantitykind": "http://qudt.org/2.1/vocab/quantitykind",
"qudtsou": "http://qudt.org/2.1/vocab/sou",
"qudtdv": "http://qudt.org/2.1/vocab/dimensionvector",
"qudtprefix": "http://qudt.org/2.1/vocab/prefix",
"ref": "https://brickschema.org/schema/Brick/ref",
}

shacl_namespace_declarations = [
Expand Down Expand Up @@ -76,6 +79,10 @@
SH.namespace: Literal(str(REF), datatype=XSD.anyURI),
SH.prefix: Literal("ref"),
},
{
SH.namespace: Literal("https://w3id.org/rec#", datatype=XSD.anyURI),
SH.prefix: Literal("rec"),
},
]

BRICK_IRI_VERSION = URIRef(f"https://brickschema.org/schema/{BRICK_VERSION}/Brick")
Expand Down
7 changes: 5 additions & 2 deletions bricksrc/quantities.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from brickschema.graph import Graph
from ontoenv import OntoEnv
from rdflib import Literal, URIRef
from .namespaces import SKOS, OWL, RDFS, BRICK, QUDTQK, QUDTDV, QUDT, UNIT


env = OntoEnv(initialize=True, search_dirs=["support/"])
g = Graph()
g.load_file("support/VOCAB_QUDT-QUANTITY-KINDS-ALL-v2.1.ttl")
g.load_file("support/VOCAB_QUDT-UNITS-ALL-v2.1.ttl")
g.bind("qudt", QUDT)
g.bind("qudtqk", QUDTQK)
g.expand(profile="shacl", backend="topquadrant")

env.import_dependencies(g)
g.expand("shacl", backend="topquadrant")


def get_units(qudt_quantity):
Expand Down
28 changes: 28 additions & 0 deletions bricksrc/rules.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,34 @@ bsh:hasSubstance a sh:NodeShape ;
.


# rule to add rec:includes when a brick:Collection contains a brick:Equipment
bsh:CollectionIncludesEquipment a sh:NodeShape ;
sh:targetClass brick:Collection, brick:System, brick:Equipment ;
sh:rule [
a sh:SPARQLRule ;
sh:construct """
CONSTRUCT {
$this rec:includes ?eq .
}
WHERE {
$this brick:hasPart ?eq .
{
?eq rdf:type/rdfs:subClassOf* brick:Equipment .
}
UNION
{
?eq rdf:type/rdfs:subClassOf* brick:Collection .
}
UNION
{
?eq rdf:type/rdfs:subClassOf* brick:System .
}
}
""" ;
sh:prefixes <https://brickschema.org/schema/1.3/Brick> ;
] ;
.

# add unidirectional charging to all EVsE chargers as a default value
# UNLESS there is already a brick:electricVehicleChargerDirectionality attribute
# on ports associated with the charger
Expand Down
10 changes: 6 additions & 4 deletions examples/last_known_value/last_known_value.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix bacnet: <http://data.ashrae.org/bacnet/2020#> .
@prefix rec: <https://w3id.org/rec#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

bldg: a owl:Ontology ;
Expand All @@ -20,8 +21,9 @@ bldg:sensor1 a brick:Air_Temperature_Sensor ;
bacnet:object-name "BLDG-Z410-ZATS" ;
bacnet:objectOf bldg:sample-device ;
] ;
brick:lastKnownValue [
brick:value "72.0"^^xsd:float ;
brick:lastKnownValue bldg:sensor1_reading1 .

bldg:sensor1_reading1 a rec:TemperatureObservation ;
brick:value "72.0"^^xsd:double ;
brick:timestamp "2020-01-01T00:00:00Z"^^xsd:dateTime ;
] ;
.
rec:sourcePoint bldg:sensor1 .
4 changes: 4 additions & 0 deletions examples/solar_array/solar_array.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

<urn:example> a owl:Ontology ;
owl:imports <https://brickschema.org/schema/1.3/Brick> .

# shared efficiency rating
site:panel_efficiency a brick:EfficiencyShape ;
Expand Down
8 changes: 7 additions & 1 deletion generate_brick.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def handle_deprecations():

# create new directory for storing imports
os.makedirs("imports", exist_ok=True)
env = ontoenv.OntoEnv(initialize=True)
env = ontoenv.OntoEnv(initialize=True, search_dirs=["support/"])
for name, uri in ontology_imports.items():
depg, loc = env.resolve_uri(str(uri))
depg.serialize(Path("imports") / f"{name}.ttl", format="ttl")
Expand All @@ -1100,3 +1100,9 @@ def handle_deprecations():
if not valid:
print(report)
sys.exit(1)

# validate Brick
# valid, _, report = pyshacl.validate(data_graph=G, advanced=True, allow_warnings=True)
# if not valid:
# print(report)
# sys.exit(1)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ flake8>=6.0
semver>=2.10.1
pytest-xdist[psutil]
html5lib
ontoenv>=0.3.9a1
ontoenv>=0.4.0a6
2 changes: 1 addition & 1 deletion support/SCHEMA_QUDT_NoOWL-v2.1.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ qudt:QuantityType-value
qudt:QuantityValue
a rdfs:Class ;
a sh:NodeShape ;
rdfs:comment "A <i>Quantity Value</i> expresses the magnitude and kind of a quantity and is given by the product of a numerical value <code>n</code> and a unit of measure <code>U</code>. The number multiplying the unit is referred to as the numerical value of the quantity expressed in that unit. Refer to <a href=\"http://physics.nist.gov/Pubs/SP811/sec07.html\">NIST SP 811 section 7</a> for more on quantity values."^^rdf:HTML ;
rdfs:comment ""^^rdf:HTML ;
rdfs:isDefinedBy <http://qudt.org/2.1/schema/shacl/qudt> ;
rdfs:label "Quantity value" ;
rdfs:subClassOf qudt:Concept ;
Expand Down
Loading