Skip to content

Commit

Permalink
Merge pull request #334 from nanglo123/fix_dkg_viz_edge_naming
Browse files Browse the repository at this point in the history
Fix dkg viz edge naming
  • Loading branch information
bgyori authored Jun 4, 2024
2 parents bb2f2c8 + 54331b6 commit 6de0824
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
3 changes: 2 additions & 1 deletion mira/dkg/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ def get_relations(
return [
FullRelationResponse(
subject=Entity.from_data(s),
predicate=dict(p) if isinstance(p, Relationship) else [dict(r) for r in p],
predicate={**dict(p), **{"type": p.type}} if isinstance(p, Relationship) else [
{**dict(r), **{"type": p.type}} for r in p],
object=Entity.from_data(o),
)
for s, p, o in records
Expand Down
2 changes: 2 additions & 0 deletions mira/dkg/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ def draw_relations(records, fname, is_full=False):
color="red", weight=2)
agraph = nx.nx_agraph.to_agraph(graph)
agraph.draw(path=fname, prog="dot", format="png")


59 changes: 31 additions & 28 deletions notebooks/DKG_Viz_Demo.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_dkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_get_relations(self):
self.assertEqual(200, response.status_code, msg=response.content)

def test_get_relations_graph(self):
"Test getting graph output of relations."""
"""Test getting graph output of relations."""
spec = inspect.signature(get_relations)
relation_query_default = spec.parameters["relation_query"].default
self.assertIsInstance(relation_query_default, fastapi.params.Body)
Expand Down

0 comments on commit 6de0824

Please sign in to comment.