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