
    ; i                        d dl mZ d dl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dd
ZddddZddddZ G d dej                  ZdddZdS )    )annotationsN)Iterator)protos)client)model_types)	operationreturn#Iterator[CreateTunedModelOperation]c                x      t          j                      fd                     dd          D             }|S )z$Calls the API to list all operationsNc              3  N   K   | ]}t                               |          V   d S N)CreateTunedModelOperation
from_proto).0opr   s     v/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/google/generativeai/operations.py	<genexpr>z"list_operations.<locals>.<genexpr>%   sG         	",,R88          )namefilter_)
client_libget_default_operations_clientlist_operations)r   
operationss   ` r   r   r      s[     ~9;;   ((b"(==  J
 r   r   strr   c                   |t          j                    }|                    |           }t                              ||          S )z)Calls the API to get a specific operationNr   )r   r   get_operationr   r   )r   r   r   s      r   r   r   -   sA    ~9;;			4		(	(B$//F;;;r   c               X    |t          j                    }|                    |           S )z,Calls the API to delete a specific operationNr   )r   r   delete_operation)r   r   s     r   r!   r!   6   s.     ~9;;"""---r   c                  t     e Zd Zed             Zedd            Zedd            Zd Zdd
Z	d fdZ
 xZS )r   c                \    t          t          ||t          j        t          j                  S )z
        result = getattr(proto, 'result', None)
        if result is not None:
            if result.value == b'':
                del proto.result
        )clsr   operations_clientresult_typemetadata_type)
from_gapicr   r   
TunedModelCreateTunedModelMetadata)r$   protor   s      r   r   z$CreateTunedModelOperation.from_protoA   s0     )$) 9
 
 
 	
r   r   operation_lib.Operationc           	         t          |dd           }t          |dd           }|d|i}n	|d|i}ni } | d|j        |j        |j        |j        |j        d|S )N_polling_retrypollingretry)r   refreshcancelr&   r'    )getattr
_operation_refresh_cancel_result_type_metadata_type)r$   r   r0   r1   kwargss        r   from_core_operationz-CreateTunedModelOperation.from_core_operationR   s    
 )Z66	8T22)FFu%FFFs 
*&$!.#2
 
 
 
 	
r   r	   r   c                    | j         j        S r   )r6   r   selfs    r   r   zCreateTunedModelOperation.namej   s    ##r   c                .    |                                   dS )z5Refresh the current statuses in metadata/result/errorN)_refresh_and_updater>   s    r   updatez CreateTunedModelOperation.updaten   s      """""r   )Iterator[protos.CreateTunedModelMetadata]c              +  z  K   t          j         d| j        j        dd|}|                                 sF| j        }|                    | j        j        |j        z
             |V  |                                 F| j        }|                    | j        j        |j        z
             |                                 S )zA tqdm wait bar, yields `Operation` statuses until complete.

        Args:
            **kwargs: passed through to `tqdm.auto.tqdm(..., **kwargs)`

        Yields:
            Operation statuses as `protos.CreateTunedModelMetadata` objects.
        r   )totalinitialr4   )tqdmmetadatatotal_stepsdonerB   completed_stepsnresult)r?   r;   barrH   s       r   wait_barz"CreateTunedModelOperation.wait_barr   s       iMdm7MMfMM ))++ 	}HJJt}4su<===NNN ))++ 	 =

4=0358999{{}}r   rM   protos.TunedModelc                r    t          j        |          }t                                          |           d S r   )r   decode_tuned_modelsuper
set_result)r?   rM   	__class__s     r   rT   z$CreateTunedModelOperation.set_result   s1    /776"""""r   )r   r,   )r	   r   )r	   rC   )rM   rP   )__name__
__module____qualname__classmethodr   r<   propertyr   rB   rO   rT   __classcell__)rU   s   @r   r   r   @   s        
 
 [
  
 
 
 [
. $ $ $ X$# # #   (# # # # # # # # # #r   )grpc_metadatac                   t          j        |j        |j        |          }t          j        |j        |j        |          } | |||||fi |S )zD`google.api_core.operation.from_gapic`, patched to allow subclasses.)rH   )	functoolspartialr   r   cancel_operation)	r$   r   r%   r&   r'   r\   r;   r2   r3   s	            r   r(   r(      sp     '-  G *  F
 3y'6;PPPPPr   )r	   r
   )r   r   r	   r   )r   r   )
__future__r   r^   typingr   google.generativeair   r   r   google.generativeai.typesr   google.api_corer   operation_lib	tqdm.autoautorG   r   r   r!   	Operationr   r(   r4   r   r   <module>rj      s_   # " " " " "           & & & & & & 4 4 4 4 4 4 1 1 1 1 1 1 6 6 6 6 6 6       #        (, < < < < < < +/ . . . . . .H# H# H# H# H# 7 H# H# H#d Q Q Q Q Q Q Qr   