@@ -65,6 +65,22 @@ def __init__(
65
65
self .destination_arn = destination_arn
66
66
self .association_type = association_type
67
67
68
+ def __hash__ (self ):
69
+ return hash (
70
+ (
71
+ "source_arn" , self .source_arn ,
72
+ "destination_arn" , self .destination_arn ,
73
+ "association_type" , self .association_type ,
74
+ )
75
+ )
76
+
77
+ def __eq__ (self , other ):
78
+ return (
79
+ self .association_type == other .association_type
80
+ and self .source_arn == other .source_arn
81
+ and self .destination_arn == other .destination_arn
82
+ )
83
+
68
84
69
85
class Vertex :
70
86
"""A vertex for a lineage graph."""
@@ -82,6 +98,22 @@ def __init__(
82
98
self .lineage_source = lineage_source
83
99
self ._session = sagemaker_session
84
100
101
+ def __hash__ (self ):
102
+ return hash (
103
+ (
104
+ "arn" , self .arn ,
105
+ "lineage_entity" , self .lineage_entity ,
106
+ "lineage_source" , self .lineage_source ,
107
+ )
108
+ )
109
+
110
+ def __eq__ (self , other ):
111
+ return (
112
+ self .arn == other .arn
113
+ and self .lineage_entity == other .lineage_entity
114
+ and self .lineage_source == other .lineage_source
115
+ )
116
+
85
117
def to_lineage_object (self ):
86
118
"""Convert the ``Vertex`` object to its corresponding ``Artifact`` or ``Context`` object."""
87
119
from sagemaker .lineage .artifact import Artifact , ModelArtifact
@@ -206,6 +238,18 @@ def _convert_api_response(self, response) -> LineageQueryResult:
206
238
converted .edges = [self ._get_edge (edge ) for edge in response ["Edges" ]]
207
239
converted .vertices = [self ._get_vertex (vertex ) for vertex in response ["Vertices" ]]
208
240
241
+ edge_set = set ()
242
+ for edge in converted .edges :
243
+ if edge in edge_set :
244
+ converted .edges .remove (edge )
245
+ edge_set .add (edge )
246
+
247
+ vertex_set = set ()
248
+ for vertex in converted .vertices :
249
+ if vertex in vertex_set :
250
+ converted .vertices .remove (vertex )
251
+ vertex_set .add (vertex )
252
+
209
253
return converted
210
254
211
255
def query (
0 commit comments