66 AsyncIterator ,
77 Dict ,
88 List ,
9+ Mapping ,
910 Optional ,
1011 Sequence ,
1112 Tuple ,
@@ -209,6 +210,7 @@ async def stream(
209210 exec_endpoint : Optional [str ] = None ,
210211 target_executor : Optional [str ] = None ,
211212 parameters : Optional [Dict ] = None ,
213+ headers : Optional [Mapping [str , str ]] = None ,
212214 results_in_order : bool = False ,
213215 return_type : Type [DocumentArray ] = DocumentArray ,
214216 ) -> AsyncIterator [Tuple [Union [DocumentArray , 'Request' ], 'ExecutorError' ]]:
@@ -221,6 +223,7 @@ async def stream(
221223 :param exec_endpoint: The Executor endpoint to which to send the Documents
222224 :param target_executor: A regex expression indicating the Executors that should receive the Request
223225 :param parameters: Parameters to be attached to the Requests
226+ :param headers: Http request headers
224227 :param results_in_order: return the results in the same order as the request_iterator
225228 :param return_type: the DocumentArray type to be returned. By default, it is `DocumentArray`.
226229 :yield: tuple of Documents or Responses and unpacked error from Executors if any
@@ -232,6 +235,7 @@ async def stream(
232235 exec_endpoint = exec_endpoint ,
233236 target_executor = target_executor ,
234237 parameters = parameters ,
238+ headers = headers ,
235239 results_in_order = results_in_order ,
236240 return_type = return_type ,
237241 ):
@@ -256,6 +260,7 @@ async def stream_doc(
256260 exec_endpoint : Optional [str ] = None ,
257261 target_executor : Optional [str ] = None ,
258262 parameters : Optional [Dict ] = None ,
263+ headers : Optional [Mapping [str , str ]] = None ,
259264 request_id : Optional [str ] = None ,
260265 return_type : Type [DocumentArray ] = DocumentArray ,
261266 ) -> AsyncIterator [Tuple [Union [DocumentArray , 'Request' ], 'ExecutorError' ]]:
@@ -267,6 +272,7 @@ async def stream_doc(
267272 :param exec_endpoint: The Executor endpoint to which to send the Documents
268273 :param target_executor: A regex expression indicating the Executors that should receive the Request
269274 :param parameters: Parameters to be attached to the Requests
275+ :param headers: Http request headers
270276 :param request_id: Request ID to add to the request streamed to Executor. Only applicable if request_size is equal or less to the length of the docs
271277 :param return_type: the DocumentArray type to be returned. By default, it is `DocumentArray`.
272278 :yield: tuple of Documents or Responses and unpacked error from Executors if any
@@ -282,6 +288,8 @@ async def stream_doc(
282288 req .header .target_executor = target_executor
283289 if parameters :
284290 req .parameters = parameters
291+ if headers :
292+ req .headers = headers
285293
286294 async for result in self .rpc_stream_doc (request = req , return_type = return_type ):
287295 error = None
@@ -306,6 +314,7 @@ async def stream_docs(
306314 exec_endpoint : Optional [str ] = None ,
307315 target_executor : Optional [str ] = None ,
308316 parameters : Optional [Dict ] = None ,
317+ headers : Optional [Mapping [str , str ]] = None ,
309318 results_in_order : bool = False ,
310319 request_id : Optional [str ] = None ,
311320 return_type : Type [DocumentArray ] = DocumentArray ,
@@ -319,6 +328,7 @@ async def stream_docs(
319328 :param exec_endpoint: The Executor endpoint to which to send the Documents
320329 :param target_executor: A regex expression indicating the Executors that should receive the Request
321330 :param parameters: Parameters to be attached to the Requests
331+ :param headers: Http request headers
322332 :param results_in_order: return the results in the same order as the request_iterator
323333 :param request_id: Request ID to add to the request streamed to Executor. Only applicable if request_size is equal or less to the length of the docs
324334 :param return_type: the DocumentArray type to be returned. By default, it is `DocumentArray`.
@@ -339,6 +349,8 @@ def _req_generator():
339349 req .header .target_executor = target_executor
340350 if parameters :
341351 req .parameters = parameters
352+ if headers :
353+ req .headers = headers
342354 yield req
343355 else :
344356 from docarray import BaseDoc
@@ -361,6 +373,8 @@ def batch(iterable, n=1):
361373 req .header .target_executor = target_executor
362374 if parameters :
363375 req .parameters = parameters
376+ if headers :
377+ req .headers = headers
364378 yield req
365379 else :
366380 req = DataRequest ()
@@ -374,6 +388,8 @@ def batch(iterable, n=1):
374388 req .header .target_executor = target_executor
375389 if parameters :
376390 req .parameters = parameters
391+ if headers :
392+ req .headers = headers
377393 yield req
378394
379395 async for resp in self .rpc_stream (
@@ -438,6 +454,7 @@ async def post(
438454 request_size : int = 100 ,
439455 on : Optional [str ] = None ,
440456 parameters : Optional [Dict ] = None ,
457+ headers : Optional [Mapping [str , str ]] = None ,
441458 return_type : Type [DocumentArray ] = DocumentArray ,
442459 ** kwargs ,
443460 ):
@@ -505,6 +522,7 @@ async def stream_doc(
505522 inputs : 'Document' ,
506523 on : Optional [str ] = None ,
507524 parameters : Optional [Dict ] = None ,
525+ headers : Optional [Mapping [str , str ]] = None ,
508526 ** kwargs ,
509527 ):
510528 req : SingleDocumentRequest = SingleDocumentRequest (inputs .to_protobuf ())
0 commit comments