Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6,049 changes: 3,567 additions & 2,482 deletions buildingmotif/libraries/brick/Brick.ttl

Large diffs are not rendered by default.

1,028 changes: 552 additions & 476 deletions libraries/brick/Brick.ttl

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions notebooks/Existing-model-validation-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,10 @@
},
"slideshow": {
"slide_type": "-"
}
},
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
Expand All @@ -721,7 +724,8 @@
" param_value = notebook_input(f\"Please enter the value for parameter \\\"{parameter}\\\":\")\n",
" templ_bindings[parameter] = BLDG[param_value]\n",
" graph = t.evaluate(templ_bindings)\n",
" medium_office_model.add_graph(graph)\n"
" medium_office_model_base.add_graph(graph)\n",
" medium_office_model = medium_office_model_base.compile(shape_collections)"
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/api/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ def test_create_model_bad_name(client, building_motif):
def test_validate_model(client, building_motif, shacl_engine):
building_motif.shacl_engine = shacl_engine
# Set up
unit = Library.load(ontology_graph="tests/unit/fixtures/unit.ttl")
assert unit is not None
qk = Library.load(ontology_graph="tests/unit/fixtures/quantitykind.ttl")
assert qk is not None
brick = Library.load(ontology_graph="tests/unit/fixtures/Brick.ttl")
assert brick is not None
library_1 = Library.load(ontology_graph="tests/unit/fixtures/shapes/shape1.ttl")
Expand All @@ -275,7 +279,7 @@ def test_validate_model(client, building_motif, shacl_engine):
results = client.post(
f"/models/{model.id}/validate",
headers={"Content-Type": "application/json"},
json={"library_ids": [library_1.id, library_2.id, brick.id]},
json={"library_ids": [library_1.id, library_2.id, brick.id, unit.id, qk.id]},
)

# Assert
Expand Down Expand Up @@ -310,7 +314,7 @@ def test_validate_model(client, building_motif, shacl_engine):

assert results.get_json().keys() == {"message", "reasons", "valid"}
assert isinstance(results.get_json()["message"], str)
assert results.get_json()["valid"]
assert results.get_json()["valid"], results.data
assert results.get_json()["reasons"] == {}


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/dataclasses/test_compiled_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_validate(clean_building_motif_topquadrant):
), "Compiled model is not an instance of CompiledModel"
assert compiled_model.model, "Model is not set in CompiledModel"

validation_context = compiled_model.validate()
validation_context = compiled_model.validate(error_on_missing_imports=False)
assert validation_context is not None
assert not validation_context.valid

Expand Down
9 changes: 5 additions & 4 deletions tests/unit/dataclasses/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def test_validate_model_manifest(clean_building_motif, shacl_engine):
m = Model.create(name="https://example.com", description="a very good model")
m.graph.add((URIRef("https://example.com/vav1"), A, BRICK.VAV))

Library.load(ontology_graph="tests/unit/fixtures/Brick.ttl")
lib = Library.load(ontology_graph="tests/unit/fixtures/shapes/shape1.ttl")
assert lib is not None

Expand Down Expand Up @@ -135,8 +134,8 @@ def test_validate_model_manifest(clean_building_motif, shacl_engine):
m.graph.add((URIRef("https://example.com/temp"), A, BRICK.Temperature_Sensor))

# validate against manifest -- should pass
result = m.validate()
assert result.valid
result = m.validate(error_on_missing_imports=False)
assert result.valid, result.report_string


def test_validate_model_manifest_with_imports(clean_building_motif, shacl_engine):
Expand All @@ -145,6 +144,8 @@ def test_validate_model_manifest_with_imports(clean_building_motif, shacl_engine
m.graph.add((URIRef("https://example.com/vav1"), A, BRICK.VAV))

# import brick
Library.load(ontology_graph="tests/unit/fixtures/unit.ttl")
Library.load(ontology_graph="tests/unit/fixtures/quantitykind.ttl")
Library.load(ontology_graph="tests/unit/fixtures/Brick.ttl")

# shape2.ttl attaches an import statement to the manifest
Expand Down Expand Up @@ -175,7 +176,7 @@ def test_validate_model_manifest_with_imports(clean_building_motif, shacl_engine
)

# validate against manifest -- should pass now
result = m.validate()
result = m.validate(error_on_missing_imports=False)
assert result.valid, result.report_string


Expand Down
2 changes: 2 additions & 0 deletions tests/unit/dataclasses/test_shape_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def test_get_shapes_of_domain(clean_building_motif):

def test_shape_collection_resolve_imports(clean_building_motif):
Library.load(ontology_graph="tests/unit/fixtures/Brick.ttl")
Library.load(ontology_graph="tests/unit/fixtures/unit.ttl")
Library.load(ontology_graph="tests/unit/fixtures/quantitykind.ttl")
Library.load(ontology_graph="constraints/constraints.ttl")
lib = Library.load(ontology_graph="tests/unit/fixtures/shapes/import_test.ttl")
sc = lib.get_shape_collection()
Expand Down
Loading
Loading