@@ -207,7 +207,13 @@ class DashVisualizer(object):
207
207
def __init__ (self ):
208
208
"""Init for DashVisualizer."""
209
209
# import visualization packages
210
- self .cyto , self .JupyterDash , self .html , self .Input , self .Output = self ._import_visual_modules ()
210
+ (
211
+ self .cyto ,
212
+ self .JupyterDash ,
213
+ self .html ,
214
+ self .Input ,
215
+ self .Output ,
216
+ ) = self ._import_visual_modules ()
211
217
212
218
def _import_visual_modules (self ):
213
219
"""Import modules needed for visualization."""
@@ -239,7 +245,6 @@ def _import_visual_modules(self):
239
245
print ("Try: pip install dash" )
240
246
raise
241
247
242
-
243
248
return cyto , JupyterDash , html , Input , Output
244
249
245
250
def _get_app (self , elements ):
@@ -252,7 +257,13 @@ def _get_app(self, elements):
252
257
self .cyto .Cytoscape (
253
258
id = "cytoscape-graph" ,
254
259
elements = elements ,
255
- style = {"width" : "85%" , "height" : "350px" , 'display' : 'inline-block' , 'border-width' : '1vw' , "border-color" : "#232f3e" },
260
+ style = {
261
+ "width" : "85%" ,
262
+ "height" : "350px" ,
263
+ "display" : "inline-block" ,
264
+ "border-width" : "1vw" ,
265
+ "border-color" : "#232f3e" ,
266
+ },
256
267
layout = {"name" : "klay" },
257
268
stylesheet = [
258
269
{
@@ -263,9 +274,9 @@ def _get_app(self, elements):
263
274
"height" : "10vw" ,
264
275
"width" : "10vw" ,
265
276
"border-width" : "0.8" ,
266
- "border-opacity" : "0" ,
277
+ "border-opacity" : "0" ,
267
278
"border-color" : "#232f3e" ,
268
- "font-family" : "verdana"
279
+ "font-family" : "verdana" ,
269
280
},
270
281
},
271
282
{
@@ -279,127 +290,161 @@ def _get_app(self, elements):
279
290
"width" : "1" ,
280
291
"curve-style" : "bezier" ,
281
292
"control-point-step-size" : "15" ,
282
- # "taxi-direction": "rightward",
283
- # "taxi-turn": "50%",
284
293
"target-arrow-color" : "gray" ,
285
294
"target-arrow-shape" : "triangle" ,
286
295
"line-color" : "gray" ,
287
296
"arrow-scale" : "0.5" ,
288
- "font-family" : "verdana"
297
+ "font-family" : "verdana" ,
289
298
},
290
299
},
291
300
{"selector" : ".Artifact" , "style" : {"background-color" : "#146eb4" }},
292
301
{"selector" : ".Context" , "style" : {"background-color" : "#ff9900" }},
293
302
{"selector" : ".TrialComponent" , "style" : {"background-color" : "#f6cf61" }},
294
303
{"selector" : ".Action" , "style" : {"background-color" : "#88c396" }},
295
304
{"selector" : ".startarn" , "style" : {"shape" : "star" }},
296
- {"selector" : ".select" , "style" : { "border-opacity" : "0.7" }},
305
+ {"selector" : ".select" , "style" : {"border-opacity" : "0.7" }},
297
306
],
298
307
responsive = True ,
299
308
),
300
- self .html .Div ([
301
- self .html .Div ([
302
- self .html .Div (
303
- style = {
304
- 'background-color' : "#f6cf61" ,
305
- 'width' : '1.5vw' ,
306
- 'height' : '1.5vw' ,
307
- 'display' : 'inline-block'
308
- }
309
- ),
310
- self .html .Div (
311
- style = {
312
- 'width' : '0.5vw' ,
313
- 'height' : '1.5vw' ,
314
- 'display' : 'inline-block'
315
- }
316
- ),
317
- self .html .Div (' Trial Component' , style = {'display' : 'inline-block' , "font-size" : "1.5vw" }),
318
- ]),
319
- self .html .Div ([
320
- self .html .Div (
321
- style = {
322
- 'background-color' : "#ff9900" ,
323
- 'width' : '1.5vw' ,
324
- 'height' : '1.5vw' ,
325
- 'display' : 'inline-block'
326
- }
327
- ),
328
- self .html .Div (
329
- style = {
330
- 'width' : '0.5vw' ,
331
- 'height' : '1.5vw' ,
332
- 'display' : 'inline-block'
333
- }
334
- ),
335
- self .html .Div (' Context' , style = {'display' : 'inline-block' , "font-size" : "1.5vw" }),
336
- ]),
337
- self .html .Div ([
338
- self .html .Div (
339
- style = {
340
- 'background-color' : "#88c396" ,
341
- 'width' : '1.5vw' ,
342
- 'height' : '1.5vw' ,
343
- 'display' : 'inline-block'
344
- }
345
- ),
309
+ self .html .Div (
310
+ [
346
311
self .html .Div (
347
- style = {
348
- 'width' : '0.5vw' ,
349
- 'height' : '1.5vw' ,
350
- 'display' : 'inline-block'
351
- }
312
+ [
313
+ self .html .Div (
314
+ style = {
315
+ "background-color" : "#f6cf61" ,
316
+ "width" : "1.5vw" ,
317
+ "height" : "1.5vw" ,
318
+ "display" : "inline-block" ,
319
+ }
320
+ ),
321
+ self .html .Div (
322
+ style = {
323
+ "width" : "0.5vw" ,
324
+ "height" : "1.5vw" ,
325
+ "display" : "inline-block" ,
326
+ }
327
+ ),
328
+ self .html .Div (
329
+ " Trial Component" ,
330
+ style = {"display" : "inline-block" , "font-size" : "1.5vw" },
331
+ ),
332
+ ]
352
333
),
353
- self .html .Div (' Action' , style = {'display' : 'inline-block' , "font-size" : "1.5vw" }),
354
- ]),
355
- self .html .Div ([
356
334
self .html .Div (
357
- style = {
358
- 'background-color' : "#146eb4" ,
359
- 'width' : '1.5vw' ,
360
- 'height' : '1.5vw' ,
361
- 'display' : 'inline-block'
362
- }
335
+ [
336
+ self .html .Div (
337
+ style = {
338
+ "background-color" : "#ff9900" ,
339
+ "width" : "1.5vw" ,
340
+ "height" : "1.5vw" ,
341
+ "display" : "inline-block" ,
342
+ }
343
+ ),
344
+ self .html .Div (
345
+ style = {
346
+ "width" : "0.5vw" ,
347
+ "height" : "1.5vw" ,
348
+ "display" : "inline-block" ,
349
+ }
350
+ ),
351
+ self .html .Div (
352
+ " Context" ,
353
+ style = {"display" : "inline-block" , "font-size" : "1.5vw" },
354
+ ),
355
+ ]
363
356
),
364
357
self .html .Div (
365
- style = {
366
- 'width' : '0.5vw' ,
367
- 'height' : '1.5vw' ,
368
- 'display' : 'inline-block'
369
- }
358
+ [
359
+ self .html .Div (
360
+ style = {
361
+ "background-color" : "#88c396" ,
362
+ "width" : "1.5vw" ,
363
+ "height" : "1.5vw" ,
364
+ "display" : "inline-block" ,
365
+ }
366
+ ),
367
+ self .html .Div (
368
+ style = {
369
+ "width" : "0.5vw" ,
370
+ "height" : "1.5vw" ,
371
+ "display" : "inline-block" ,
372
+ }
373
+ ),
374
+ self .html .Div (
375
+ " Action" ,
376
+ style = {"display" : "inline-block" , "font-size" : "1.5vw" },
377
+ ),
378
+ ]
370
379
),
371
- self .html .Div (' Artifact' , style = {'display' : 'inline-block' , "font-size" : "1.5vw" }),
372
- ]),
373
- self .html .Div ([
374
380
self .html .Div (
375
- "★" ,
376
- style = {
377
- 'background-color' : "white" ,
378
- 'width' : '1.5vw' ,
379
- 'height' : '1.5vw' ,
380
- 'display' : 'inline-block' ,
381
- "font-size" : "1.5vw"
382
- }
381
+ [
382
+ self .html .Div (
383
+ style = {
384
+ "background-color" : "#146eb4" ,
385
+ "width" : "1.5vw" ,
386
+ "height" : "1.5vw" ,
387
+ "display" : "inline-block" ,
388
+ }
389
+ ),
390
+ self .html .Div (
391
+ style = {
392
+ "width" : "0.5vw" ,
393
+ "height" : "1.5vw" ,
394
+ "display" : "inline-block" ,
395
+ }
396
+ ),
397
+ self .html .Div (
398
+ " Artifact" ,
399
+ style = {"display" : "inline-block" , "font-size" : "1.5vw" },
400
+ ),
401
+ ]
383
402
),
384
403
self .html .Div (
385
- style = {
386
- 'width' : '0.5vw' ,
387
- 'height' : '1.5vw' ,
388
- 'display' : 'inline-block'
389
- }
404
+ [
405
+ self .html .Div (
406
+ "★" ,
407
+ style = {
408
+ "background-color" : "white" ,
409
+ "width" : "1.5vw" ,
410
+ "height" : "1.5vw" ,
411
+ "display" : "inline-block" ,
412
+ "font-size" : "1.5vw" ,
413
+ },
414
+ ),
415
+ self .html .Div (
416
+ style = {
417
+ "width" : "0.5vw" ,
418
+ "height" : "1.5vw" ,
419
+ "display" : "inline-block" ,
420
+ }
421
+ ),
422
+ self .html .Div (
423
+ "StartArn" ,
424
+ style = {"display" : "inline-block" , "font-size" : "1.5vw" },
425
+ ),
426
+ ]
390
427
),
391
- self .html .Div ('StartArn' , style = {'display' : 'inline-block' , "font-size" : "1.5vw" }),
392
- ]),
393
- ], style = {'width' : '15%' , 'display' : 'inline-block' , "font-size" : "1vw" , "font-family" : "verdana" , "vertical-align" : "top" })
428
+ ],
429
+ style = {
430
+ "width" : "15%" ,
431
+ "display" : "inline-block" ,
432
+ "font-size" : "1vw" ,
433
+ "font-family" : "verdana" ,
434
+ "vertical-align" : "top" ,
435
+ },
436
+ ),
394
437
]
395
438
)
396
439
397
- @app .callback (self .Output ("cytoscape-graph" , "elements" ),
398
- self .Input ("cytoscape-graph" , "tapNodeData" ),
399
- self .Input ("cytoscape-graph" , "elements" ))
440
+ @app .callback (
441
+ self .Output ("cytoscape-graph" , "elements" ),
442
+ self .Input ("cytoscape-graph" , "tapNodeData" ),
443
+ self .Input ("cytoscape-graph" , "elements" ),
444
+ )
400
445
def selectNode (tapData , elements ):
401
446
for n in elements :
402
- if tapData != None and n ["data" ]["id" ] == tapData ["id" ]:
447
+ if tapData is not None and n ["data" ]["id" ] == tapData ["id" ]:
403
448
# if is tapped node, add "select" class to node
404
449
n ["classes" ] += " select"
405
450
elif "classes" in n :
@@ -416,6 +461,7 @@ def render(self, elements, mode):
416
461
417
462
return app .run_server (mode = mode )
418
463
464
+
419
465
class LineageQueryResult (object ):
420
466
"""A wrapper around the results of a lineage query."""
421
467
@@ -450,18 +496,18 @@ def __str__(self):
450
496
Format:
451
497
{
452
498
'edges':[
453
- {
499
+ " {
454
500
'source_arn': 'string', 'destination_arn': 'string',
455
501
'association_type': 'string'
456
- },
502
+ }" ,
457
503
...
458
504
],
459
505
'vertices':[
460
- {
506
+ " {
461
507
'arn': 'string', 'lineage_entity': 'string',
462
508
'lineage_source': 'string',
463
509
'_session': <sagemaker.session.Session object>
464
- },
510
+ }" ,
465
511
...
466
512
],
467
513
'startarn':[
@@ -515,7 +561,7 @@ def _get_visualization_elements(self):
515
561
516
562
def visualize (self ):
517
563
"""Visualize lineage query result."""
518
- elements = self ._get_visualization_elements ()
564
+ elements = self ._get_visualization_elements ()
519
565
520
566
# initialize DashVisualizer instance to render graph & interactive components
521
567
dash_vis = DashVisualizer ()
@@ -524,6 +570,7 @@ def visualize(self):
524
570
525
571
return dash_server
526
572
573
+
527
574
class LineageFilter (object ):
528
575
"""A filter used in a lineage query."""
529
576
0 commit comments