Skip to content

Commit 77965db

Browse files
author
Yi-Ting Lee
committed
feature: add __str__ methods to queryLineage output classes
1 parent b2d4744 commit 77965db

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/sagemaker/lineage/query.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ def __eq__(self, other):
9292
and self.destination_arn == other.destination_arn
9393
)
9494

95+
def __str__(self):
96+
"""Define string representation of ``Edge``.
97+
98+
Format:
99+
{
100+
'source_arn': 'string', 'destination_arn': 'string',
101+
'association_type': 'string'
102+
}
103+
104+
"""
105+
return (str(self.__dict__))
106+
95107

96108
class Vertex:
97109
"""A vertex for a lineage graph."""
@@ -130,6 +142,19 @@ def __eq__(self, other):
130142
and self.lineage_source == other.lineage_source
131143
)
132144

145+
def __str__(self):
146+
"""Define string representation of ``Vertex``.
147+
148+
Format:
149+
{
150+
'arn': 'string', 'lineage_entity': 'string',
151+
'lineage_source': 'string',
152+
'_session': <sagemaker.session.Session object>
153+
}
154+
155+
"""
156+
return (str(self.__dict__))
157+
133158
def to_lineage_object(self):
134159
"""Convert the ``Vertex`` object to its corresponding lineage object.
135160
@@ -199,6 +224,32 @@ def __init__(
199224
if vertices is not None:
200225
self.vertices = vertices
201226

227+
def __str__(self):
228+
"""Define string representation of ``LineageQueryResult``.
229+
230+
Format:
231+
{
232+
'edges':[
233+
{
234+
'source_arn': 'string', 'destination_arn': 'string',
235+
'association_type': 'string'
236+
},
237+
...
238+
]
239+
'vertices':[
240+
{
241+
'arn': 'string', 'lineage_entity': 'string',
242+
'lineage_source': 'string',
243+
'_session': <sagemaker.session.Session object>
244+
},
245+
...
246+
]
247+
}
248+
249+
"""
250+
result_dict = vars(self)
251+
return (str({k: [vars(val) for val in v] for k, v in result_dict.items()}))
252+
202253

203254
class LineageFilter(object):
204255
"""A filter used in a lineage query."""

0 commit comments

Comments
 (0)