Skip to content

Commit

Permalink
SHACL-based Brick Implementation (#341)
Browse files Browse the repository at this point in the history
* adding documentation on Brick releases (#264)

* Class-based shapes (#240)

* init class shapes

* Fix Nightly Builds (#241)

* try renaming file

* trying a different release package

* Amending QUDT Definitions (#239)

* change owl:sameAs to brick:hasQUDTReference

* fix Grains -> GrainsOfMoisture

* update QUDT

* simplify generation code

* fix test to reflect new implementation

* include units, even those without a symbol

* do not make Brick Quantities also QUDT Quantity Kinds

* fixing Dimensionless reference, correcting sameAs for power

* fix typos, remove undefined QUDT units

* follow steves recommendation for ontology metadata

* updating uris

* Update Ontology Metadata (#245)

* update ontology metadata to include publisher, issued, modified and use owl.versionInfo rather than dcterms.version (which does not exist)

* make publisher a blank node

* use date of publication as release date

* remove old logic for shacl test

* amend definition for isPointOf (#251)

* Adding quantities, sensor classes for air quality (#247)

* adding quantities, sensor classes for air quality

* add air quality example file + graph

* fix CO2 tags now that it is outside of particulate matter

* add definitions

* use brick value, not brick area inside the entity property (#254)

* Regenerate air quality sensor example (#255)

* use brick value, not brick area inside the entity property

* regenerate file

* fix typo

* implement disjoint classes & add tests

* clean up code

* init class shapes

* remove old logic for shacl test

* fix typo

* implement disjoint classes & add tests

* clean up code

* update shacl

* add shacl messages

* use brickschema

Co-authored-by: Gabe Fierro <[email protected]>

* generalizing solar panel and adding its subclasses (#248)

* generalizing solar panel and adding its subclasses based on the discussion at https://groups.google.com/u/1/g/brickschema/c/hvverLxC16A/m/NlvGEvcJBgAJ

* remove Solar_Panel

* add building electrical meter example (#265)

* Fixing Meter relationship in example (#266)

* add building electrical meter example

* fix relationship for meter

* add types to external properties and classes (#267)

* Fixing ASHRAE reference (#268)

* ASHRAE URI is not real; amend to something that does not break downstream parsing

* update reference

* Fix the rest of the rdfs:seeAlso URI encoding (#275)

* fix the rest of the rdfs:seeAlso URI encoding

* add seealso encoding test

* fix test to not require URIs as the only kind of resource for definitions

* added open close status classes

* Added Water Level Alarms (#282)

* added water level alarms

* fixed issue with comma in definition

* Added Lockout and Availability Status Points (#280)

* added lockout and availability status classes

* fixed issue with using comma within definitions

* added flow sensors points (#279)

* Added New Boiler Types (#283)

* added new boiler types

* Fixed capitalization in TAG term.

Co-authored-by: Gabe Fierro <[email protected]>

* Additional air handling unit types (#274)

* added classes for more air handling unit types

* added Unit suffix to DOAS name

* Update pre-commit configuration (#286)

* bumping versions, updating precommit config

* wrong version for pre-commit

* added air system classes (#278)

Co-authored-by: Gabe Fierro <[email protected]>

* fix bad merge: remove exhaust air system (#288)

* remove equipment-flavored open-close status points

* Radiant system terminal unit classes (#270)

* added radiant system termianl unit classes

* removed non uri from see also columns

* added missing rcp class

* added Panel suffix to radiant terminal unit equip names

* Add Shapes to Brick distribution (#285)

* add comments to the shapes

* add shacl shapes to base Brick distribution

* fix typo

* building Brick is dependent on shacl shapes now

* fixup shacl shapes

* update generated shapes

* PV Systems and Entity Properties (#273)

* add entity properties for panels

* add generated solar array example

* add azimuth angle in favor of orientation

* add azimuth angle to entity properties

* add meter to solar panel example

* add rated/measured power output

* add geocoordinates, efficiency

* rated vs measured conversion efficiency

* add export annotation on poitns

* more entity properties in the example

* fix header

* maximum -> nominal

* update more entity properties

* update shapes

* update examples

* Updating Nightly Builds (#289)

* explicitly pull allegrograph container in build;regen shacl before Brick

* try newer container

* try beta brickschema w/ more logging

* bump deps

* bump deps

* update deps

* update deps

* update deps

* update deps

* update deps

* update deps

* update deps

* update deps

* update deps

* use "/" suffix for sosa namespace (#295)

* add imbalance sensors (#293)

* add stage riser; update riser defn (#296)

* value of path should be sh:class, not rdfs:range (#300)

* Add testing for examples (#299)

* add labels to units when we import them into Brick

* make sure QUDT units are encoded as such

* fixing up shapes, examples

* add example tests

* fixing up example1

* Add UFAD and diffuser equipment and points (#297)

* added ufad equipment and diffuser classes

* added ufad sensor and setpoint classes

* Fixing validation of entity properties (#301)

* working on fixing validation of entity properties

* working on tests

* add types to entity property enumerations; fix entity property test to include types

* keep as byte encoding until brickschema version bump

* fix shacl generation

* fix units in air quality example

* decimal value for shapes

* fixing shape definitions, updating encodings

* add optional stuff to shapes

* more edits

* ditch Py3.6

* bump deps

* validate entity properties

* remove reference to defunct tags.py file (#303)

* Add collection types (#269)

* working on modeling collections

* fix typo

* add PV array

* fix class name in definition

* add air loop

* add constraints to collections

* add collection inference rules

* add unit test for collection

* adding some definitions

* remove rule stuff

* move PV array to collections

* remove Make predicate

* ensure systems can be in systems; ensure collections can contain locations

* add PV array to possible contents of systems

* Adding Differential Quantities to Brick (#294)

* try differential static pressure

* working on more differential quantities, adding annotations to sensors

* fix annotation

* fix some quantities

* fix inference related to differential sensors

* fix co2 sensor query test

* V1.2.1 release (#309)

* added radiant system temperature sensor classes

* added radiant system temperature setpoints

* deleted property from embedded temp sensor

* starting v1.2.1 release

* branch stuff

* added diff temp points and water temp setpoints (#277)

Co-authored-by: Gabe Fierro <[email protected]>

* Added Differential Pressure Points (#276)

* added and restructured diff pressure points

* added a more specific tag for diff pressure to resolve over infer

Co-authored-by: Gabe Fierro <[email protected]>

* use more generic differential pressure quantity for sensors

* more stuff

* working on versions, directions

* fix transmittence typo

* make sure we do not add duplicate RDFS labels (#307)

* remove controls (#310)

* Allow Entity Properties to have generic numeric values (#311)

* add list to help entity properties have generic numeric values

* minor refactor

* update shacl tag test

* adjusting implementation of radiant temp sensors

* fix misplaced tags

* load local extenstion files

* Expand ApplicableUnits annotations (#306)

* update QUDT, use skos:broader hierarchy traversals

* switch to CelsiusTemperature

* try out Temperature

* use narrower, not broader

* traverse up, not down the skos hierarchy

* removing skos:narrower traversal

* derive units from the quantity

Co-authored-by: Gabe Fierro <[email protected]>

* fix bad merge

* first draft of release notes

Co-authored-by: Carlos Duarte <[email protected]>
Co-authored-by: Gabe Fierro <[email protected]>
Co-authored-by: Jason B. Koh <[email protected]>

* - Add Chilled Beam and subclasses (#302)

- Add Induction Unit

* removing intersection classes

* Fix RDFS Labels (#313)

* get the truth value correct when checking for rdfs labels

* more tests; ensure not adding duplicate labels

* Added brick:Relief_Damper, brick:Relief_Fan and tag:Relief (#312)

Co-authored-by: David Waterworth <[email protected]>

* System shape

* Remove redundant shape definition

* before rebase

* Changed to Collection

* Replaced remaining use of System with Collection

* fix construction of shacl rules

* Adding optimized SHACL shapes to reduce inference time (#316)

* adding optimized SHACL shapes to reduce reasoning time

* extra shacl step

* bump requirements

* bump brickschema to enable new pyshacl

* fix slow mark? try different inference schedule

* ensure tiem imported for now

* compress to shorter schedule

* fix measure inference

* fix hierarchy inference

* Reduce automated test time (#320)

* mark hierarchy inference test as slow

* use xdist for tests

* bump brickschema to proper version for testing

* bump brickschema again

* avoid "slow" tests and use worker threads in github build action

* Add Sensors from NREL Example Models (#317)

* add some missing sensors

* add coils, etc to the PR

* brick reasoning shortcut schedule

* fix measures annotation

* fix measures annotation

* run "slow" tests too

* Labels on properties and entity properties (#322)

* Some labels on relations

* Labels on entity properties

* Labels on properties

* Remove duplicate

Co-authored-by: Jonas Bülow <[email protected]>

* Fix spelling (#323)

* Ignore generated files (#327)

* Ignore generated files

* Updates from review comments

Co-authored-by: Jonas Bülow <[email protected]>

* fix Dew_Point to Dewpoint (#338)

* add misc concepts (#335)

* restructure valve hierarchy and add TMV (#333)

* restructure valve hierarchy by introducing hvac valve and adding a non-hvac valve

* fix loops

* remote incorrect tags (#340)

* add miscellaneous alarms (#331)

* more alarms

* add defs

* missing declaration

* add missing points (#329)

* add missing points

* remove Air_Humidity_Setpoint

* add def

* fix typo

Co-authored-by: Gabe Fierro <[email protected]>

* using shacl inf, not owl; switch to Brick.Entity as root class

* ensure pyshacl version

* add rules.ttl for shacl

* add CRAH (#342)

* Update files generated from source (#326)

* Update files generated from source

* Avoid repo diff after running tests

Co-authored-by: Jonas Bülow <[email protected]>

* more shacl features

* Added heating, cooling enable commands (#339)

* added heating, cooling enable commands

* updated heating/cooling enable command definitions

* Remove second skos:definition for Brick#Building (#343)

* fix entity property range

* add draft of tag rule (not that we want to do this) ; fix setpoint test

* try double-shacl, use subclassof

* bump reqs

* Update rules.ttl

* triple shacl

Co-authored-by: Jason B. Koh <[email protected]>
Co-authored-by: Carlos Duarte <[email protected]>
Co-authored-by: Gabe Fierro <[email protected]>
Co-authored-by: wcrd <[email protected]>
Co-authored-by: David Waterworth <[email protected]>
Co-authored-by: David Waterworth <[email protected]>
Co-authored-by: Jonas Bülow <[email protected]>
Co-authored-by: Jonas Bülow <[email protected]>
  • Loading branch information
9 people authored Nov 2, 2021
1 parent 5c27682 commit 30a7ac0
Show file tree
Hide file tree
Showing 60 changed files with 4,646 additions and 1,476 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.6.12, 3.7.9, 3.8.5, 3.9.0]
python-version: [3.7.9, 3.8.5, 3.9.0]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Set up AllegroGraph (Docker)
run: |
docker version
docker pull franzinc/agraph:v7.0.0
docker pull franzinc/agraph:v7.1.0
- name: Install Dependencies
run: |
pip install -r requirements.txt
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Run the tests
# -s flag: do not capture output (avoids killing test after 10 min)
run: |
pytest -s -vvvv
pytest -s -vvvv --durations=0 -n auto tests
- name: Do integration tests
run: |
cd tests/integration
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/nightly-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ jobs:
with:
python-version: 3.8.5
architecture: x64
- name: Set up AllegroGraph (Docker)
run: |
docker version
docker pull franzinc/agraph:v7.1.0
- name: install deps
run: |
pip install -r requirements.txt
cd shacl && python generate_shacl.py && cd ..
python generate_brick.py
cd shacl && python generate_shacl.py
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,6 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
Brick+extensions.ttl
Brick.ttl
extensions/brick_extension_shacl_tag_inference.ttl
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v4.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: stable
rev: 21.5b2
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: master
rev: 3.9.2
hooks:
- id: flake8
args: ['--config=.flake8']
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ https://brickschema.org/schema/Brick#Thermostat,An automatic control device used

Tags provide an alternative way of instantiating classes; Brick can infer classifications from the set of tags applied to an entity with the `brick.hasTag` relationship.
Each subclass's tags should contain *at least* the tags of its parent class; currently, the set of tags for a class must be explicitly annotated.
Tags can also be explicitly defined in `bricksrc/tags.py`.

### Defining Brick Relationships

Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
.PHONY: format

Brick.ttl: bricksrc/*.py bricksrc/definitions.csv generate_brick.py
Brick.ttl: bricksrc/*.py bricksrc/*.ttl bricksrc/definitions.csv generate_brick.py
mkdir -p extensions
python generate_brick.py
cd shacl && python generate_shacl.py

shacl/BrickShape.ttl: bricksrc/*.py generate_brick.py shacl/generate_shacl.py
cd shacl && python generate_shacl.py

clean:
rm Brick.ttl Brick+extensions.ttl

format:
black generate_brick.py
black shacl/
Expand All @@ -16,7 +19,8 @@ format:
black tools/

test: Brick.ttl shacl/BrickShape.ttl
pytest -s -vvvv -m 'not slow' tests
#pytest -s -vvvv -m 'not slow' --durations=0 -n auto tests
pytest -s -vvvv --durations=0 -n auto tests
cd tests/integration && bash run_integration_tests.sh

quantity-test: Brick.ttl
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The official Brick website, [http://brickschema.org/](http://brickschema.org/),

This repository tracks the main schema development of Brick.


## Discussion

Discussion takes place primarily on the Brick User Form: [https://groups.google.com/forum/#!forum/brickschema](https://groups.google.com/forum/#!forum/brickschema)
Expand All @@ -33,6 +34,14 @@ The `examples/` directory contains executable code samples with extensive docume
- `simple_apartment`: uses Python to programmatically build a Brick model of a small apartment
- `g36`: contains Brick implementations of several figures from ASHRAE Guideline 36

## Versioning

Brick uses a semantic versioning scheme for its version numbers: `major.minor.patch`. The [releases page](https://github.com/BrickSchema/Brick/releases) contains links to each published Brick release for easy download.

We target a minor version release (e.g. `1.1`, `1.2`, `1.3`) roughly every 6 months. Minor releases will contain largely backwards-compatible extensions and new features to the ontology. Due to the significance of these changes, minor releases will be developed in their own branch; PRs for those releases will be merged into the minor version branch, and then ultimately merged into the main branch when the minor release is published.

Patch releases (e.g. `1.2.1`, `1.2.2`) contain smaller, incremental, backwards-compatible changes to the ontology. Commits and PRs for the next patch release will be merged directly into `master`. Every evening, a `nightly` build is produced containing the latest commits. **There may be bugs or errors in the nightly release**, however these bugs will be removed by the time a patch release is published.

## How To Contribute

See [CONTRIBUTING.md](https://github.com/BrickSchema/Brick/blob/master/CONTRIBUTING.md)
Expand Down
61 changes: 61 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Release Notes

This document contains the items that need to be done to prepare Brick for a release.

## Version Number

Change the version number in `bricksrc/version.py`; this will usually involve changing either the **patch** version or the **minor** version.

## Branch

Create a new branch to centralize the final changes for the release; something like `v1.2.1` or `v1.2.1-release` is appropriate. Push this branch to GitHub and use it as the merge target for any outstanding PRs.

When the branch is finished and the release is ready, merge it into the `master` branch on GitHub.

## Release Notes

Now the release notes can be prepared.

Use the output of the `tools/compare_versions` tool to generate a list of what has changed since the last release of Brick. This *can* be a URL, and in fact this is the easist way of comparing the current build with the previous build: specifically, what classes/concepts are added or removed. Take a look at the bottom of https://github.com/BrickSchema/Brick/releases/tag/v1.2.0 as an example for what this should look like in the release.

Due to a limitation of the `compare_versions` tool, it is currently necessary to download all Brick.ttl files that will be compared and to manually adjust the namespaces so that they are versioned, e.g. `https://brickschema.org/schema/Brick#` becomes `https://brickschema.org/schema/1.2.1/Brick#`.

After this is done, the tool can be run as follows

```bash
$ make # generate Brick
$ python tools/compare_versions/compare_versions.py --oldbrick 1.2.0 Brick120.ttl --newbrick 1.2.1 Brick.ttl
```

This will generate a `history/` directory containing files with the added and removed class lists.

Put together the release notes. This should summarize the changes to Brick since the last release. Be sure to thank all contributors since the previous release. This can be computed by the following git command:

```
git shortlog <last version>..HEAD -n -s
```

for example, using the git tag for the `v1.2.0` release:

```
git shortlog v1.2.0..HEAD -n -s
```

Include the added/removed classes at the bottom of the release notes. Be sure to tag the release following the usual naming schema `vMAJOR.MINOR.PATCH`.

## Update `brickschema`

Checkout the [brickschema repository](https://github.com/BrickSchema/py-brickschema). Edit `tools/update_auxiliary.sh` to identify the internal folder where the copy of Brick should go. Usually this will just involve changing the version number at the end.

Then, run `update_auxiliary.sh` from the root directory of the repository:

```bash
$ ./tools/update_auxiliary.sh
```

Update the version number of the package (`poetry version <new version>`), build and publish.


## Update Website

Instructions coming soon...
67 changes: 63 additions & 4 deletions bricksrc/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,24 @@
"Air_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm],
"subclasses": {
"Air_Flow_Loss_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm, TAG.Flow, TAG.Loss],
"Air_Flow_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm, TAG.Flow],
"subclasses": {
"Air_Flow_Loss_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm, TAG.Flow, TAG.Loss],
},
"High_Air_Flow_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm, TAG.Flow, TAG.High],
},
"Low_Air_Flow_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm, TAG.Flow, TAG.Low],
"subclasses": {
"Low_Discharge_Air_Flow_Alarm": {
"tags": [TAG.Point, TAG.Air, TAG.Alarm, TAG.Flow, TAG.Low, TAG.Discharge],
}
}
}
}
}
},
},
Expand All @@ -20,6 +36,17 @@
},
},
},
"Voltage_Alarm": {
"tags": [TAG.Point, TAG.Voltage, TAG.Alarm],
"subclasses": {
"Low_Voltage_Alarm": {
"tags": [TAG.Point, TAG.Low, TAG.Voltage, TAG.Alarm],
},
},
},
"Valve_Position_Alarm": {
"tags": [TAG.Point, TAG.Valve, TAG.Position, TAG.Alarm],
},
"Change_Filter_Alarm": {
"tags": [TAG.Point, TAG.Change, TAG.Filter, TAG.Alarm],
},
Expand Down Expand Up @@ -48,6 +75,9 @@
"Unit_Failure_Alarm": {
"tags": [TAG.Point, TAG.Unit, TAG.Failure, TAG.Alarm],
},
"Sensor_Failure_Alarm": {
"tags": [TAG.Point, TAG.Sensor, TAG.Failure, TAG.Alarm],
},
},
},
"Humidity_Alarm": {
Expand Down Expand Up @@ -168,6 +198,17 @@
],
"parents": [BRICK.High_Temperature_Alarm],
},
"Low_Discharge_Air_Temperature_Alarm": {
"tags": [
TAG.Point,
TAG.Low,
TAG.Discharge,
TAG.Air,
TAG.Temperature,
TAG.Alarm,
],
"parents": [BRICK.Low_Temperature_Alarm],
},
},
},
"Supply_Air_Temperature_Alarm": {
Expand Down Expand Up @@ -263,8 +304,26 @@
TAG.Level,
TAG.Alarm,
TAG.Point,
]
}
],
},
"Max_Water_Level_Alarm": {
"tags": [
TAG.Point,
TAG.Max,
TAG.Water,
TAG.Level,
TAG.Alarm,
],
},
"Min_Water_Level_Alarm": {
"tags": [
TAG.Point,
TAG.Min,
TAG.Water,
TAG.Level,
TAG.Alarm,
],
},
},
},
},
Expand Down
Loading

0 comments on commit 30a7ac0

Please sign in to comment.