Skip to content

Commit e3a4c9d

Browse files
author
Yi-Ting Lee
committed
Double sided arrows handled
1 parent 687d6b6 commit e3a4c9d

File tree

2 files changed

+29
-118
lines changed

2 files changed

+29
-118
lines changed

src/sagemaker/lineage/query.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ def _import_visual_modules(self):
267267

268268
from dash import html
269269

270-
return cyto, JupyterDash, html
270+
from dash.dependencies import Input, Output
271+
272+
return cyto, JupyterDash, html, Input, Output
271273

272274
def _get_verts(self):
273275
"""Convert vertices to tuple format for visualizer."""
@@ -287,11 +289,12 @@ def _get_edges(self):
287289
# get edge info in the form of (source, target, label)
288290
for edge in self.edges:
289291
edges.append((edge.source_arn, edge.destination_arn, edge.association_type))
292+
edges.append((self.edges[1].destination_arn, self.edges[1].source_arn, self.edges[1].association_type))
290293
return edges
291294

292295
def visualize(self):
293296
"""Visualize lineage query result."""
294-
cyto, JupyterDash, html = self._import_visual_modules()
297+
cyto, JupyterDash, html, Input, Output = self._import_visual_modules()
295298

296299
cyto.load_extra_layouts() # load "klay" layout (hierarchical layout) from extra layouts
297300
app = JupyterDash(__name__)
@@ -314,7 +317,7 @@ def visualize(self):
314317
app.layout = html.Div(
315318
[
316319
cyto.Cytoscape(
317-
id="cytoscape-layout-1",
320+
id="cytoscape-graph",
318321
elements=elements,
319322
style={"width": "100%", "height": "350px"},
320323
layout={"name": "klay"},
@@ -326,6 +329,9 @@ def visualize(self):
326329
"font-size": "3.5vw",
327330
"height": "10vw",
328331
"width": "10vw",
332+
"border-width": "0.8",
333+
"border-opacity": "0",
334+
"border-color": "#232f3e"
329335
},
330336
},
331337
{
@@ -334,11 +340,13 @@ def visualize(self):
334340
"label": "data(label)",
335341
"color": "gray",
336342
"text-halign": "left",
337-
"text-margin-y": "3px",
338-
"text-margin-x": "-2px",
339-
"font-size": "3%",
340-
"width": "1%",
341-
"curve-style": "taxi",
343+
"text-margin-y": "2.5",
344+
"font-size": "3",
345+
"width": "1",
346+
"curve-style": "bezier",
347+
"control-point-step-size": "15",
348+
# "taxi-direction": "rightward",
349+
# "taxi-turn": "50%",
342350
"target-arrow-color": "gray",
343351
"target-arrow-shape": "triangle",
344352
"line-color": "gray",
@@ -350,12 +358,25 @@ def visualize(self):
350358
{"selector": ".TrialComponent", "style": {"background-color": "#f6cf61"}},
351359
{"selector": ".Action", "style": {"background-color": "#88c396"}},
352360
{"selector": ".startarn", "style": {"shape": "star"}},
361+
{"selector": ".select", "style": { "border-opacity": "0.7"}},
353362
],
354363
responsive=True,
355364
)
356365
]
357366
)
358367

368+
@app.callback(Output("cytoscape-graph", "elements"),
369+
Input("cytoscape-graph", "tapNodeData"))
370+
def selectNode(data):
371+
for n in nodes:
372+
if data != None and n["data"]["id"] == data["id"]:
373+
n["classes"] += " select"
374+
else:
375+
n["classes"] = n["classes"].replace("select", "")
376+
377+
elements = nodes + edges
378+
return elements
379+
359380
return app.run_server(mode="inline")
360381

361382

tests/data/_repack_model.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)