Skip to content

Commit 628ba0f

Browse files
author
Yi-Ting Lee
committed
__str__ function update
1 parent 73f2d4f commit 628ba0f

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

src/sagemaker/lineage/query.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ def __str__(self):
104104
"""
105105
return str(self.__dict__)
106106

107+
def __repr__(self):
108+
"""Define string representation of ``Edge``.
109+
110+
Format:
111+
{
112+
'source_arn': 'string', 'destination_arn': 'string',
113+
'association_type': 'string'
114+
}
115+
116+
"""
117+
return "\n\t" + str(self.__dict__)
118+
107119

108120
class Vertex:
109121
"""A vertex for a lineage graph."""
@@ -155,6 +167,19 @@ def __str__(self):
155167
"""
156168
return str(self.__dict__)
157169

170+
def __repr__(self):
171+
"""Define string representation of ``Vertex``.
172+
173+
Format:
174+
{
175+
'arn': 'string', 'lineage_entity': 'string',
176+
'lineage_source': 'string',
177+
'_session': <sagemaker.session.Session object>
178+
}
179+
180+
"""
181+
return "\n\t" + str(self.__dict__)
182+
158183
def to_lineage_object(self):
159184
"""Convert the ``Vertex`` object to its corresponding lineage object.
160185
@@ -312,29 +337,19 @@ def __str__(self):
312337
Format:
313338
{
314339
'edges':[
315-
"{
316-
'source_arn': 'string', 'destination_arn': 'string',
317-
'association_type': 'string'
318-
}",
319-
...
320-
],
340+
{'source_arn': 'string', 'destination_arn': 'string', 'association_type': 'string'},
341+
...],
342+
321343
'vertices':[
322-
"{
323-
'arn': 'string', 'lineage_entity': 'string',
324-
'lineage_source': 'string',
325-
'_session': <sagemaker.session.Session object>
326-
}",
327-
...
328-
],
329-
'startarn':[
330-
'string',
331-
...
332-
]
344+
{'arn': 'string', 'lineage_entity': 'string', 'lineage_source': 'string', '_session': <sagemaker.session.Session object>},
345+
...],
346+
347+
'startarn':['string', ...]
333348
}
334349
335350
"""
336351
result_dict = vars(self)
337-
return str({k: [str(val) for val in v] for k, v in result_dict.items()})
352+
return '{\n' + '\n\n'.join('\'{}\': {},'.format(key, val) for key, val in self.__dict__.items()) + '\n}'
338353

339354
def _covert_edges_to_tuples(self):
340355
"""Convert edges to tuple format for visualizer."""

0 commit comments

Comments
 (0)