
    ]jI                        d dl Zd dlZd dlmZ ddlmZ ddlmZm	Z	 ddl
mZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ  ej6                  ej8                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)CancelModelRunResponse)ModelRun)ProjectSubsetEnum   )ListRunsRequestProjectSubset.c                      e Zd ZdefdZdddddddededej                  e   dej                  e   d	ej                  e   d
ej                  e	   dej                  e
   deej                  e      fdZeeeeeeeedd	deded	edej                  e   dej                  e   dej                  e   dej                  ej$                     d
ej                  e   dej                  e   dej                  e   dej                  e   dej                  e
   dee   fdZdddedededej                  e
   dee   f
dZy)RawRunsClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     R/root/env/lib/python3.12/site-packages/label_studio_sdk/prompts/runs/raw_client.py__init__zRawRunsClient.__init__   
    -    Norderingparent_modelprojectproject_subsetrequest_options	prompt_id
version_idr    r!   r"   r#   r$   returnc          	         | j                   j                  j                  dt        |       dt        |       dd||||d|      }	 d|j                  cxk  rdk  rin nft        j                  t
        j                  t           t        t
        j                  t           |j                         	            }	t        ||	
      S |j                         }
t        |j                  t        |j                        |
      # t        $ r6 t        |j                  t        |j                        |j                         w xY w)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get information (status, metadata, etc) about an existing inference run

        Parameters
        ----------
        prompt_id : int

        version_id : int

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

        parent_model : typing.Optional[int]
            The ID of the parent model for this Inference Run

        project : typing.Optional[int]
            The ID of the project this Inference Run makes predictions on

        project_subset : typing.Optional[ListRunsRequestProjectSubset]
            Defines which tasks are operated on (e.g. HasGT will only operate on tasks with a ground truth annotation, but All will operate on all records)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.List[ModelRun]]

        api/prompts/
/versions//inference-runsGETr    r!   r"   r#   methodparamsr$      ,  type_object_responsedatastatus_codeheadersbody)r   httpx_clientrequestr
   r:   typingcastListr   r   jsonr	   r   r   dictr;   textr   r%   r&   r    r!   r"   r#   r$   	_response_data_response_jsons              r   listzRawRunsClient.list   s*   \ ((55==+I67zBRS]B^A__no$ ,""0	 , > 

		ti++1c1KK)"$kk(3 ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   	A=D D ?E	job_idonly_missing_predictionsorganizationpredictions_updated_atr#   total_correct_predictionstotal_predictionstotal_tasksr$   rK   rL   rM   rN   rO   rP   rQ   c       
         ^   | j                   j                  j                  dt        |       dt        |       dd|||||||	|
|d	ddi|t              }	 d	|j
                  cxk  rd
k  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j
                  t        |j                        |      # t        $ r6 t        |j
                  t        |j                        |j                         w xY w)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Run a prompt inference.

        Parameters
        ----------
        prompt_id : int

        version_id : int

        project : int

        job_id : typing.Optional[str]
            Job ID for inference job for a ModelRun e.g. Adala job ID

        only_missing_predictions : typing.Optional[bool]
            When true, only tasks without successful predictions for this prompt version are submitted for inference.

        organization : typing.Optional[int]

        predictions_updated_at : typing.Optional[dt.datetime]

        project_subset : typing.Optional[ProjectSubsetEnum]

        total_correct_predictions : typing.Optional[int]

        total_predictions : typing.Optional[int]

        total_tasks : typing.Optional[int]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[ModelRun]

        r)   r*   r+   POST	rK   rL   rM   rN   r"   r#   rO   rP   rQ   content-typeapplication/jsonr/   rB   r;   r$   omitr1   r2   r3   r6   r9   )r   r=   r>   r
   OMITr:   r?   r@   r   r   rB   r	   r   r   rC   r;   rD   r   r%   r&   r"   rK   rL   rM   rN   r#   rO   rP   rQ   r$   rF   rG   rH   s                   r   createzRawRunsClient.createb   s7   v ((55==+I67zBRS]B^A__no ,D ,*@""0-F%6*
  2 ,% > 
	(	ti++1c1"& ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AC- 2C- -?D,r$   inference_run_idc          
      P   | j                   j                  j                  dt        |       dt        |       dt        |       dd|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                         	            }t        ||
      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)ag  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Cancel the inference run for the given api

        Parameters
        ----------
        prompt_id : int

        version_id : int

        inference_run_id : int

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[CancelModelRunResponse]

        r)   r*   /inference-runs//cancelrS   r/   r$   r1   r2   r3   r6   r9   )r   r=   r>   r
   r:   r?   r@   r   r   rB   r	   r   r   rC   r;   rD   r   r%   r&   r]   r$   rF   rG   rH   s           r   cancelzRawRunsClient.cancel   s+   B ((55==+I67zBRS]B^A__o  qA  BR  qS  pT  T[  \+ > 
	
	ti++1c1*"4 ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AC& +C& &?D%)__name__
__module____qualname__r   r   intr?   Optionalstrr   r   r	   rA   r   rI   rY   booldtdatetimer   r[   r   rc    r   r   r   r      s,   .*; . *.-1(,HL;?FpFp Fp
 //#&Fp ooc*Fp %Fp (DEFp  8Fp 
fkk(+	,Fp\ (,:>-1?C=A:>26,0;?\p\p \p
 \p $\p #)//$"7\p ooc*\p !' <\p (9:\p $*??3#7\p "??3/\p __S)\p  8\p 
h	\pH <@3p3p 3p 	3p  83p 
,	-3pr   r   c                      e Zd ZdefdZdddddddededej                  e   dej                  e   d	ej                  e   d
ej                  e	   dej                  e
   deej                  e      fdZeeeeeeeedd	deded	edej                  e   dej                  e   dej                  e   dej                  ej$                     d
ej                  e   dej                  e   dej                  e   dej                  e   dej                  e
   dee   fdZdddedededej                  e
   dee   f
dZy)AsyncRawRunsClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawRunsClient.__init__   r   r   Nr   r%   r&   r    r!   r"   r#   r$   r'   c          	        K   | j                   j                  j                  dt        |       dt        |       dd||||d|       d{   }	 d|j                  cxk  rd	k  rin nft        j                  t
        j                  t           t        t
        j                  t           |j                         
            }	t        ||	      S |j                         }
t        |j                  t        |j                        |
      7 # t        $ r6 t        |j                  t        |j                        |j                         w xY ww)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get information (status, metadata, etc) about an existing inference run

        Parameters
        ----------
        prompt_id : int

        version_id : int

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

        parent_model : typing.Optional[int]
            The ID of the parent model for this Inference Run

        project : typing.Optional[int]
            The ID of the project this Inference Run makes predictions on

        project_subset : typing.Optional[ListRunsRequestProjectSubset]
            Defines which tasks are operated on (e.g. HasGT will only operate on tasks with a ground truth annotation, but All will operate on all records)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.List[ModelRun]]

        r)   r*   r+   r,   r-   r.   Nr1   r2   r3   r6   r9   )r   r=   r>   r
   r:   r?   r@   rA   r   r   rB   r   r   r   rC   r;   rD   rE   s              r   rI   zAsyncRawRunsClient.list   s8    \ ..;;CC+I67zBRS]B^A__no$ ,""0	 , D 

 

		ti++1c1KK)"$kk(3 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo1

,  	ty'<'<d9K\K\F]dmdrdrss	ts7   AEDEA=D ED !,E?EErJ   rK   rL   rM   rN   rO   rP   rQ   c       
         z  K   | j                   j                  j                  dt        |       dt        |       dd|||||||	|
|d	ddi|t               d	{   }	 d
|j
                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j
                  t        |j                        |      7 # t        $ r6 t        |j
                  t        |j                        |j                         w xY ww)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Run a prompt inference.

        Parameters
        ----------
        prompt_id : int

        version_id : int

        project : int

        job_id : typing.Optional[str]
            Job ID for inference job for a ModelRun e.g. Adala job ID

        only_missing_predictions : typing.Optional[bool]
            When true, only tasks without successful predictions for this prompt version are submitted for inference.

        organization : typing.Optional[int]

        predictions_updated_at : typing.Optional[dt.datetime]

        project_subset : typing.Optional[ProjectSubsetEnum]

        total_correct_predictions : typing.Optional[int]

        total_predictions : typing.Optional[int]

        total_tasks : typing.Optional[int]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[ModelRun]

        r)   r*   r+   rS   rT   rU   rV   rW   Nr1   r2   r3   r6   r9   )r   r=   r>   r
   rY   r:   r?   r@   r   r   rB   r   r   r   rC   r;   rD   rZ   s                   r   r[   zAsyncRawRunsClient.createB  sF    v ..;;CC+I67zBRS]B^A__no ,D ,*@""0-F%6*
  2 ,% D 
 
	(	ti++1c1"& ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`nooC
>  	ty'<'<d9K\K\F]dmdrdrss	ts7   AD;C7D; AC9 ;D;<C9 ,D;9?D88D;r\   r]   c          
      l  K   | j                   j                  j                  dt        |       dt        |       dt        |       dd|       d{   }	 d|j                  cxk  rd	k  rGn nDt        j                  t        t        t        |j                         
            }t        ||      S |j                         }t        |j                  t        |j                        |      7 # t        $ r6 t        |j                  t        |j                        |j                        w xY ww)al  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Cancel the inference run for the given api

        Parameters
        ----------
        prompt_id : int

        version_id : int

        inference_run_id : int

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[CancelModelRunResponse]

        r)   r*   r_   r`   rS   ra   Nr1   r2   r3   r6   r9   )r   r=   r>   r
   r:   r?   r@   r   r   rB   r   r   r   rC   r;   rD   rb   s           r   rc   zAsyncRawRunsClient.cancel  s9    B ..;;CC+I67zBRS]B^A__o  qA  BR  qS  pT  T[  \+ D 
 
	
	ti++1c1*"4 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	ts7   AD4C0D4AC2 4D45C2 ,D42?D11D4)rd   re   rf   r   r   rg   r?   rh   ri   r   r   r   rA   r   rI   rY   rj   rk   rl   r   r[   r   rc   rm   r   r   ro   ro      s,   .*< . *.-1(,HL;?FpFp Fp
 //#&Fp ooc*Fp %Fp (DEFp  8Fp 
6;;x0	1Fp\ (,:>-1?C=A:>26,0;?\p\p \p
 \p $\p #)//$"7\p ooc*\p !' <\p (9:\p $*??3#7\p "??3/\p __S)\p  8\p 
8	$\pH <@3p3p 3p 	3p  83p 
1	23pr   ro   ) rl   rk   r?   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.jsonable_encoderr
   core.request_optionsr   core.unchecked_base_modelr   types.cancel_model_run_responser   types.model_runr   types.project_subset_enumr   &types.list_runs_request_project_subsetr   r@   AnyrY   r   ro   rm   r   r   <module>r      sc      ( & H A 5 2 7 E ' : P v{{6::s#]p ]p@]p ]pr   