Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix application exploration #287

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<mat-tab label="Validate">
<app-model-validate [modelId]=model.id></app-model-validate>
</mat-tab>
<mat-tab label="new thing">
<mat-tab label="Application Explorer">
<app-shape-validation [modelId]=model.id></app-shape-validation>
</mat-tab>
</mat-tab-group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ mat-card {

mat-card-content{
white-space: pre-line
}

.passes{
background-color: green;
color: white;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<mat-card-title>{{item.key}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<div *ngFor="let reason of item.value">{{reason}}</div>
<button class="passes" [disableRipple]="true" button mat-button *ngIf="!item.value.length"> Passes</button>
<div *ngFor="let reason of item.value"> - {{reason}}</div>
</mat-card-content>
</mat-card>
</mat-list>
Expand Down
1 change: 0 additions & 1 deletion buildingmotif/api/views/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from buildingmotif.api.serializers.library import serialize
from buildingmotif.dataclasses.shape_collection import ShapeCollection
from buildingmotif.namespaces import BMOTIF

blueprint = Blueprint("libraries", __name__)

Expand Down
6 changes: 4 additions & 2 deletions buildingmotif/api/views/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from buildingmotif.api.serializers.model import serialize
from buildingmotif.dataclasses import Library, Model, ShapeCollection
from buildingmotif.namespaces import BMOTIF, BRICK, RDFS, SH

blueprint = Blueprint("models", __name__)

Expand Down Expand Up @@ -55,7 +54,9 @@ def get_model_graph(models_id: int) -> Graph:
except NoResultFound:
return {"message": f"No model with id {models_id}"}, status.HTTP_404_NOT_FOUND

return model.graph.serialize(format="ttl"), status.HTTP_200_OK
g = Graph() + model.graph
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a copy_graph function in utils.py however, looking at the implementation it seems like it might be slower than this. @gtfierro what do you think?


return g.serialize(format="ttl"), status.HTTP_200_OK


@blueprint.route("/<models_id>/target_nodes", methods=(["GET"]))
Expand All @@ -80,6 +81,7 @@ def get_target_nodes(models_id: int) -> Graph:
"""
)
result = list({r for r in result})
result.sort()

return result, status.HTTP_200_OK

Expand Down
14 changes: 8 additions & 6 deletions buildingmotif/dataclasses/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,26 @@ def test_model_against_shapes(
print(target_class)
print(
f"""
SELECT ?target
SELECT ?target
WHERE {{
?target a {target_class}

}}
}}
"""
)
targets = model_graph.query(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake I made when originally writing this method, but I think we can move target resolution outside the for loop to improve performance.

f"""
SELECT ?target
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?target
WHERE {{
?target a <{target_class}>
?target rdf:type/rdfs:subClassOf* <{target_class}>

}}
}}
"""
)
temp_model_graph = copy_graph(model_graph)
for s in targets:
for (s,) in targets:
temp_model_graph.add((URIRef(s), A, shape_uri))

temp_model_graph += ontology_graph.cbd(shape_uri)
Expand Down
Loading