Skip to content

Commit acf64f4

Browse files
author
Yi-Ting Lee
committed
color node by lineage entity
1 parent d524416 commit acf64f4

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

src/sagemaker/lineage/query.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,22 @@ def __str__(self):
236236
Format:
237237
{
238238
'edges':[
239-
{
239+
"{
240240
'source_arn': 'string', 'destination_arn': 'string',
241241
'association_type': 'string'
242-
},
242+
}",
243243
...
244-
]
244+
],
245245
'vertices':[
246-
{
246+
"{
247247
'arn': 'string', 'lineage_entity': 'string',
248248
'lineage_source': 'string',
249249
'_session': <sagemaker.session.Session object>
250-
},
250+
}",
251+
...
252+
],
253+
'startarn':[
254+
'string',
251255
...
252256
]
253257
}
@@ -270,7 +274,7 @@ def _get_verts(self):
270274
"""Convert vertices to tuple format for visualizer"""
271275
verts = []
272276
for vert in self.vertices:
273-
verts.append((vert.arn, vert.lineage_source))
277+
verts.append((vert.arn, vert.lineage_source, vert.lineage_entity))
274278
return verts
275279

276280
def _get_edges(self):
@@ -288,14 +292,16 @@ def visualize(self):
288292
cyto.load_extra_layouts() # load "klay" layout (hierarchical layout) from extra layouts
289293
app = JupyterDash(__name__)
290294

295+
# get vertices and edges info for graph
291296
verts = self._get_verts()
292297
edges = self._get_edges()
293298

294299
nodes = [
295300
{
296301
"data": {"id": id, "label": label},
302+
"classes": classes
297303
}
298-
for id, label in verts
304+
for id, label, classes in verts
299305
]
300306

301307
edges = [
@@ -341,6 +347,30 @@ def visualize(self):
341347
"arrow-scale": "0.5"
342348
},
343349
},
350+
{
351+
"selector": ".Artifact",
352+
"style": {
353+
"background-color": "#146eb4"
354+
}
355+
},
356+
{
357+
"selector": ".Context",
358+
"style": {
359+
"background-color": "#ff9900"
360+
}
361+
},
362+
{
363+
"selector": ".TrialComponent",
364+
"style": {
365+
"background-color": "#f6cf61"
366+
}
367+
},
368+
{
369+
"selector": ".Action",
370+
"style": {
371+
"background-color": "#88c396"
372+
}
373+
}
344374
],
345375
responsive=True,
346376
)

0 commit comments

Comments
 (0)