Skip to content

Commit a0a2c35

Browse files
committed
use sh:node to compose, add dependent libraries for validation
1 parent 050f30a commit a0a2c35

File tree

7 files changed

+42
-98
lines changed

7 files changed

+42
-98
lines changed

libraries/ashrae/guideline36/4.2-vav-with-reheat.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
:vav-with-reheat a sh:NodeShape, owl:Class, bmotif:System_Specification ;
1111
sh:class brick:RVAV ;
12-
rdfs:subClassOf vav41:vav-cooling-only ;
12+
sh:node vav41:vav-cooling-only ;
1313
sh:or ( :heating-signal1 :heating-signal2 ) ;
1414
bmotif:domain bmotif:HVAC ;
1515
.

libraries/ashrae/guideline36/4.5-dual-duct-terminal-unit-with-discharge.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
sh:qualifiedMinCount 1 ;
4242
sh:qualifiedMaxCount 1 ;
4343
] ;
44-
rdfs:subClassOf vav41:zone-temperature, vav41:zone-co2-level, vav41:occupancy-sensor ;
44+
sh:node vav41:zone-temperature, vav41:zone-co2-level, vav41:occupancy-sensor ;
4545
.
4646

4747
:hot-deck a sh:NodeShape, owl:Class ;
4848
sh:class brick:Hot_Deck ;
49-
rdfs:subClassOf components:heating_damper ;
49+
sh:node components:heating_damper ;
5050
.
5151

5252
:cold-deck a sh:NodeShape, owl:Class ;
5353
sh:class brick:Cold_Deck ;
54-
rdfs:subClassOf components:cooling_damper ;
54+
sh:node components:cooling_damper ;
5555
.

libraries/ashrae/guideline36/4.6-multiple-zone-vav-AHU.ttl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,31 @@
3737
] ;
3838
sh:property [
3939
sh:path brick:hasPoint ;
40-
sh:qualifiedValueShape [ sh:node vav48:oa-temp ] ;
40+
sh:qualifiedValueShape [ sh:class brick:Outside_Air_Temperature_Sensor ] ;
4141
sh:qualifiedMinCount 1 ;
4242
sh:qualifiedMaxCount 1 ;
4343
] ;
4444
sh:property [
4545
sh:path brick:hasPoint ;
46-
sh:qualifiedValueShape [ sh:node vav48:ma-temp ] ;
46+
sh:qualifiedValueShape [ sh:class brick:Mixed_Air_Temperature_Sensor ] ;
4747
sh:qualifiedMinCount 1 ;
4848
sh:qualifiedMaxCount 1 ;
4949
] ;
5050
sh:property [
5151
sh:path brick:hasPoint ;
52-
sh:qualifiedValueShape [ sh:node vav48:ra-temp ] ;
52+
sh:qualifiedValueShape [ sh:class brick:Return_Air_Temperature_Sensor] ;
5353
sh:qualifiedMinCount 1 ;
5454
sh:qualifiedMaxCount 1 ;
5555
] ;
5656
sh:property [
5757
sh:path brick:hasPoint ;
58-
sh:qualifiedValueShape [ sh:node vav48:sa-temp ] ;
58+
sh:qualifiedValueShape [ sh:class brick:Supply_Air_Temperature_Sensor] ;
5959
sh:qualifiedMinCount 1 ;
6060
sh:qualifiedMaxCount 1 ;
6161
] ;
6262
sh:property [
6363
sh:path brick:hasPoint ;
64-
sh:qualifiedValueShape [ sh:node vav48:filter-pd ] ;
64+
sh:qualifiedValueShape [sh:class brick:Filter_Differential_Pressure_Sensor] ;
6565
sh:qualifiedMinCount 1 ;
6666
sh:qualifiedMaxCount 1 ;
6767
] ;

libraries/ashrae/guideline36/4.8-sz-vav-ahu.ttl

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -92,68 +92,6 @@
9292
] ;
9393
.
9494

95-
:sa-temp a sh:NodeShape, owl:Class ;
96-
sh:class brick:Supply_Air_Temperature_Sensor ;
97-
sh:property [
98-
sh:minCount 1;
99-
sh:maxCount 1;
100-
sh:path brick:hasUnit ;
101-
] ;
102-
.
103-
104-
:oa-temp a sh:NodeShape, owl:Class ;
105-
sh:class brick:Outside_Air_Temperature_Sensor ;
106-
sh:property [
107-
sh:minCount 1;
108-
sh:maxCount 1;
109-
sh:path brick:hasUnit ;
110-
] ;
111-
.
112-
113-
:ma-temp a sh:NodeShape, owl:Class ;
114-
sh:class brick:Mixed_Air_Temperature_Sensor ;
115-
sh:property [
116-
sh:minCount 1;
117-
sh:maxCount 1;
118-
sh:path brick:hasUnit ;
119-
] ;
120-
.
121-
122-
:ra-temp a sh:NodeShape, owl:Class ;
123-
sh:class brick:Return_Air_Temperature_Sensor ;
124-
sh:property [
125-
sh:minCount 1;
126-
sh:maxCount 1;
127-
sh:path brick:hasUnit ;
128-
] ;
129-
.
130-
131-
:filter-pd a sh:NodeShape, owl:Class ;
132-
sh:class brick:Filter_Differential_Pressure_Sensor ;
133-
sh:property [
134-
sh:minCount 1;
135-
sh:maxCount 1;
136-
sh:path brick:hasUnit ;
137-
] ;
138-
.
139-
140-
:clg-signal a sh:NodeShape, owl:Class ;
141-
sh:class brick:Cooling_Command ;
142-
sh:property [
143-
sh:minCount 1;
144-
sh:maxCount 1;
145-
sh:path brick:hasUnit ;
146-
] ;
147-
.
148-
149-
:htg-signal a sh:NodeShape, owl:Class ;
150-
sh:class brick:Heating_Command ;
151-
sh:property [
152-
sh:minCount 1;
153-
sh:maxCount 1;
154-
sh:path brick:hasUnit ;
155-
] ;
156-
.
15795

15896
:zone-temperature a sh:NodeShape, owl:Class ;
15997
sh:class brick:Zone_Temperature_Sensor ;
@@ -164,23 +102,6 @@
164102
] ;
165103
.
166104

167-
:occupancy-sensor a sh:NodeShape, owl:Class ;
168-
sh:class brick:Occupancy_Sensor ;
169-
sh:property [
170-
sh:minCount 1;
171-
sh:maxCount 1;
172-
sh:path brick:hasUnit ;
173-
] ;
174-
.
175-
176-
:zone-co2-level a sh:NodeShape, owl:Class ;
177-
sh:class brick:CO2_Level_Sensor ;
178-
sh:property [
179-
sh:minCount 1;
180-
sh:maxCount 1;
181-
sh:path brick:hasUnit ;
182-
] ;
183-
.
184105

185106
:oa-ra-damper a sh:NodeShape, owl:Class ;
186107
sh:class brick:Damper ;

libraries/ashrae/guideline36/5.16.14-multiple-zone-vav-ahu-afdd.ttl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
:fc-3 a sh:NodeShape, owl:Class, bmotif:Analytics_Application ;
7272
rdfs:label "FC#3" ;
7373
rdfs:comment "MAT too high; should be between OAT and RAT" ;
74-
rdfs:subClassOf :fc-2 .
74+
sh:node :fc-2 .
7575

7676
:fc-4 a sh:NodeShape, owl:Class, bmotif:Analytics_Application ;
7777
bmotif:domain bmotif:HVAC ;
@@ -133,8 +133,7 @@
133133
sh:qualifiedMinCount 1 ;
134134
]
135135
) ;
136-
# use subclassof to compose shapes
137-
rdfs:subClassOf :percent-oa-minimum .
136+
sh:node :percent-oa-minimum .
138137

139138
:percent-oa-fraction a sh:NodeShape, owl:Class ;
140139
rdfs:label "%OA" ;

libraries/ashrae/guideline36/5.18.13-single-zone-vav-ahu-afdd.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
:fc-3 a sh:NodeShape, owl:Class, bmotif:Analytics_Application ;
4242
rdfs:label "FC#3" ;
4343
rdfs:comment "MAT too high; should be between OAT and RAT" ;
44-
rdfs:subClassOf :fc-2 .
44+
sh:node :fc-2 .
4545

4646
:fc-4 a sh:NodeShape, owl:Class, bmotif:Analytics_Application ;
4747
bmotif:domain bmotif:HVAC ;

tests/unit/api/test_model.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,15 @@ def test_validate_model_bad_args(client, building_motif):
441441
def test_validate_model_against_shapes(client, building_motif, shacl_engine):
442442
building_motif.shacl_engine = shacl_engine
443443
# Load libraries
444-
Library.load(ontology_graph=str(PROJECT_DIR / "libraries/brick/Brick.ttl"))
444+
brick = Library.load(ontology_graph=str(PROJECT_DIR / "libraries/brick/Brick.ttl"))
445+
unit = Library.load(
446+
ontology_graph=str(PROJECT_DIR / "libraries/qudt/VOCAB_QUDT-UNITS-ALL.ttl")
447+
)
448+
qk = Library.load(
449+
ontology_graph=str(
450+
PROJECT_DIR / "libraries/qudt/VOCAB_QUDT-QUANTITY-KINDS-ALL.ttl"
451+
)
452+
)
445453
ashrae_g36 = Library.load(
446454
directory=str(PROJECT_DIR / "libraries/ashrae/guideline36/")
447455
)
@@ -465,7 +473,12 @@ def test_validate_model_against_shapes(client, building_motif, shacl_engine):
465473
f"/models/{medium_office_model.id}/validate_shape",
466474
headers={"Content-Type": "application/json"},
467475
json={
468-
"shape_collection_ids": [ashrae_g36.get_shape_collection().id],
476+
"shape_collection_ids": [
477+
ashrae_g36.get_shape_collection().id,
478+
brick.get_shape_collection().id,
479+
unit.get_shape_collection().id,
480+
qk.get_shape_collection().id,
481+
],
469482
"shape_uris": [
470483
"urn:ashrae/g36/5.16.14/multiple-zone-vav-ahu-afdd/fc-3",
471484
"urn:ashrae/g36/5.16.14/multiple-zone-vav-ahu-afdd/fc-4",
@@ -557,7 +570,10 @@ def test_validate_endpoint_include_templates_returns_inlined_templates_with_para
557570
assert "templates" in data
558571
assert isinstance(data["templates"], list)
559572
assert len(data["templates"]) >= 1
560-
assert all(isinstance(t.get("template_id"), int) and t["template_id"] > 0 for t in data["templates"])
573+
assert all(
574+
isinstance(t.get("template_id"), int) and t["template_id"] > 0
575+
for t in data["templates"]
576+
)
561577
# Verify focus is included for each template and includes the VAV focus node
562578
for t in data["templates"]:
563579
assert "focus" in t
@@ -590,7 +606,9 @@ def test_validate_endpoint_include_templates_returns_inlined_templates_with_para
590606
assert "https://brickschema.org/schema/Brick#Air_Flow_Sensor" in all_types
591607

592608

593-
def test_validate_endpoint_include_templates_via_json_body(client, building_motif, shacl_engine):
609+
def test_validate_endpoint_include_templates_via_json_body(
610+
client, building_motif, shacl_engine
611+
):
594612
# Ensure SHACL engine configured
595613
building_motif.shacl_engine = shacl_engine
596614

@@ -608,15 +626,21 @@ def test_validate_endpoint_include_templates_via_json_body(client, building_moti
608626
res = client.post(
609627
f"/models/{model.id}/validate",
610628
headers={"Content-Type": "application/json"},
611-
json={"library_ids": [library_1.id, library_2.id, brick.id], "include_templates": True},
629+
json={
630+
"library_ids": [library_1.id, library_2.id, brick.id],
631+
"include_templates": True,
632+
},
612633
)
613634
assert res.status_code == 200, res.data
614635

615636
data = res.get_json()
616637
assert "templates" in data
617638
assert isinstance(data["templates"], list)
618639
assert len(data["templates"]) >= 1
619-
assert all(isinstance(t.get("template_id"), int) and t["template_id"] > 0 for t in data["templates"])
640+
assert all(
641+
isinstance(t.get("template_id"), int) and t["template_id"] > 0
642+
for t in data["templates"]
643+
)
620644
for t in data["templates"]:
621645
assert "template_id" in t
622646
assert isinstance(t["template_id"], int) and t["template_id"] > 0

0 commit comments

Comments
 (0)