Skip to content

Commit

Permalink
V1.4.0 Release Candidate 1 (#613)
Browse files Browse the repository at this point in the history
* Add REC namespace to deprecations module.

* aider: Create rec_location_deprecations dictionary in bricksrc/deprecations.py for deprecated location classes with corresponding mitigation messages and replacements.

# Aider chat conversation:

USER: Create a new dictionary in `bricksrc/deprecations.py` called rec_location_deprecations. For each deprecated concept in `support/brickpatches.ttl`, create a new entry with the corresponding keys 'mitigation_message', 'replace_with' and 'version'. 'version' should be '1.4.0'

ASSISTANT: ```diff
--- bricksrc/deprecations.py
+++ bricksrc/deprecations.py
@@ ... @@
 deprecations = {
     BRICK.Condenser: {
         "version": "1.3.0",
         "mitigation_message": "'Condenser' and 'Condensing Unit' are interchangable terms. Renaming class to 'Condensing_Unit' to further aligns with ASHRAE's terminology.",
         "replace_with": BRICK.Condensing_Unit,
     },
+    # ... (other existing deprecations) ...
+}
+
+rec_location_deprecations = {
+    BRICK.Ablutions_Room: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. There is not yet a replacement in REC for Ablutions_Room",
+        "replace_with": None,
+    },
+    BRICK.Atrium: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. For a replacement, consider rec:Atrium",
+        "replace_with": REC.Atrium,
+    },
+    # ... (other deprecated location classes with similar structure) ...
+}
```

Note: The above diff is a partial representation. The `rec_location_deprecations` dictionary should include entries for all deprecated location classes found in `support/brickpatches.ttl`, following the same pattern as shown in the example entries for `BRICK.Ablutions_Room` and `BRICK.Atrium`. Each entry should have a `version` key with the value `"1.4.0"`, a `mitigation_message` key with the deprecation message from the `.ttl` file, and a `replace_with` key with the corresponding REC class if available or `None` if there is no direct replacement.

* aider: Create rec_location_deprecations dictionary for all deprecated location classes with version 1.4.0.

# Aider chat conversation:

USER: Create a new dictionary in `bricksrc/deprecations.py` called rec_location_deprecations. For each deprecated concept in `support/brickpatches.ttl`, create a new entry with the corresponding keys 'mitigation_message', 'replace_with' and 'version'. 'version' should be '1.4.0'. Do this for all deprecated concepts

ASSISTANT: ```diff
--- bricksrc/deprecations.py
+++ bricksrc/deprecations.py
@@ ... @@
 deprecations = {
     BRICK.Condenser: {
         "version": "1.3.0",
         "mitigation_message": "'Condenser' and 'Condensing Unit' are interchangable terms. Renaming class to 'Condensing_Unit' to further aligns with ASHRAE's terminology.",
         "replace_with": BRICK.Condensing_Unit,
     },
     # ... (other existing deprecations) ...
+    BRICK.Ablutions_Room: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. There is not yet a replacement in REC for Ablutions_Room",
+        "replace_with": None,
+    },
+    BRICK.Atrium: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. For a replacement, consider rec:Atrium",
+        "replace_with": REC.Atrium,
+    },
+    BRICK.Auditorium: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. For a replacement, consider rec:Auditorium",
+        "replace_with": REC.Auditorium,
+    },
+    BRICK.Basement: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. For a replacement, consider rec:BasementLevel",
+        "replace_with": REC.BasementLevel,
+    },
+    BRICK.Battery_Room: {
+        "version": "1.4.0",
+        "mitigation_message": "Brick location classes are being phased out in favor of RealEstateCore classes. For a replacement, consider rec:ElectricityRoom",
+        "replace_with": REC.ElectricityRoom,
+    },
+    # ... (other deprecated location classes with similar structure) ...
 }
```

Note: The above diff is a partial representation. The `rec_location_deprecations` dictionary should include entries for all deprecated location classes found in `support/brickpatches.ttl`, following the same pattern as shown in the example entries for `BRICK.Ablutions_Room`, `BRICK.Atrium`, `BRICK.Auditorium`, `BRICK.Basement`, and `BRICK.Battery_Room`. Each entry should have a `version` key with the value `"1.4.0"`, a `mitigation_message` key with the deprecation message from the `.ttl` file, and a `replace_with` key with the corresponding REC class if available or `None` if there is no direct replacement. The actual implementation should continue this pattern for all deprecated concepts in the `.ttl` file.

* adding brick location deprecations

* bump dependency and version

* add rec/brick example

* bump dep again

* fix deprecations

* update ontoenv

* adjust rule for rdfs range

* refresh only when necessary

* fixing quantities environment
  • Loading branch information
gtfierro authored Jan 24, 2024
1 parent 6322eb6 commit 12deea6
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 72 deletions.
2 changes: 1 addition & 1 deletion bricksrc/deprecations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .namespaces import BRICK, RDFS, SKOS, A
from .namespaces import BRICK, RDFS, SKOS, A, REC

deprecations = {
BRICK.Condenser: {
Expand Down
2 changes: 1 addition & 1 deletion bricksrc/quantities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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
from .namespaces import SKOS, RDFS, BRICK, QUDTQK, QUDTDV, QUDT, UNIT

env = OntoEnv(initialize=True, search_dirs=["support/"])
g = Graph()
Expand Down
1 change: 1 addition & 0 deletions bricksrc/rules.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ CONSTRUCT {
$this rdfs:range ?shape .
?shape a sh:NodeShape .
?ent $this ?val .
FILTER NOT EXISTS { ?val a ?shape }
}""" ;
sh:prefixes <https://brickschema.org/schema/1.3/Brick> ;
] ;
Expand Down
6 changes: 3 additions & 3 deletions bricksrc/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

# Minor version: increment for substantial additions to the ontology that
# are backwards compatible
BRICK_MINOR_VERSION = 3
BRICK_MINOR_VERSION = 4

# Patch version: increment for minor additions/changes to the ontology that
# are largely backwards compatible (bug-fixes exempted)
BRICK_PATCH_VERSION = 0

# the simplified (no patch version) version number for Brick. Intended for
# inclusion in the Brick namespace URI
BRICK_VERSION = f"{BRICK_MAJOR_VERSION}.{BRICK_MINOR_VERSION}"
BRICK_VERSION = f"{BRICK_MAJOR_VERSION}.{BRICK_MINOR_VERSION}-rc1"

# the full "semantic verersion" including the patch number
BRICK_FULL_VERSION = f"{BRICK_VERSION}.{BRICK_PATCH_VERSION}"
BRICK_FULL_VERSION = f"{BRICK_VERSION}.{BRICK_PATCH_VERSION}-rc1"
2 changes: 1 addition & 1 deletion examples/last_known_value/last_known_value.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ bldg:sensor1 a brick:Air_Temperature_Sensor ;

bldg:sensor1_reading1 a rec:TemperatureObservation ;
brick:value "72.0"^^xsd:double ;
brick:timestamp "2020-01-01T00:00:00Z"^^xsd:dateTime ;
brick:timestamp "2024-01-01T00:00:00Z"^^xsd:dateTime ;
rec:sourcePoint bldg:sensor1 .
64 changes: 64 additions & 0 deletions examples/rec-with-brick/building.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@prefix ex: <http://example.com#> .
@prefix rec: <https://w3id.org/rec/core/> .
@prefix brick: <https://brickschema.org/schema/1.1/Brick#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

ex:Building1 a rec:Building .

# Floors
ex:Floor1 a rec:Storey ;
rec:isPartOf ex:Building1 .
ex:Floor2 a rec:Storey ;
rec:isPartOf ex:Building1 .

# Zones for each floor
ex:Floor1Zone1 a rec:Zone ;
rec:isPartOf ex:Floor1 .
ex:Floor1Zone2 a rec:Zone ;
rec:isPartOf ex:Floor1 .
ex:Floor2Zone1 a rec:Zone ;
rec:isPartOf ex:Floor2 .
ex:Floor2Zone2 a rec:Zone ;
rec:isPartOf ex:Floor2 .

# Rooms for each zone
ex:Room1 a rec:Space ;
rec:isPartOf ex:Floor1Zone1 .
ex:Room2 a rec:Space ;
rec:isPartOf ex:Floor1Zone1 .
ex:Room3 a rec:Space ;
rec:isPartOf ex:Floor1Zone2 .
ex:Room4 a rec:Space ;
rec:isPartOf ex:Floor1Zone2 .
ex:Room5 a rec:Space ;
rec:isPartOf ex:Floor2Zone1 .
ex:Room6 a rec:Space ;
rec:isPartOf ex:Floor2Zone1 .
ex:Room7 a rec:Space ;
rec:isPartOf ex:Floor2Zone2 .
ex:Room8 a rec:Space ;
rec:isPartOf ex:Floor2Zone2 .

# AHU and VAVs
ex:MainAHU a brick:Air_Handler_Unit ;
brick:feeds ex:RVAV1, ex:RVAV2, ex:RVAV3, ex:RVAV4 .

ex:RVAV1 a brick:Variable_Air_Volume_Box_With_Reheat ;
brick:feeds ex:Floor1Zone1 .
ex:RVAV2 a brick:Variable_Air_Volume_Box_With_Reheat ;
brick:feeds ex:Floor1Zone2 .
ex:RVAV3 a brick:Variable_Air_Volume_Box_With_Reheat ;
brick:feeds ex:Floor2Zone1 .
ex:RVAV4 a brick:Variable_Air_Volume_Box_With_Reheat ;
brick:feeds ex:Floor2Zone2 .

# Sensors and Setpoints for each RVAV (only doing for RVAV1 as example, repeat for others)
ex:AirTempSensor_RVAV1 a brick:Air_Temperature_Sensor ;
brick:isPointOf ex:RVAV1 .

ex:AirTempSetpoint_RVAV1 a brick:Temperature_Setpoint ;
brick:hasPoint ex:RVAV1 .

ex:AirFlowSensor_RVAV1 a brick:Air_Flow_Sensor ;
brick:isPointOf ex:RVAV1 .
18 changes: 12 additions & 6 deletions generate_brick.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,14 @@ def handle_deprecations():
fp.write(graph.serialize(format="turtle").rstrip())
fp.write("\n")

# add rec stuff
env = ontoenv.OntoEnv(initialize=True, search_dirs=["support/"])
env.import_graph(G, "support/rec.ttl")
env.import_graph(G, "support/brickpatches.ttl")

# add inferred information to Brick
# logger.info("Adding inferred information to Brick")
# G.expand('shacl', backend='topquadrant')
#logger.info("Adding inferred information to Brick")
#G.expand('shacl', backend='topquadrant')

# serialize Brick to output
with open("Brick.ttl", "w", encoding="utf-8") as fp:
Expand All @@ -1089,11 +1094,12 @@ def handle_deprecations():

# create new directory for storing imports
os.makedirs("imports", exist_ok=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")
G += depg # add the imported graph to Brick so we can do validation
graph, _ = env.resolve_uri(uri)
env.import_graph(G, graph)

# add new Brick to ontology environment
env.refresh()

# validate Brick
valid, _, report = G.validate(engine="topquadrant")
Expand Down
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.4.0a8
ontoenv>=0.4.0a12
Loading

0 comments on commit 12deea6

Please sign in to comment.