Skip to content

Commit

Permalink
Use pyontoenv package for environment management (BrickSchema#634)
Browse files Browse the repository at this point in the history
* Use pyontoenv package for environment management

This is faster and more rigorously tested than the old environment
management package.

* fix package install

* working on using new ontoenv

* bump ontoenv

* fixing up rdfs label test

* add env.py

* remove extra label for atrium

* bump pyontoenv in reqs.txt

* working on labels

* more lang tags

* final version bump
  • Loading branch information
gtfierro authored Jun 16, 2024
1 parent c685f5b commit 586bb90
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Brick.ttl: bricksrc/*.py bricksrc/*.ttl bricksrc/definitions.csv generate_brick.
python handle_extensions.py

clean:
rm -r Brick.ttl Brick+extensions.ttl imports/
rm -r Brick.ttl Brick+extensions.ttl imports/ .ontoenv

format:
black generate_brick.py
Expand Down
94 changes: 47 additions & 47 deletions bricksrc/entity_properties.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bricksrc/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ontoenv import OntoEnv, Config
cfg = Config(["support/"], strict=False, offline=True)
env = OntoEnv(cfg)
96 changes: 48 additions & 48 deletions bricksrc/quantities.py

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions bricksrc/relationships.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
from rdflib import Literal
from .namespaces import A, OWL, RDFS, BRICK, VCARD, UNIT, QUDT, SDO, RDF, BSH, XSD
from .namespaces import A, OWL, RDFS, BRICK, VCARD, QUDT, SDO, RDF, BSH, XSD

"""
Defining Brick relationships
"""
relationships = {
"connectedTo": {
A: [OWL.ObjectProperty, OWL.SymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Connected To"),
RDFS.label: Literal("Connected To", lang="en"),
},
"isReplacedBy": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Is replaced by"),
RDFS.label: Literal("Is replaced by", lang="en"),
"range": BRICK.Entity,
"domain": BRICK.Entity,
},
"hasSubstance": {
A: [OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Has Substance"),
RDFS.label: Literal("Has Substance", lang="en"),
"range": BRICK.Substance,
"domain": [BRICK.Point, BRICK.Meter],
},
"hasQuantity": {
A: [OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Has Quantity"),
RDFS.label: Literal("Has Quantity", lang="en"),
RDFS.subPropertyOf: QUDT.hasQuantityKind,
"range": [BRICK.Quantity, QUDT.QuantityKind],
"domain": BRICK.Point,
},
"value": {
RDFS.subPropertyOf: QUDT.value,
RDFS.label: Literal("Value"),
RDFS.label: Literal("Value", lang="en"),
A: [RDF.Property],
"range": RDFS.Resource,
"domain": RDFS.Resource,
},
"latitude": {
RDFS.subPropertyOf: SDO.latitude,
RDFS.label: Literal("Latitude"),
RDFS.label: Literal("Latitude", lang="en"),
A: [OWL.ObjectProperty],
"domain": BRICK.Entity,
"datatype": BSH.NumericValue,
},
"longitude": {
RDFS.subPropertyOf: SDO.longitude,
RDFS.label: Literal("Longitude"),
RDFS.label: Literal("Longitude", lang="en"),
A: [OWL.ObjectProperty],
"domain": BRICK.Entity,
"datatype": BSH.NumericValue,
},
"timestamp": {
RDFS.label: Literal("Timestamp"),
RDFS.label: Literal("Timestamp", lang="en"),
A: [RDF.Property],
"domain": BRICK.Entity,
"datatype": XSD.dateTime,
},
"hasQUDTReference": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
RDFS.label: Literal("Has QUDT reference"),
RDFS.label: Literal("Has QUDT reference", lang="en"),
"domain": BRICK.Quantity,
"range": QUDT.QuantityKind,
},
Expand All @@ -66,43 +66,43 @@
OWL.inverseOf: BRICK["hasLocation"],
"domain": BRICK.Location,
"range": BRICK.Entity,
RDFS.label: Literal("Is location of"),
RDFS.label: Literal("Is location of", lang="en"),
},
"hasLocation": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["isLocationOf"],
"domain": BRICK.Entity,
"range": BRICK.Location,
RDFS.label: Literal("Has location"),
RDFS.label: Literal("Has location", lang="en"),
},
"hasInputSubstance": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
"range": BRICK.Substance,
"domain": BRICK.Equipment,
RDFS.label: Literal("Has input substance"),
RDFS.label: Literal("Has input substance", lang="en"),
},
"hasOutputSubstance": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
"range": BRICK.Substance,
"domain": BRICK.Equipment,
RDFS.label: Literal("Has output substance"),
RDFS.label: Literal("Has output substance", lang="en"),
},
"feeds": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["isFedBy"],
RDFS.label: Literal("Feeds"),
RDFS.label: Literal("Feeds", lang="en"),
},
"isFedBy": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["feeds"],
RDFS.label: Literal("Is fed by"),
RDFS.label: Literal("Is fed by", lang="en"),
},
"hasPoint": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["isPointOf"],
"range": BRICK.Point,
"domain": [BRICK.Equipment, BRICK.Location],
RDFS.label: Literal("Has point"),
RDFS.label: Literal("Has point", lang="en"),
},
"isPointOf": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
Expand All @@ -112,85 +112,85 @@
BRICK.Equipment,
BRICK.Location,
],
RDFS.label: Literal("Is point of"),
RDFS.label: Literal("Is point of", lang="en"),
},
"hasPart": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["isPartOf"],
RDFS.label: Literal("Has part"),
RDFS.label: Literal("Has part", lang="en"),
},
"isPartOf": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["hasPart"],
RDFS.label: Literal("Is part of"),
RDFS.label: Literal("Is part of", lang="en"),
},
"hasTag": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["isTagOf"],
"range": BRICK.Tag,
"domain": OWL.Class,
RDFS.label: Literal("Has tag"),
RDFS.label: Literal("Has tag", lang="en"),
},
"isTagOf": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
"domain": BRICK.Tag,
"range": OWL.Class,
RDFS.label: Literal("Is tag of"),
RDFS.label: Literal("Is tag of", lang="en"),
},
"hasAssociatedTag": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["isAssociatedWith"],
"domain": OWL.Class,
"range": BRICK.Tag,
RDFS.label: Literal("Has associated tag"),
RDFS.label: Literal("Has associated tag", lang="en"),
},
"isAssociatedWith": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK["hasAssociatedTag"],
"domain": BRICK.Tag,
"range": OWL.Class,
RDFS.label: Literal("Is associated with"),
RDFS.label: Literal("Is associated with", lang="en"),
},
"hasAddress": {
RDFS.subPropertyOf: VCARD.hasAddress,
"domain": BRICK.Building,
"range": VCARD.Address,
RDFS.label: Literal("Has address"),
RDFS.label: Literal("Has address", lang="en"),
},
"hasUnit": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
"range": QUDT.Unit,
"domain": BRICK.Point,
RDFS.label: Literal("Has unit"),
RDFS.label: Literal("Has unit", lang="en"),
},
"meters": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK.isMeteredBy,
"domain": BRICK.Meter,
# this is a special property that implements the 'range' as a SHACL shape
"range": [BRICK.Equipment, BRICK.Location, BRICK.Collection],
RDFS.label: Literal("meters"),
RDFS.label: Literal("meters", lang="en"),
},
"isMeteredBy": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK.meters,
# this is a special property that implements the 'domain' as a SHACL shape
"domain": [BRICK.Equipment, BRICK.Location, BRICK.Collection],
"range": BRICK.Meter,
RDFS.label: Literal("is metered by"),
RDFS.label: Literal("is metered by", lang="en"),
},
"hasSubMeter": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK.isSubMeterOf,
"range": BRICK.Meter,
"domain": BRICK.Meter,
RDFS.label: Literal("has sub-meter"),
RDFS.label: Literal("has sub-meter", lang="en"),
},
"isSubMeterOf": {
A: [OWL.ObjectProperty, OWL.AsymmetricProperty, OWL.IrreflexiveProperty],
OWL.inverseOf: BRICK.hasSubMeter,
"range": BRICK.Meter,
"domain": BRICK.Meter,
RDFS.label: Literal("is sub-meter of"),
RDFS.label: Literal("is sub-meter of", lang="en"),
},
}
15 changes: 15 additions & 0 deletions bricksrc/root_class_shapes.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ brick:Location a sh:NodeShape ;
sh:class brick:Equipment;
sh:message "Locations can be fed only by other Equipment."
];
sh:property [
sh:path brick:hasPoint ;
sh:class brick:Point ;
sh:message "A Location can have Points."
];
.

brick:Equipment a sh:NodeShape ;
Expand All @@ -45,6 +50,11 @@ brick:Equipment a sh:NodeShape ;
sh:class brick:Equipment;
sh:message "A piece of Equipment's parts should be always other Equipment."
];
sh:property [
sh:path brick:hasPoint ;
sh:class brick:Point ;
sh:message "A piece of Equipment can have Points."
];
sh:property [
sh:path brick:isPartOf;
sh:or (
Expand Down Expand Up @@ -82,6 +92,11 @@ brick:Point a sh:NodeShape;
sh:maxCount 0 ;
sh:message "Points cannot have locations; use 'isPointOf' instead" ;
] ;
sh:property [
sh:path brick:isPointOf ;
sh:or ( [ sh:class brick:Equipment ] [ sh:class brick:Location ] [ sh:class rec:Space ] );
sh:message "A Point can be a Point of Equipment, Location or Space."
] ;
.

brick:Collection a sh:NodeShape;
Expand Down
Loading

0 comments on commit 586bb90

Please sign in to comment.