Skip to content

Commit daa5cc4

Browse files
author
Yi-Ting Lee
committed
style check
1 parent c135ab9 commit daa5cc4

File tree

1 file changed

+149
-102
lines changed

1 file changed

+149
-102
lines changed

src/sagemaker/lineage/query.py

Lines changed: 149 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,13 @@ class DashVisualizer(object):
207207
def __init__(self):
208208
"""Init for DashVisualizer."""
209209
# import visualization packages
210-
self.cyto, self.JupyterDash, self.html, self.Input, self.Output = self._import_visual_modules()
210+
(
211+
self.cyto,
212+
self.JupyterDash,
213+
self.html,
214+
self.Input,
215+
self.Output,
216+
) = self._import_visual_modules()
211217

212218
def _import_visual_modules(self):
213219
"""Import modules needed for visualization."""
@@ -239,7 +245,6 @@ def _import_visual_modules(self):
239245
print("Try: pip install dash")
240246
raise
241247

242-
243248
return cyto, JupyterDash, html, Input, Output
244249

245250
def _get_app(self, elements):
@@ -252,7 +257,13 @@ def _get_app(self, elements):
252257
self.cyto.Cytoscape(
253258
id="cytoscape-graph",
254259
elements=elements,
255-
style={"width": "85%", "height": "350px", 'display': 'inline-block', 'border-width': '1vw', "border-color": "#232f3e"},
260+
style={
261+
"width": "85%",
262+
"height": "350px",
263+
"display": "inline-block",
264+
"border-width": "1vw",
265+
"border-color": "#232f3e",
266+
},
256267
layout={"name": "klay"},
257268
stylesheet=[
258269
{
@@ -263,9 +274,9 @@ def _get_app(self, elements):
263274
"height": "10vw",
264275
"width": "10vw",
265276
"border-width": "0.8",
266-
"border-opacity": "0",
277+
"border-opacity": "0",
267278
"border-color": "#232f3e",
268-
"font-family": "verdana"
279+
"font-family": "verdana",
269280
},
270281
},
271282
{
@@ -279,127 +290,161 @@ def _get_app(self, elements):
279290
"width": "1",
280291
"curve-style": "bezier",
281292
"control-point-step-size": "15",
282-
# "taxi-direction": "rightward",
283-
# "taxi-turn": "50%",
284293
"target-arrow-color": "gray",
285294
"target-arrow-shape": "triangle",
286295
"line-color": "gray",
287296
"arrow-scale": "0.5",
288-
"font-family": "verdana"
297+
"font-family": "verdana",
289298
},
290299
},
291300
{"selector": ".Artifact", "style": {"background-color": "#146eb4"}},
292301
{"selector": ".Context", "style": {"background-color": "#ff9900"}},
293302
{"selector": ".TrialComponent", "style": {"background-color": "#f6cf61"}},
294303
{"selector": ".Action", "style": {"background-color": "#88c396"}},
295304
{"selector": ".startarn", "style": {"shape": "star"}},
296-
{"selector": ".select", "style": { "border-opacity": "0.7"}},
305+
{"selector": ".select", "style": {"border-opacity": "0.7"}},
297306
],
298307
responsive=True,
299308
),
300-
self.html.Div([
301-
self.html.Div([
302-
self.html.Div(
303-
style={
304-
'background-color': "#f6cf61",
305-
'width': '1.5vw',
306-
'height': '1.5vw',
307-
'display': 'inline-block'
308-
}
309-
),
310-
self.html.Div(
311-
style={
312-
'width': '0.5vw',
313-
'height': '1.5vw',
314-
'display': 'inline-block'
315-
}
316-
),
317-
self.html.Div(' Trial Component', style={'display': 'inline-block', "font-size": "1.5vw"}),
318-
]),
319-
self.html.Div([
320-
self.html.Div(
321-
style={
322-
'background-color': "#ff9900",
323-
'width': '1.5vw',
324-
'height': '1.5vw',
325-
'display': 'inline-block'
326-
}
327-
),
328-
self.html.Div(
329-
style={
330-
'width': '0.5vw',
331-
'height': '1.5vw',
332-
'display': 'inline-block'
333-
}
334-
),
335-
self.html.Div(' Context', style={'display': 'inline-block', "font-size": "1.5vw"}),
336-
]),
337-
self.html.Div([
338-
self.html.Div(
339-
style={
340-
'background-color': "#88c396",
341-
'width': '1.5vw',
342-
'height': '1.5vw',
343-
'display': 'inline-block'
344-
}
345-
),
309+
self.html.Div(
310+
[
346311
self.html.Div(
347-
style={
348-
'width': '0.5vw',
349-
'height': '1.5vw',
350-
'display': 'inline-block'
351-
}
312+
[
313+
self.html.Div(
314+
style={
315+
"background-color": "#f6cf61",
316+
"width": "1.5vw",
317+
"height": "1.5vw",
318+
"display": "inline-block",
319+
}
320+
),
321+
self.html.Div(
322+
style={
323+
"width": "0.5vw",
324+
"height": "1.5vw",
325+
"display": "inline-block",
326+
}
327+
),
328+
self.html.Div(
329+
" Trial Component",
330+
style={"display": "inline-block", "font-size": "1.5vw"},
331+
),
332+
]
352333
),
353-
self.html.Div(' Action', style={'display': 'inline-block', "font-size": "1.5vw"}),
354-
]),
355-
self.html.Div([
356334
self.html.Div(
357-
style={
358-
'background-color': "#146eb4",
359-
'width': '1.5vw',
360-
'height': '1.5vw',
361-
'display': 'inline-block'
362-
}
335+
[
336+
self.html.Div(
337+
style={
338+
"background-color": "#ff9900",
339+
"width": "1.5vw",
340+
"height": "1.5vw",
341+
"display": "inline-block",
342+
}
343+
),
344+
self.html.Div(
345+
style={
346+
"width": "0.5vw",
347+
"height": "1.5vw",
348+
"display": "inline-block",
349+
}
350+
),
351+
self.html.Div(
352+
" Context",
353+
style={"display": "inline-block", "font-size": "1.5vw"},
354+
),
355+
]
363356
),
364357
self.html.Div(
365-
style={
366-
'width': '0.5vw',
367-
'height': '1.5vw',
368-
'display': 'inline-block'
369-
}
358+
[
359+
self.html.Div(
360+
style={
361+
"background-color": "#88c396",
362+
"width": "1.5vw",
363+
"height": "1.5vw",
364+
"display": "inline-block",
365+
}
366+
),
367+
self.html.Div(
368+
style={
369+
"width": "0.5vw",
370+
"height": "1.5vw",
371+
"display": "inline-block",
372+
}
373+
),
374+
self.html.Div(
375+
" Action",
376+
style={"display": "inline-block", "font-size": "1.5vw"},
377+
),
378+
]
370379
),
371-
self.html.Div(' Artifact', style={'display': 'inline-block', "font-size": "1.5vw"}),
372-
]),
373-
self.html.Div([
374380
self.html.Div(
375-
"★",
376-
style={
377-
'background-color': "white",
378-
'width': '1.5vw',
379-
'height': '1.5vw',
380-
'display': 'inline-block',
381-
"font-size": "1.5vw"
382-
}
381+
[
382+
self.html.Div(
383+
style={
384+
"background-color": "#146eb4",
385+
"width": "1.5vw",
386+
"height": "1.5vw",
387+
"display": "inline-block",
388+
}
389+
),
390+
self.html.Div(
391+
style={
392+
"width": "0.5vw",
393+
"height": "1.5vw",
394+
"display": "inline-block",
395+
}
396+
),
397+
self.html.Div(
398+
" Artifact",
399+
style={"display": "inline-block", "font-size": "1.5vw"},
400+
),
401+
]
383402
),
384403
self.html.Div(
385-
style={
386-
'width': '0.5vw',
387-
'height': '1.5vw',
388-
'display': 'inline-block'
389-
}
404+
[
405+
self.html.Div(
406+
"★",
407+
style={
408+
"background-color": "white",
409+
"width": "1.5vw",
410+
"height": "1.5vw",
411+
"display": "inline-block",
412+
"font-size": "1.5vw",
413+
},
414+
),
415+
self.html.Div(
416+
style={
417+
"width": "0.5vw",
418+
"height": "1.5vw",
419+
"display": "inline-block",
420+
}
421+
),
422+
self.html.Div(
423+
"StartArn",
424+
style={"display": "inline-block", "font-size": "1.5vw"},
425+
),
426+
]
390427
),
391-
self.html.Div('StartArn', style={'display': 'inline-block', "font-size": "1.5vw"}),
392-
]),
393-
], style={'width': '15%', 'display': 'inline-block', "font-size": "1vw", "font-family": "verdana", "vertical-align": "top"})
428+
],
429+
style={
430+
"width": "15%",
431+
"display": "inline-block",
432+
"font-size": "1vw",
433+
"font-family": "verdana",
434+
"vertical-align": "top",
435+
},
436+
),
394437
]
395438
)
396439

397-
@app.callback(self.Output("cytoscape-graph", "elements"),
398-
self.Input("cytoscape-graph", "tapNodeData"),
399-
self.Input("cytoscape-graph", "elements"))
440+
@app.callback(
441+
self.Output("cytoscape-graph", "elements"),
442+
self.Input("cytoscape-graph", "tapNodeData"),
443+
self.Input("cytoscape-graph", "elements"),
444+
)
400445
def selectNode(tapData, elements):
401446
for n in elements:
402-
if tapData != None and n["data"]["id"] == tapData["id"]:
447+
if tapData is not None and n["data"]["id"] == tapData["id"]:
403448
# if is tapped node, add "select" class to node
404449
n["classes"] += " select"
405450
elif "classes" in n:
@@ -416,6 +461,7 @@ def render(self, elements, mode):
416461

417462
return app.run_server(mode=mode)
418463

464+
419465
class LineageQueryResult(object):
420466
"""A wrapper around the results of a lineage query."""
421467

@@ -450,18 +496,18 @@ def __str__(self):
450496
Format:
451497
{
452498
'edges':[
453-
{
499+
"{
454500
'source_arn': 'string', 'destination_arn': 'string',
455501
'association_type': 'string'
456-
},
502+
}",
457503
...
458504
],
459505
'vertices':[
460-
{
506+
"{
461507
'arn': 'string', 'lineage_entity': 'string',
462508
'lineage_source': 'string',
463509
'_session': <sagemaker.session.Session object>
464-
},
510+
}",
465511
...
466512
],
467513
'startarn':[
@@ -515,7 +561,7 @@ def _get_visualization_elements(self):
515561

516562
def visualize(self):
517563
"""Visualize lineage query result."""
518-
elements = self._get_visualization_elements()
564+
elements = self._get_visualization_elements()
519565

520566
# initialize DashVisualizer instance to render graph & interactive components
521567
dash_vis = DashVisualizer()
@@ -524,6 +570,7 @@ def visualize(self):
524570

525571
return dash_server
526572

573+
527574
class LineageFilter(object):
528575
"""A filter used in a lineage query."""
529576

0 commit comments

Comments
 (0)