@@ -230,7 +230,32 @@ class PyvisVisualizer(object):
230
230
"""Create object used for visualizing graph using Pyvis library."""
231
231
232
232
def __init__ (self , graph_styles ):
233
- """Init for PyvisVisualizer."""
233
+ """Init for PyvisVisualizer.
234
+
235
+ Args:
236
+ graph_styles: A dictionary that contains graph style for node and edges by their type.
237
+ Example: Display the nodes with different color by their lineage entity / different
238
+ shape by start arn.
239
+ lineage_graph = {
240
+ "TrialComponent": {
241
+ "name": "Trial Component",
242
+ "style": {"background-color": "#f6cf61"},
243
+ "isShape": "False",
244
+ },
245
+ "Context": {
246
+ "name": "Context",
247
+ "style": {"background-color": "#ff9900"},
248
+ "isShape": "False",
249
+ },
250
+ "StartArn": {
251
+ "name": "StartArn",
252
+ "style": {"shape": "star"},
253
+ "isShape": "True",
254
+ "symbol": "★", # shape symbol for legend
255
+ },
256
+ }
257
+
258
+ """
234
259
# import visualization packages
235
260
(
236
261
self .Network ,
@@ -283,7 +308,23 @@ def _node_color(self, entity):
283
308
return self .graph_styles [entity ]["style" ]["background-color" ]
284
309
285
310
def render (self , elements , path = "pyvisExample.html" ):
286
- """Render graph for lineage query result."""
311
+ """Render graph for lineage query result.
312
+
313
+ Args:
314
+ elements: A dictionary that contains the node and the edges of the graph.
315
+ Example:
316
+ elements["nodes"] contains list of tuples, each tuple represents a node
317
+ format: (node arn, node lineage source, node lineage entity,
318
+ node is start arn)
319
+ elements["edges"] contains list of tuples, each tuple represents an edge
320
+ format: (edge source arn, edge destination arn, edge association type)
321
+
322
+ path(optional): The path/filemname of the rendered graph html file. (default path: "pyvisExample.html")
323
+
324
+ Returns:
325
+ display graph: The interactive visualization is presented as a static HTML file.
326
+
327
+ """
287
328
net = self .Network (height = "500px" , width = "100%" , notebook = True , directed = True )
288
329
net .set_options (self ._options )
289
330
@@ -384,7 +425,19 @@ def _get_visualization_elements(self):
384
425
return elements
385
426
386
427
def visualize (self , path = "pyvisExample.html" ):
387
- """Visualize lineage query result."""
428
+ """Visualize lineage query result.
429
+
430
+ Creates a PyvisVisualizer object to render network graph with Pyvis library.
431
+ Pyvis library should be installed before using this method (run "pip install pyvis")
432
+ The elements(nodes & edges) are preprocessed in this method and sent to
433
+ PyvisVisualizer for rendering graph.
434
+
435
+ Args:
436
+ path(optional): The path/filemname of the rendered graph html file. (default path: "pyvisExample.html")
437
+
438
+ Returns:
439
+ display graph: The interactive visualization is presented as a static HTML file.
440
+ """
388
441
lineage_graph = {
389
442
# nodes can have shape / color
390
443
"TrialComponent" : {
0 commit comments