Skip to content

Commit 83964da

Browse files
author
Yi-Ting Lee
committed
resolve conflict with master branch
1 parent fa7b9dd commit 83964da

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/sagemaker/lineage/query.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,7 @@ def __init__(self, graph_styles):
214214

215215
self.graph_styles = graph_styles
216216

217-
def _import_visual_modules(self):
218-
"""Import modules needed for visualization."""
219-
get_module("pyvis")
220-
from pyvis.network import Network
221-
from pyvis.options import Options
222-
223-
return Network, Options
224-
225-
def _get_options(self):
226-
"""Get pyvis graph options."""
227-
options = """
217+
self._options = """
228218
var options = {
229219
"configure":{
230220
"enabled": false
@@ -253,28 +243,36 @@ def _get_options(self):
253243
}
254244
}
255245
"""
256-
return options
257246

258-
def _node_color(self, n):
247+
def _import_visual_modules(self):
248+
"""Import modules needed for visualization."""
249+
get_module("pyvis")
250+
from pyvis.network import Network
251+
from pyvis.options import Options
252+
253+
return Network, Options
254+
255+
def _node_color(self, entity):
259256
"""Return node color by background-color specified in graph styles."""
260-
return self.graph_styles[n[2]]["style"]["background-color"]
257+
return self.graph_styles[entity]["style"]["background-color"]
261258

262259
def render(self, elements, path="pyvisExample.html"):
263260
"""Render graph for lineage query result."""
264261
net = self.Network(height="500px", width="100%", notebook=True, directed=True)
265-
options = self._get_options()
266-
net.set_options(options)
262+
net.set_options(self._options)
267263

268264
# add nodes to graph
269-
for n in elements["nodes"]:
270-
if n[3]: # startarn
271-
net.add_node(n[0], label=n[1], title=n[2], color=self._node_color(n), shape="star")
265+
for arn, source, entity, is_start_arn in elements["nodes"]:
266+
if is_start_arn: # startarn
267+
net.add_node(
268+
arn, label=source, title=entity, color=self._node_color(entity), shape="star"
269+
)
272270
else:
273-
net.add_node(n[0], label=n[1], title=n[2], color=self._node_color(n))
271+
net.add_node(arn, label=source, title=entity, color=self._node_color(entity))
274272

275273
# add edges to graph
276-
for e in elements["edges"]:
277-
net.add_edge(e[0], e[1], title=e[2])
274+
for src, dest, asso_type in elements["edges"]:
275+
net.add_edge(src, dest, title=asso_type)
278276

279277
return net.show(path)
280278

0 commit comments

Comments
 (0)