
    0j&q                       d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlmZ d dlZddlmZmZmZmZmZmZmZ ddlmZmZmZmZ dd	lmZ dd
lmZm Z  ddl!m"Z"m#Z#m$Z$m%Z% ddl&m'Z'm(Z( ddl)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddgZ> G d de          Z? G d de           Z@ G d d          ZA G d d          ZB G d d          ZC G d  d!          ZDdS )"    )annotations)AnyDictListUnionIterableOptionalcast)chain)LiteralN   )BodyOmitQueryHeadersNotGivenomit	not_given)is_givenmaybe_transformstrip_not_givenasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperto_streamed_response_wrapperasync_to_raw_response_wrapper"async_to_streamed_response_wrapper)StreamAsyncStream)task_group_create_paramstask_group_events_paramstask_group_add_runs_paramstask_group_get_runs_params)make_request_options)	TaskGroup)TaskSpecParam)ParallelBetaParam)BetaRunInputParam)TaskGroupRunResponse)TaskGroupEventsResponse)TaskGroupGetRunsResponseTaskGroupResourceAsyncTaskGroupResourcec            	          e Zd ZdZed1d            Zed2d            Zedddedd3dZ	dddedd4dZ
eedddedd5d!Zeeddded"d6d(Zeeeeddded)d7d0ZdS )8r.     
    The Task Group API is currently in beta and enables batch execution of many independent Task runs with group-level monitoring and failure handling.
     - Submit hundreds or thousands of Tasks as a single group
    - Observe group progress and receive results as they complete
    - Real-time updates via Server-Sent Events (SSE)
    - Add tasks to an existing group while it is running
    - Group-level retry and error aggregation
    Status: beta and subject to change.
    return TaskGroupResourceWithRawResponsec                     t          |           S a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/parallel-web/parallel-sdk-python#accessing-raw-response-data-eg-headers
        )r3   selfs    j/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/parallel/resources/beta/task_group.pywith_raw_responsez#TaskGroupResource.with_raw_response3   s     0555    &TaskGroupResourceWithStreamingResponsec                     t          |           S z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/parallel-web/parallel-sdk-python#with_streaming_response
        )r;   r6   s    r8   with_streaming_responsez)TaskGroupResource.with_streaming_response=   s     6d;;;r:   Nmetadataextra_headersextra_query
extra_bodytimeoutr@   3Optional[Dict[str, Union[str, float, bool]]] | OmitrA   Headers | NonerB   Query | NonerC   Body | NonerD   'float | httpx.Timeout | None | NotGivenr'   c          
         ddi|pi }|                      dt          d|it          j                  t	          ||||          t
                    S )  
        Initiates a TaskGroup to group and track multiple runs.

        Args:
          metadata: User-provided metadata stored with the task group.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        parallel-betasearch-extract-2025-10-10/v1beta/tasks/groupsr@   rA   rB   rC   rD   bodyoptionscast_to)_postr   r"   TaskGroupCreateParamsr&   r'   r7   r@   rA   rB   rC   rD   s         r8   createzTaskGroupResource.createF   sp    2 )*E_-J][]_zz" *h!79Q9ghh(+Q[el     
 
 	
r:   rO   task_group_idstrc          	         |st          d|          ddi|pi }|                     d| t          ||||          t                    S )k  
        Retrieves aggregated status across runs in a TaskGroup.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        <Expected a non-empty value for `task_group_id` but received rL   rM   /v1beta/tasks/groups/rO   rR   rS   
ValueError_getr&   r'   r7   rX   rA   rB   rC   rD   s         r8   retrievezTaskGroupResource.retrievei   s    .  	om\immnnn(*E_-J][]_yy3M33(+Q[el     
 
 	
r:   default_task_specbetasrA   rB   rC   rD   inputsIterable[BetaRunInputParam]re   Optional[TaskSpecParam] | Omitrf   List[ParallelBetaParam] | Omitr+   c          
        |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     d| dt          ||dt          j	                  t          ||||	          t          
          S )  
        Initiates multiple task runs within a TaskGroup.

        Args:
          inputs: List of task runs to execute. Up to 1,000 runs can be specified per request. If
              you'd like to add more runs, split them across multiple TaskGroup POST requests.

          default_task_spec: Specification for a task.

              Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
              Not specifying a TaskSpec is the same as setting an auto output schema.

              For convenience bare strings are also accepted as input or output schemas.

          betas: Optional header to specify the beta version(s) to enable.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        r\   rL   ,c              3  4   K   | ]}t          |          V  d S NrY   .0es     r8   	<genexpr>z-TaskGroupResource.add_runs.<locals>.<genexpr>   (      4K4KSVV4K4K4K4K4K4Kr:   rM   r]   /runsrg   re   rO   rP   )r`   r   r   joinr   r   rT   r   r$   TaskGroupAddRunsParamsr&   r+   	r7   rX   rg   re   rf   rA   rB   rC   rD   s	            r8   add_runszTaskGroupResource.add_runs   s   L  	om\immnnn	
#&#SXXe4K4KU4K4K4KNiMj.k.k%l%l%l" 	
 "	
 )*E_-J][]_zz8M888 $):  +A  )+Q[el   )  
 
 	
r:   last_event_idapi_timeoutrA   rB   rC   rD   r}   Optional[str] | Omitr~   Optional[float] | OmitStream[TaskGroupEventsResponse]c               0   |st          d|          ddi|pi }ddi|pi }|                     d| dt          ||||t          ||dt          j                  	          t          t          t                    d
t          t                             S )  
        Streams events from a TaskGroup: status updates and run completions.

        The connection will remain open for up to an hour as long as at least one run in
        the group is still active.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        r\   Accepttext/event-streamrL   rM   r]   /eventsr}   r~   rA   rB   rC   rD   queryTrR   rS   stream
stream_cls)
r`   ra   r&   r   r#   TaskGroupEventsParamsr
   r   r,   r    r7   rX   r}   r~   rA   rB   rC   rD   s           r8   eventszTaskGroupResource.events   s    8  	om\immnnn!#6P=;NBP(*E_-J][]_yy:M:::(+'%%)6'2  -B    ,  56'  
 
 	
r:   include_inputinclude_outputr}   statusrA   rB   rC   rD   r   bool | Omitr   r   rOptional[Literal['queued', 'action_required', 'running', 'completed', 'failed', 'cancelling', 'cancelled']] | Omit Stream[TaskGroupGetRunsResponse]c               4   |st          d|          ddi|pi }ddi|pi }|                     d| dt          ||||	t          ||||dt          j                  	          t          t          t                    d
t          t                             S )f  
        Retrieves task runs in a TaskGroup and optionally their inputs and outputs.

        All runs within a TaskGroup are returned as a stream. To get the inputs and/or
        outputs back in the stream, set the corresponding `include_input` and
        `include_output` parameters to `true`.

        The stream is resumable using the `event_id` as the cursor. To resume a stream,
        specify the `last_event_id` parameter with the `event_id` of the last event in
        the stream. The stream will resume from the next event after the
        `last_event_id`.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        r\   r   r   rL   rM   r]   rv   r   r   r}   r   r   Tr   )
r`   ra   r&   r   r%   TaskGroupGetRunsParamsr
   r   r-   r    
r7   rX   r   r   r}   r   rA   rB   rC   rD   s
             r8   get_runszTaskGroupResource.get_runs  s    N  	om\immnnn!#6P=;NBP(*E_-J][]_yy8M888(+'%%)6*8)6"(	  /E    -  67+  
 
 	
r:   )r2   r3   )r2   r;   r@   rE   rA   rF   rB   rG   rC   rH   rD   rI   r2   r'   rX   rY   rA   rF   rB   rG   rC   rH   rD   rI   r2   r'   rX   rY   rg   rh   re   ri   rf   rj   rA   rF   rB   rG   rC   rH   rD   rI   r2   r+   )rX   rY   r}   r   r~   r   rA   rF   rB   rG   rC   rH   rD   rI   r2   r   )rX   rY   r   r   r   r   r}   r   r   r   rA   rF   rB   rG   rC   rH   rD   rI   r2   r   __name__
__module____qualname____doc__r   r9   r>   r   r   rW   rc   r{   r   r    r:   r8   r.   r.   (   st         6 6 6 _6 < < < _< IM )-$("&;D!
 !
 !
 !
 !
 !
R )-$("&;D 
  
  
  
  
  
N =A04 )-$("&;D@
 @
 @
 @
 @
 @
L /3.2 )-$("&;D4
 4
 4
 4
 4
 4
t &*&*.2  )-$("&;D!A
 A
 A
 A
 A
 A
 A
 A
r:   c            	          e Zd ZdZed1d            Zed2d            Zedddedd3dZ	dddedd4dZ
eedddedd5d!Zeeddded"d6d(Zeeeeddded)d7d0ZdS )8r/   r1   r2   %AsyncTaskGroupResourceWithRawResponsec                     t          |           S r5   )r   r6   s    r8   r9   z(AsyncTaskGroupResource.with_raw_responseR  s     5T:::r:   +AsyncTaskGroupResourceWithStreamingResponsec                     t          |           S r=   )r   r6   s    r8   r>   z.AsyncTaskGroupResource.with_streaming_response\  s     ;4@@@r:   Nr?   r@   rE   rA   rF   rB   rG   rC   rH   rD   rI   r'   c          
        K   ddi|pi }|                      dt          d|it          j                   d{V t	          ||||          t
                     d{V S )rK   rL   rM   rN   r@   NrO   rP   )rT   r   r"   rU   r&   r'   rV   s         r8   rW   zAsyncTaskGroupResource.createe  s      2 )*E_-J][]_ZZ",j(-CE]Estttttttt(+Q[el      
 
 
 
 
 
 
 
 	
r:   rO   rX   rY   c          	        K   |st          d|          ddi|pi }|                     d| t          ||||          t                     d{V S )r[   r\   rL   rM   r]   rO   r^   Nr_   rb   s         r8   rc   zAsyncTaskGroupResource.retrieve  s      .  	om\immnnn(*E_-J][]_YY3M33(+Q[el     
 
 
 
 
 
 
 
 	
r:   rd   rg   rh   re   ri   rf   rj   r+   c          
       K   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     d| dt          ||dt          j	                   d	{V t          ||||
          t                     d	{V S )rl   r\   rL   rm   c              3  4   K   | ]}t          |          V  d S ro   rp   rq   s     r8   rt   z2AsyncTaskGroupResource.add_runs.<locals>.<genexpr>  ru   r:   rM   r]   rv   rw   NrO   rP   )r`   r   r   rx   r   r   rT   r   r$   ry   r&   r+   rz   s	            r8   r{   zAsyncTaskGroupResource.add_runs  s_     L  	om\immnnn	
#&#SXXe4K4KU4K4K4KNiMj.k.k%l%l%l" 	
 "	
 )*E_-J][]_ZZ8M888,$):  +A        )+Q[el   )   
 
 
 
 
 
 
 
 	
r:   r|   r}   r   r~   r   $AsyncStream[TaskGroupEventsResponse]c               L  K   |st          d|          ddi|pi }ddi|pi }|                     d| dt          ||||t          ||dt          j                   d	{V 
          t          t          t                    dt          t                              d	{V S )r   r\   r   r   rL   rM   r]   r   r   Nr   Tr   )
r`   ra   r&   r   r#   r   r
   r   r,   r!   r   s           r8   r   zAsyncTaskGroupResource.events  s     8  	om\immnnn!#6P=;NBP(*E_-J][]_YY:M:::(+'%1)6'2  -B          ,  "#:;'  
 
 
 
 
 
 
 
 	
r:   r   r   r   r   r   r   %AsyncStream[TaskGroupGetRunsResponse]c               P  K   |st          d|          ddi|pi }ddi|pi }|                     d| dt          ||||	t          ||||dt          j                   d	{V 
          t          t          t                    dt          t                              d	{V S )r   r\   r   r   rL   rM   r]   rv   r   Nr   Tr   )
r`   ra   r&   r   r%   r   r
   r   r-   r!   r   s
             r8   r   zAsyncTaskGroupResource.get_runs"  s&     N  	om\immnnn!#6P=;NBP(*E_-J][]_YY8M888(+'%1)6*8)6"(	  /E          -  "#;<+  
 
 
 
 
 
 
 
 	
r:   )r2   r   )r2   r   r   r   r   )rX   rY   r}   r   r~   r   rA   rF   rB   rG   rC   rH   rD   rI   r2   r   )rX   rY   r   r   r   r   r}   r   r   r   rA   rF   rB   rG   rC   rH   rD   rI   r2   r   r   r   r:   r8   r/   r/   G  sx         ; ; ; _; A A A _A IM )-$("&;D!
 !
 !
 !
 !
 !
R )-$("&;D 
  
  
  
  
  
N =A04 )-$("&;D@
 @
 @
 @
 @
 @
L /3.2 )-$("&;D4
 4
 4
 4
 4
 4
t &*&*.2  )-$("&;D!A
 A
 A
 A
 A
 A
 A
 A
r:   c                      e Zd ZddZdS )r3   
task_groupr.   r2   Nonec                   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S ro   )_task_groupr   rW   rc   r{   r   r   r7   r   s     r8   __init__z)TaskGroupResourceWithRawResponse.__init__g  s    %-
 
 0
 
 0
 
 .
 
 0
 
r:   Nr   r.   r2   r   r   r   r   r   r   r:   r8   r3   r3   f  (        
 
 
 
 
 
r:   r3   c                      e Zd ZddZdS )r   r   r/   r2   r   c                   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S ro   )r   r   rW   rc   r{   r   r   r   s     r8   r   z.AsyncTaskGroupResourceWithRawResponse.__init__|  s    %3
 
 6
 
 6
 
 4
 
 6
 
r:   Nr   r/   r2   r   r   r   r:   r8   r   r   {  r   r:   r   c                      e Zd ZddZdS )r;   r   r.   r2   r   c                   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S ro   )r   r   rW   rc   r{   r   r   r   s     r8   r   z/TaskGroupResourceWithStreamingResponse.__init__  s    %2
 
 5
 
 5
 
 3
 
 5
 
r:   Nr   r   r   r:   r8   r;   r;     r   r:   r;   c                      e Zd ZddZdS )r   r   r/   r2   r   c                   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S ro   )r   r   rW   rc   r{   r   r   r   s     r8   r   z4AsyncTaskGroupResourceWithStreamingResponse.__init__  s    %8
 
 ;
 
 ;
 
 9
 
 ;
 
r:   Nr   r   r   r:   r8   r   r     r   r:   r   )E
__future__r   typingr   r   r   r   r   r	   r
   	itertoolsr   typing_extensionsr   httpx_typesr   r   r   r   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   r   r   
_streamingr    r!   
types.betar"   r#   r$   r%   _base_clientr&   types.beta.task_groupr'   types.task_spec_paramr(   types.beta.parallel_beta_paramr)   types.beta.beta_run_input_paramr*   "types.beta.task_group_run_responser+   %types.beta.task_group_events_responser,   'types.beta.task_group_get_runs_responser-   __all__r.   r/   r3   r   r;   r   r   r:   r8   <module>r      s@   # " " " " " C C C C C C C C C C C C C C C C C C       % % % % % %  K K K K K K K K K K K K K K K K K K W W W W W W W W W W W W & & & & & & : : : : : : : :            . - - - - - - -            1 0 0 0 0 0 . . . . . . 2 2 2 2 2 2 ? ? ? ? ? ? @ @ @ @ @ @ F F F F F F L L L L L L O O O O O O 8
9\
 \
 \
 \
 \
 \
 \
 \
~\
 \
 \
 \
 \
- \
 \
 \
~
 
 
 
 
 
 
 
*
 
 
 
 
 
 
 
*
 
 
 
 
 
 
 
*
 
 
 
 
 
 
 
 
 
r:   