Skip to content

Commit 169dd30

Browse files
authored
Merge pull request #8 from ytlee93/master
documentation: add visualize & PyvisVisualizer documentation
2 parents 99027e3 + 143143d commit 169dd30

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

src/sagemaker/lineage/query.py

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,32 @@ 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
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+
"""
234259
# import visualization packages
235260
(
236261
self.Network,
@@ -283,7 +308,23 @@ def _node_color(self, entity):
283308
return self.graph_styles[entity]["style"]["background-color"]
284309

285310
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+
"""
287328
net = self.Network(height="500px", width="100%", notebook=True, directed=True)
288329
net.set_options(self._options)
289330

@@ -384,7 +425,19 @@ def _get_visualization_elements(self):
384425
return elements
385426

386427
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+
"""
388441
lineage_graph = {
389442
# nodes can have shape / color
390443
"TrialComponent": {

0 commit comments

Comments
 (0)