Skip to content

Commit 2950b9f

Browse files
author
Yi-Ting Lee
committed
documentation: add visualize & PyvisVisualizer documentation
1 parent 32fe4fe commit 2950b9f

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

src/sagemaker/lineage/query.py

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,31 @@ class PyvisVisualizer(object):
230230
"""Create object used for visualizing graph using Pyvis library."""
231231

232232
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+
"""
234258
# import visualization packages
235259
(
236260
self.Network,
@@ -283,7 +307,22 @@ def _node_color(self, entity):
283307
return self.graph_styles[entity]["style"]["background-color"]
284308

285309
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+
"""
287326
net = self.Network(height="500px", width="100%", notebook=True, directed=True)
288327
net.set_options(self._options)
289328

@@ -384,7 +423,17 @@ def _get_visualization_elements(self):
384423
return elements
385424

386425
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+
"""
388437
lineage_graph = {
389438
# nodes can have shape / color
390439
"TrialComponent": {

0 commit comments

Comments
 (0)