@@ -68,16 +68,14 @@ def api_client(api_token: str, environment: str) -> Iterator[ApiClient]:
6868def pipeline_id (api_client : v .ApiClient , org_id : str ) -> Iterator [str ]:
6969 pipelines = v .PipelinesApi (api_client )
7070
71- connectors_api = v .ConnectorsApi (api_client )
71+ connectors_api = v .SourceConnectorsApi (api_client )
7272 response = connectors_api .create_source_connector (
7373 org_id ,
74- [
75- v .CreateSourceConnector (
76- name = "from api" , type = v .SourceConnectorType .FILE_UPLOAD
77- )
78- ],
74+ v .CreateSourceConnectorRequest (
75+ v .FileUpload (name = "from api" , type = "FILE_UPLOAD" )
76+ ),
7977 )
80- source_connector_id = response .connectors [ 0 ] .id
78+ source_connector_id = response .connector .id
8179 logging .info ("Created source connector %s" , source_connector_id )
8280
8381 uploads_api = v .UploadsApi (api_client )
@@ -111,13 +109,17 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]:
111109 else :
112110 logging .info ("Upload successful" )
113111
114- ai_platforms = connectors_api .get_ai_platform_connectors (org_id )
112+ ai_platforms = v .AIPlatformConnectorsApi (api_client ).get_ai_platform_connectors (
113+ org_id
114+ )
115115 builtin_ai_platform = next (
116116 c .id for c in ai_platforms .ai_platform_connectors if c .type == "VECTORIZE"
117117 )
118118 logging .info ("Using AI platform %s" , builtin_ai_platform )
119119
120- vector_databases = connectors_api .get_destination_connectors (org_id )
120+ vector_databases = v .DestinationConnectorsApi (
121+ api_client
122+ ).get_destination_connectors (org_id )
121123 builtin_vector_db = next (
122124 c .id for c in vector_databases .destination_connectors if c .type == "VECTORIZE"
123125 )
@@ -127,24 +129,24 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]:
127129 org_id ,
128130 v .PipelineConfigurationSchema (
129131 source_connectors = [
130- v .SourceConnectorSchema (
132+ v .PipelineSourceConnectorSchema (
131133 id = source_connector_id ,
132134 type = v .SourceConnectorType .FILE_UPLOAD ,
133135 config = {},
134136 )
135137 ],
136- destination_connector = v .DestinationConnectorSchema (
138+ destination_connector = v .PipelineDestinationConnectorSchema (
137139 id = builtin_vector_db ,
138- type = v . DestinationConnectorType . VECTORIZE ,
140+ type = " VECTORIZE" ,
139141 config = {},
140142 ),
141- ai_platform = v .AIPlatformSchema (
143+ ai_platform_connector = v .PipelineAIPlatformConnectorSchema (
142144 id = builtin_ai_platform ,
143- type = v . AIPlatformType . VECTORIZE ,
144- config = v . AIPlatformConfigSchema () ,
145+ type = " VECTORIZE" ,
146+ config = {} ,
145147 ),
146148 pipeline_name = "Test pipeline" ,
147- schedule = v .ScheduleSchema (type = v . ScheduleSchemaType . MANUAL ),
149+ schedule = v .ScheduleSchema (type = "manual" ),
148150 ),
149151 )
150152 pipeline_id = pipeline_response .data .id
@@ -173,9 +175,15 @@ def test_retrieve_init_args(
173175 )
174176 start = time .time ()
175177 while True :
176- docs = retriever .invoke (input = "What are you?" )
177- if len (docs ) == 2 :
178- break
178+ try :
179+ docs = retriever .invoke (input = "What are you?" )
180+ if len (docs ) == 2 :
181+ break
182+ except Exception as e :
183+ if "503" in str (e ):
184+ continue
185+ raise RuntimeError (e ) from e
186+
179187 if time .time () - start > 180 :
180188 msg = "Docs not retrieved in time"
181189 raise RuntimeError (msg )
@@ -191,15 +199,22 @@ def test_retrieve_invoke_args(
191199 retriever = VectorizeRetriever (environment = environment , api_token = api_token )
192200 start = time .time ()
193201 while True :
194- docs = retriever .invoke (
195- input = "What are you?" ,
196- organization = org_id ,
197- pipeline_id = pipeline_id ,
198- num_results = 2 ,
199- )
200- if len (docs ) == 2 :
201- break
202+ try :
203+ docs = retriever .invoke (
204+ input = "What are you?" ,
205+ organization = org_id ,
206+ pipeline_id = pipeline_id ,
207+ num_results = 2 ,
208+ )
209+ if len (docs ) == 2 :
210+ break
211+
212+ except Exception as e :
213+ if "503" in str (e ):
214+ continue
215+ raise RuntimeError (e ) from e
202216 if time .time () - start > 180 :
203217 msg = "Docs not retrieved in time"
204218 raise RuntimeError (msg )
219+
205220 time .sleep (1 )
0 commit comments