
    ci6             	          d dl Z d dlZd dlZd dlZd dlmZ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 d	dlmZ  ej,                  d      Z	 ddeeeef   ef   deeeef      deeef   fdZ	 ddeeeef   ef   deeeef      deeef   fdZ	 ddeeeef   ef   deeeef      deeef   fdZ	 ddeeeef   ef   deeeef      deeef   fdZ	 ddeeeef   ef   deeeef      deeef   fdZ	 ddeeeef   ef   deeeef      deeef   fdZ 	 ddeeeef   ef   deeeef      deeef   fdZ!	 ddeeeef   ef   deeeef      deeef   fdZ"	 ddeeeef   ef   deeeef      deeef   fdZ# G d dejH                        Z% G d dejH                        Z&y)    N)AnyOptionalUnion)	urlencode)_api_module)_common)types)get_value_by_path)set_value_by_path   )_datasets_utilszvertexai_genai.datasetsfrom_objectparent_objectreturnc                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             |S )Nname_urlgemini_request_read_configgeminiRequestReadConfigconfiggetvsetvr   r   	to_objects      ?/tmp/pip-target-z3e9_cxr/lib/python/vertexai/_genai/datasets.py$_AssembleDatasetParameters_to_vertexr   &   s     !#IK&".Y(${VH*EFK678D&';<=	
 K($0Y
Dxj$AB    c                 "   i }t        | dg      t        |ddgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | d	g      	 t        |d
gt        | d	g             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             |S )Nr   r   r   r   'tuning_resource_usage_assessment_config#tuningResourceUsageAssessmentConfig#tuning_validation_assessment_config tuningValidationAssessmentConfig1batch_prediction_resource_usage_assessment_config,batchPredictionResourceUsageAssessmentConfig-batch_prediction_validation_assessment_config)batchPredictionValidationAssessmentConfigr   r   r   s      r   "_AssessDatasetParameters_to_vertexr(   ;   s_    !#IK&".Y(${VH*EFK678D&';<=	
 KCDEQ23HIJ	
 K?@AM/0DEF	
 	[NOP	 	;<RST	
 KIJKW89NOP	
 K($0Y
Dxj$ABr   c                    i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |d	gt        | dg             t        | d
g      t        |d
gt        | d
g             |S )Nr   display_namedisplayNamemetadata_schema_urimetadataSchemaUrimetadatadescriptionencryption_specencryptionSpecr   r   r   s      r   ,_CreateMultimodalDatasetParameters_to_vertexr2   o   s,    !#IK&".Y${VH"=>K.)*6YkN;K)LMK/01=+,d;AV@W.X	
 K*&2Yd;&EFK-)5YkM?)KLK+,-9Y)*D?P>Q,RSK($0Y
Dxj$ABr   c                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |dgt        | dg             |S Nr   r   r   r   r   s      r   3_DeleteMultimodalDatasetRequestParameters_to_vertexr5      ^     !#IK&".Y(${VH*EFK($0Y
Dxj$ABr   c                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |ddgt        | dg             t        | dg      t        |dgt        | dg             |S )N
dataset_idr   operation_idr   r   r   s      r   2_GetMultimodalDatasetOperationParameters_to_vertexr:      s     !#IK,(4Y.[<.0QRK.)*6Y0${^DT2UVK($0Y
Dxj$ABr   c                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |dgt        | dg             |S r4   r   r   s      r   )_GetMultimodalDatasetParameters_to_vertexr<      r6   r   c                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |ddgt        | dg             t        | dg      t        |ddgt        | dg             |S )N	page_size_querypageSize
page_token	pageTokenfilterr   r   s      r   '_ListMultimodalDatasetsConfig_to_vertexrD      s     !#IK+'3]Xz2D{m4TUK,(4]X{3T+~5VWK($0]Xx0${XJ2OPr   c           
      j    i }t        | dg      #t        |dgt        t        | dg      |             |S )Nr   )r   r   rD   r   s      r   2_ListMultimodalDatasetsRequestParameters_to_vertexrF      sF     !#IK($0J3[8*-y	
 r   c                    i }t        | dg      t        |ddgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | d	g      t        |d	gt        | d	g             |S )
Nr   r   r*   r+   r.   r/   r0   r1   r   r   r   s      r   ,_UpdateMultimodalDatasetParameters_to_vertexrH      s     !#IK&".Y(${VH*EFK.)*6YkN;K)LMK*&2Yd;&EFK-)5YkM?)KLK+,-9Y)*D?P>Q,RSK($0Y
Dxj$ABr   c                   *   e Zd Zddddedeej                     deej                     dej                  fdZ	ddddddddedeej                     d	eej                     d
eej                     deej                     deej                     deej                     dej                  fdZdddddddddee   dee   dee   deej                      dee   deej$                     deej&                     dej                  fdZdddedeej*                     dej                  fdZddddee   deej*                     dej.                  fdZdddddee   dee   deej2                     dej                  fdZdddeej6                     dej8                  fdZddddddddee   dee   deej                      dee   deej$                     deej<                     dej.                  fdZd ej                  d!e de!ee"f   fd"Z#ddd#ejH                  deej&                     dej.                  fd$Z%ddd#ejH                  deej&                     dej.                  fd%Z&dddedeej&                     dej.                  fd&Z'dddedeej&                     dej                  fd'Z(ddd(ded)eejR                     deej                     defd*Z*ddd(d+ed,ed)eejR                     deej                     dejV                  f
d-Z,y).DatasetsNr   r   r   r   r   r   c                8   t        j                  |||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}	|j                  ,|j                  j                  |j                  j                  }	t        j                  |      }t        j                  |      }| j                  j                  d	|||	      }
|
j                   si nt#        j$                  |
j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S z:
        Assembles a multimodal dataset resource.
        r   r   r   6This method is only supported in the Vertex AI client.r   zdatasets/{name}:assembler?   ?r   Npostresponsekwargs)r	   _AssembleDatasetParameters_api_clientvertexai
ValueErrorr   get
format_mapr   popr   http_optionsr   convert_to_dictencode_unserializable_typesrequestbodyjsonloadsMultimodalDatasetOperation_from_response
model_dump_verify_responseselfr   r   r   parameter_modelrequest_dictrequest_url_dictpathquery_paramsr\   rS   response_dictreturn_values                r   _assemble_multimodal_datasetz%Datasets._assemble_multimodal_dataset   sw     ::'A
 ((UVV?PL+//71<<=MN1#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++FD,U"*--TZZ5N77FF"?+E+E+G G 
 	)),7r   r   r    r"   r$   r&   r   r    r"   r$   r&   c          	      @   t        j                  |||||||      }| j                  j                  st	        d      t        |      }	|	j                  d      }
|
rdj                  |
      }nd}|	j                  d      }|r| dt        |       }|	j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |	      }	t        j                  |	      }	| j                  j                  d	||	|      }|j                   si nt#        j$                  |j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S z9
        Assesses a multimodal dataset resource.
        )r   r   r    r"   r$   r&   r   rO   r   zdatasets/{name}:assessr?   rP   r   NrQ   rR   )r	   _AssessDatasetParametersrV   rW   rX   r(   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rh   r   r   r    r"   r$   r&   r   ri   rj   rk   rl   rm   r\   rS   rn   ro   s                    r   _assess_multimodal_datasetz#Datasets._assess_multimodal_dataset3  s   2  88'A4[0S>o:g
 ((UVV=oNL+//7/::;KL/#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++FD,U"*--TZZ5N77FF"?+E+E+G G 
 	)),7r   r   r*   r,   r.   r/   r0   r   r*   r,   r.   r/   r0   c          	      @   t        j                  |||||||      }| j                  j                  st	        d      t        |      }	|	j                  d      }
|
rdj                  |
      }nd}|	j                  d      }|r| dt        |       }|	j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |	      }	t        j                  |	      }	| j                  j                  d	||	|      }|j                   si nt#        j$                  |j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S zJ
        Creates a dataset resource to store multimodal datasets.
        rw   rO   r   datasetsr?   rP   r   NrQ   rR   )r	   "_CreateMultimodalDatasetParametersrV   rW   rX   r2   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rh   r   r*   r,   r.   r/   r0   r   ri   rj   rk   rl   rm   r\   rS   rn   ro   s                    r   _create_multimodal_datasetz#Datasets._create_multimodal_dataset|  s     BB% 3#+
 ((UVVGXL+//7!,,-=>!#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++FD,U"*--TZZ5N77FF"?+E+E+G G 
 	)),7r   r   c                6   t        j                  ||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|||      }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         
      }| j                  j-                  |       |S z8
        Deletes a multimodal dataset resource.
        r   r   rO   r   datasets/{name}r?   rP   r   NdeleterR   )r	   )_DeleteMultimodalDatasetRequestParametersrV   rW   rX   r5   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rh   r   r   ri   rj   rk   rl   rm   r\   rS   rn   ro   s               r   _delete_multimodal_datasetz#Datasets._delete_multimodal_dataset  sy     II
 ((UVVNL  ,//7(334DE(#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++HdL,W"*--TZZ5N77FF"?+E+E+G G 
 	)),7r   r   c                6   t        j                  ||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|||      }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         
      }| j                  j-                  |       |S z5
        Gets a multimodal dataset resource.
        r   rO   r   r   r?   rP   r   NrY   rR   )r	   _GetMultimodalDatasetParametersrV   rW   rX   r<   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   MultimodalDatasetrd   re   rf   r   s               r   _get_multimodal_datasetz Datasets._get_multimodal_dataset  ss     ??
 ((UVVD_UL+//7(334DE(#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++E4|T"*--TZZ5N..=="?+E+E+G > 
 	)),7r   r8   r9   r   r8   r9   c                8   t        j                  |||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}	|j                  ,|j                  j                  |j                  j                  }	t        j                  |      }t        j                  |      }| j                  j                  d	|||	      }
|
j                   si nt#        j$                  |
j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S zH
        Gets the operation from creating a multimodal dataset.
        r   rO   r   z/datasets/{dataset_id}/operations/{operation_id}r?   rP   r   NrY   rR   )r	   (_GetMultimodalDatasetOperationParametersrV   rW   rX   r:   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rh   r8   r9   r   ri   rj   rk   rl   rm   r\   rS   rn   ro   s                r   !_get_multimodal_dataset_operationz*Datasets._get_multimodal_dataset_operation$  s     HH!%
 ((UVVML  ,//7HSS$ I#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++E4|T"*--TZZ5N77FF"?+E+E+G G 
 	)),7r   c                4   t        j                  |      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|||      }|j                   si nt#        j$                  |j                         }	t         j&                  j)                  |	|j+                         
      }
| j                  j-                  |
       |
S z,
        Lists multimodal datasets.
        r~   rO   r   rz   r?   rP   r   NrY   rR   )r	   (_ListMultimodalDatasetsRequestParametersrV   rW   rX   rF   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   ListMultimodalDatasetsResponserd   re   rf   rh   r   ri   rj   rk   rl   rm   r\   rS   rn   ro   s              r   _list_multimodal_datasetsz"Datasets._list_multimodal_datasets_  sv     HH

 ((UVVML  ,//7!,,-=>!#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++E4|T"*--TZZ5N;;JJ"?+E+E+G K 
 	)),7r   r   r*   r.   r/   r0   r   c                >   t        j                  ||||||      }| j                  j                  st	        d      t        |      }|j                  d      }	|	rdj                  |	      }
nd}
|j                  d      }|r|
 dt        |       }
|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|
||      }|j                   si nt#        j$                  |j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S z8
        Updates a multimodal dataset resource.
        r   rO   r   r   r?   rP   r   NpatchrR   )r	   "_UpdateMultimodalDatasetParametersrV   rW   rX   rH   rY   rZ   r   r[   r   r\   r   r]   r^   r_   r`   ra   rb   r   rd   re   rf   rh   r   r*   r.   r/   r0   r   ri   rj   rk   rl   rm   r\   rS   rn   ro   s                   r   _update_multimodal_datasetz#Datasets._update_multimodal_dataset  s     BB%#+
 ((UVVGXL+//7(334DE(#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H##++GT<V"*--TZZ5N..=="?+E+E+G > 
 	)),7r   	operationtimeout_secondsc                    |j                   }|t        d      |j                  d      d   j                  d      d   }|j                  d      d   }t        j                         }d}d}d	}	t        j                         |z
  |k  r_| j	                  ||
      }|j
                  rnNt        j                  |       t        ||z  |	      }t        j                         |z
  |k  r_t        d| d      |r|j                  <t        j                  d|j                   d       t        d|j                   d      t        |d      r$|j                  t        d|j                         |j                  S )a  Waits for a multimodal or assemble dataset operation to complete.

        Args:
          operation: The multimodal or assemble dataset operation to wait for.
          timeout_seconds: The maximum time in seconds to wait for the operation
          to complete.

        Returns:
            A dict containing the operation response.

        Raises:
          TimeoutError: If the operation does not complete within the timeout.
          ValueError: If the operation fails.
         Dataset operation name is empty.
/datasets/r   /r         <   r8   r9   ?The operation did not complete within the specified timeout of 	 seconds.Error running the operation .error)r   rX   splittimer   donesleepminTimeoutErrorrS   loggerr   hasattr
rh   r   r   response_operation_namer8   r9   
start_timesleep_duration_secondswait_multipliermax_wait_time_secondss
             r   _wait_for_operationzDatasets._wait_for_operation  s   & #,.."*?@@,22<@CII#NqQ
.44S9"=YY[
!" "yy{Z'?:>>%) ? I ~~JJ-.%(&8:O&" yy{Z'?: ))8(9D  I..6LL7	8J8J7K1MN;I<N<N;OqQRR9g&9??+F;IOO;LMNN!!!r   multimodal_datasetc                   t        |t              rt        j                  di |}t	        |d      r|j
                  t        d      t	        |j
                  d      r|j
                  j                  t        d      t	        |j
                  j                  d      r |j
                  j                  j                  t        d      t	        |j
                  j                  j                  d      r*|j
                  j                  j                  j                  t        d      |j
                  j                  j                  j                  j                  d	      sPd	|j
                  j                  j                  j                   |j
                  j                  j                  _	        t        |t              rt        j                  di |}n|st        j                         }| j                  ||j                  t        j                  |j
                  
      }| j!                  ||j"                        }t        j$                  t        j                  |      S )  Creates a multimodal dataset from a BigQuery table.

        Args:
          multimodal_dataset:
            Required. A representation of a multimodal dataset.
          config:
            Optional. A configuration for creating the multimodal dataset. If not
            provided, the default configuration will be used.

        Returns:
          A types.MultimodalDataset object representing a multimodal dataset.
        r.   (Multimodal dataset metadata is required.input_config,Multimodal dataset input config is required.bigquery_source<Multimodal dataset input config bigquery source is required.uri@Multimodal dataset input config bigquery source uri is required.bq://r   r*   r,   r.   r   r    
isinstancedictr	   r   r   r.   rX   r   r   r   
startswithCreateMultimodalDatasetConfigr}   r*   r   METADATA_SCHEMA_URIr   timeoutcreate_from_responserh   r   r   multimodal_dataset_operationrS   s        r   create_from_bigqueryzDatasets.create_from_bigquery  s   $ ($/!&!8!8!N;M!N*J7!**2GHH*33^D!**77?KLL*33@@BST!**77GGON  *33@@PPRWX!**77GGKKSR  "**77GGKKVV
 *33@@PPTTUV ''44DDH fd#88B6BF88:F'+'F'F+88 / C C'00	 (G (
$ ++2"NN , 
 33E4K4KXVVr   c                Z   t        |t              rt        j                  di |}t	        |d      r|j
                  t        d      t	        |j
                  d      r|j
                  j                  t        d      t	        |j
                  j                  d      r |j
                  j                  j                  t        d      t	        |j
                  j                  j                  d      r*|j
                  j                  j                  j                  t        d      |j
                  j                  j                  j                  j                  d	      sPd	|j
                  j                  j                  j                   |j
                  j                  j                  _	        t        |t              rt        j                  di |}n|st        j                         }| j                  ||j                  |j                  |j                  |j
                  
      S )a  Updates a multimodal dataset.

        Updatable fields include:
        - display_name
        - description

        Args:
          multimodal_dataset:
            Required. A representation of a multimodal dataset.
          config:
            Optional. A configuration for updating the multimodal dataset. If not
            provided, the default configuration will be used.

        Returns:
          A types.MultimodalDataset object representing the retrieved multimodal
          dataset.
        r.   r   r   r   r   r   r   r   r   r   r   r*   r/   r.   r   r   r   r	   r   r   r.   rX   r   r   r   r   r   r   r   r*   r/   rh   r   r   s      r   update_multimodal_datasetz"Datasets.update_multimodal_datasetG  s   . ($/!&!8!8!N;M!N*J7!**2GHH*33^D!**77?KLL*33@@BST!**77GGON  *33@@PPRWX!**77GGKKSR  "**77GGKKVV
 *33@@PPTTUV ''44DDH fd#88B6BF88:F..#((+88*66'00 / 
 	
r   c                    t        |t              rt        j                  di |}n|st        j                         }| j	                  ||      S )a  Gets a multimodal dataset.

        Args:
          name:
            Required. name of a multimodal dataset.
          config:
            Optional. A configuration for getting the multimodal dataset. If not
            provided, the default configuration will be used.

        Returns:
          A types.MultimodalDataset object representing the retrieved multimodal
          dataset.
        r   r   r   r   r   r	   r   r   rh   r   r   s      r   get_multimodal_datasetzDatasets.get_multimodal_dataset  sH    & fd#88B6BF88:F++6+EEr   c                    t        |t              rt        j                  di |}n|st        j                         }| j	                  ||      S )  Deletes a multimodal dataset.

        Args:
          name:
            Required. name of a multimodal dataset.
          config:
            Optional. A configuration for deleting the multimodal dataset. If not
            provided, the default configuration will be used.

        Returns:
          A types.MultimodalDatasetOperation object representing the delete
          multimodal dataset operation.
        r   r   r   r   r	   r   r   r   s      r   delete_multimodal_datasetz"Datasets.delete_multimodal_dataset  sH    & fd#88B6BF88:F..f4.HHr   template_configr   r   c                    t        |t              rt        j                  di |}n|st        j                         }| j	                  |d|i|      }| j                  ||j                        }|d   S )  Assemble the dataset into a BigQuery table.

        Waits for the assemble operation to complete before returning.

        Args:
          name:
            Required. The name of the dataset to assemble. The name should be in
            the format of "projects/{project}/locations/{location}/datasets/{dataset}".
          template_config:
            Optional. The template config to use to assemble the dataset. If
            not provided, the template config attached to the dataset will be
            used.
          config:
            Optional. A configuration for assembling the dataset. If not
            provided, the default configuration will be used.

        Returns:
            The URI of the bigquery table of the assembled dataset.
        r   rN   r   bigqueryDestinationr   r   r   r	   AssembleDatasetConfigrp   r   r   rh   r   r   r   r   rS   s         r   assemblezDatasets.assemble  s    4 fd#00:6:F002F55!?(  6 
	 ++"NN , 
 -..r   dataset_name
model_namec                |   t        |t              rt        j                  di |}n|st        j                         }| j	                  |t        j
                  |      t        j                  |      |      }| j                  ||j                        }t        j                  t        j                  |d         S )  Assess the tuning resources required for a given model.

        Args:
          dataset_name:
            Required. The name of the dataset to assess the tuning resources
            for.
          model_name:
            Required. The name of the model to assess the tuning resources
            for.
          template_config:
            Optional. The template config used to assemble the dataset
            before assessing the tuning resources. If not provided, the
            template config attached to the dataset will be used. Required
            if no template config is attached to the dataset.
          config:
            Optional. A configuration for assessing the tuning resources. If not
            provided, the default configuration will be used.

        Returns:
          A types.TuningResourceUsageAssessmentResult object representing the
          tuning resource usage assessment result.
        r   r   r   r    r   r   r   #tuningResourceUsageAssessmentResultr   r   r   r	   AssessDatasetConfigrv   #TuningResourceUsageAssessmentConfigGeminiRequestReadConfigr   r   r   r   #TuningResourceUsageAssessmentResultrh   r   r   r   r   r   rS   s          r   assess_tuning_resourcesz Datasets.assess_tuning_resources  s    < fd#..88F..0F33494]4]%5 (-'D'D /(  4 	
	 ++"NN , 
 3355:;
 	
r   -__name__
__module____qualname__strr   r	   GeminiRequestReadConfigOrDictAssembleDatasetConfigOrDictrc   rp   )TuningResourceUsageAssessmentConfigOrDict&TuningValidationAssessmentConfigOrDict2BatchPredictionResourceUsageAssessmentConfigOrDict/BatchPredictionValidationAssessmentConfigOrDictAssessDatasetConfigOrDictrv   !SchemaTablesDatasetMetadataOrDictgenai_typesEncryptionSpecOrDict#CreateMultimodalDatasetConfigOrDictr}   VertexBaseConfigOrDictr   r   r   )GetMultimodalDatasetOperationConfigOrDictr   "ListMultimodalDatasetsConfigOrDictr   r   #UpdateMultimodalDatasetConfigOrDictr   intr   r   r   MultimodalDatasetOrDictr   r   r   r   GeminiTemplateConfigOrDictr   r   r   r   r   r   rJ   rJ      sB    >B7 7 %-//%
	7 ::;7 
	)	)7~     <@'G G %-//%
	G 2:;;2
G .688.
G <DDD<
G  8@AA8
!G& 889'G( 
	)	))GX #&*-1FJ%)FJFJ= sm= sm	=
 &c]= 5BBC= c]= "+"B"BC= BBC= 
	)	)=@ NR22$,U-I-I$J2		)	)2n #9=	3 sm3 556	3
 
	 	 3p %)&*LP9 SM9 sm	9
 HHI9 
	)	)9x OS1!%"J"JK1		-	-1l #&*FJ%)FJFJ; sm; sm	;
 5BBC; c]; "+"B"BC; BBC; 
	 	 ;z3"333" 3" 
c3h	3"r GK	AW "99AW BBC	AW
 
	 	 AWN GK	B
 "99B
 BBC	B

 
	 	 B
P GK	F F BBC	F
 
	 	 F< GK	I I BBC	I
 
	)	)I< GK>B*/ */ "%"B"BC	*/
 ::;*/ 
*/b GK<@4
 4
 	4

 "%"B"BC4
 8894
 
	2	24
r   rJ   c                   *   e Zd Zddddedeej                     deej                     dej                  fdZ	ddddddddedeej                     d	eej                     d
eej                     deej                     deej                     deej                     dej                  fdZdddddddddee   dee   dee   deej                      dee   deej$                     deej&                     dej                  fdZdddedeej*                     dej                  fdZddddee   deej*                     dej.                  fdZdddddee   dee   deej2                     dej                  fdZdddeej6                     dej8                  fdZddddddddee   dee   deej                      dee   deej$                     deej<                     dej.                  fdZd ej                  d!e de!ee"f   fd"Z#ddd#ejH                  deej&                     dej.                  fd$Z%ddd#ejH                  deej&                     dej.                  fd%Z&dddedeej&                     dej.                  fd&Z'dddedeej&                     dej                  fd'Z(ddd(ded)eejR                     deej                     defd*Z*ddd(d+ed,ed)eejR                     deej                     dejV                  f
d-Z,y).AsyncDatasetsNrK   r   r   r   r   c                T  K   t        j                  |||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}	|j                  ,|j                  j                  |j                  j                  }	t        j                  |      }t        j                  |      }| j                  j                  d	|||	       d{   }
|
j                   si nt#        j$                  |
j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S 7 }wrM   )r	   rU   rV   rW   rX   r   rY   rZ   r   r[   r   r\   r   r]   r^   async_requestr`   ra   rb   rc   rd   re   rf   rg   s                r   rp   z*AsyncDatasets._assemble_multimodal_dataset$  s      ::'A
 ((UVV?PL+//71<<=MN1#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))77D,
 
 #+--TZZ5N77FF"?+E+E+G G 
 	)),7
   D&F((F&)A>F(rq   r    r"   r$   r&   c          	      \  K   t        j                  |||||||      }| j                  j                  st	        d      t        |      }	|	j                  d      }
|
rdj                  |
      }nd}|	j                  d      }|r| dt        |       }|	j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |	      }	t        j                  |	      }	| j                  j                  d	||	|       d{   }|j                   si nt#        j$                  |j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S 7 }wrs   )r	   rt   rV   rW   rX   r(   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   rc   rd   re   rf   ru   s                    r   rv   z(AsyncDatasets._assess_multimodal_dataset_  s    2  88'A4[0S>o:g
 ((UVV=oNL+//7/::;KL/#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))77D,
 
 #+--TZZ5N77FF"?+E+E+G G 
 	)),7
   D*F,,F*-A>F,rw   r*   r,   r.   r/   r0   c          	      \  K   t        j                  |||||||      }| j                  j                  st	        d      t        |      }	|	j                  d      }
|
rdj                  |
      }nd}|	j                  d      }|r| dt        |       }|	j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |	      }	t        j                  |	      }	| j                  j                  d	||	|       d{   }|j                   si nt#        j$                  |j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S 7 }wry   )r	   r{   rV   rW   rX   r2   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   rc   rd   re   rf   r|   s                    r   r}   z(AsyncDatasets._create_multimodal_dataset  s      BB% 3#+
 ((UVVGXL+//7!,,-=>!#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))77D,
 
 #+--TZZ5N77FF"?+E+E+G G 
 	)),7
r  r~   c                R  K   t        j                  ||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|||       d{   }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         
      }| j                  j-                  |       |S 7 }wr   )r	   r   rV   rW   rX   r5   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   rc   rd   re   rf   r   s               r   r   z(AsyncDatasets._delete_multimodal_dataset  s      II
 ((UVVNL  ,//7(334DE(#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))77dL,
 
 #+--TZZ5N77FF"?+E+E+G G 
 	)),7
   D%F''F%(A>F'r   c                R  K   t        j                  ||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|||       d{   }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         
      }| j                  j-                  |       |S 7 }wr   )r	   r   rV   rW   rX   r<   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   r   rd   re   rf   r   s               r   r   z%AsyncDatasets._get_multimodal_dataset!  s      ??
 ((UVVD_UL+//7(334DE(#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))774|
 
 #+--TZZ5N..=="?+E+E+G > 
 	)),7
r  r   r8   r9   c                T  K   t        j                  |||      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}	|j                  ,|j                  j                  |j                  j                  }	t        j                  |      }t        j                  |      }| j                  j                  d	|||	       d{   }
|
j                   si nt#        j$                  |
j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S 7 }wr   )r	   r   rV   rW   rX   r:   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   rc   rd   re   rf   r   s                r   r   z/AsyncDatasets._get_multimodal_dataset_operationX  s      HH!%
 ((UVVML  ,//7HSS$ I#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))774|
 
 #+--TZZ5N77FF"?+E+E+G G 
 	)),7
r  c                P  K   t        j                  |      }| j                  j                  st	        d      t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|||       d{   }|j                   si nt#        j$                  |j                         }	t         j&                  j)                  |	|j+                         
      }
| j                  j-                  |
       |
S 7 }wr   )r	   r   rV   rW   rX   rF   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   r   rd   re   rf   r   s              r   r   z'AsyncDatasets._list_multimodal_datasets  s      HH

 ((UVVML  ,//7!,,-=>!#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))774|
 
 #+--TZZ5N;;JJ"?+E+E+G K 
 	)),7
s   D$F&&F$'A>F&r   c                Z  K   t        j                  ||||||      }| j                  j                  st	        d      t        |      }|j                  d      }	|	rdj                  |	      }
nd}
|j                  d      }|r|
 dt        |       }
|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d	|
||       d{   }|j                   si nt#        j$                  |j                         }t         j&                  j)                  ||j+                         
      }| j                  j-                  |       |S 7 }wr   )r	   r   rV   rW   rX   rH   rY   rZ   r   r[   r   r\   r   r]   r^   r  r`   ra   rb   r   rd   re   rf   r   s                   r   r   z(AsyncDatasets._update_multimodal_dataset  s      BB%#+
 ((UVVGXL+//7(334DE(#''1V1Y|456D4(48"".&&33?*11>>L..|<::<H))77T<
 
 #+--TZZ5N..=="?+E+E+G > 
 	)),7
s   D)F++F),A>F+r   r   c                 (  K   |j                   }|t        d      |j                  d      d   j                  d      d   }|j                  d      d   }t        j                         }d}d	}d
}	t        j                         |z
  |k  ro| j	                  ||       d{   }|j
                  rnVt        j                  |       d{    t        ||z  |	      }t        j                         |z
  |k  rot        d| d      |r|j                  <t        j                  d|j                   d       t        d|j                   d      t        |d      r$|j                  t        d|j                         |j                  S 7 7 ŭw)a  Waits for a multimodal dataset operation to complete.

        Args:
          operation: The multimodal dataset operation to wait for.
          timeout_seconds: The maximum time in seconds to wait for the operation
          to complete.

        Returns:
            A dict containing the operation response.

        Raises:
          TimeoutError: If the operation does not complete within the timeout.
          ValueError: If the operation fails.
        Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   rX   r   r   r   r   asyncior   r   r   rS   r   r   r   r   s
             r   r   z!AsyncDatasets._wait_for_operation	  s    & #,.."*?@@,22<@CII#NqQ
.44S9"=YY[
!" "yy{Z'?:"DD%) E  I ~~-- 6777%(&8:O&" yy{Z'?: ))8(9D  I..6LL7	8J8J7K1MN;I<N<N;OqQRR9g&9??+F;IOO;LMNN!!!) 8s+   BF F!)F
F-F9BFFr   c                  K   t        |t              rt        j                  di |}t	        |d      r|j
                  t        d      t	        |j
                  d      r|j
                  j                  t        d      t	        |j
                  j                  d      r |j
                  j                  j                  t        d      t	        |j
                  j                  j                  d      r*|j
                  j                  j                  j                  t        d	      |j
                  j                  j                  j                  j                  d
      sPd
|j
                  j                  j                  j                   |j
                  j                  j                  _	        t        |t              rt        j                  di |}n|st        j                         }| j                  ||j                  t        j                  |j
                         d{   }| j!                  ||j"                         d{   }t        j$                  t        j                  |      S 7 M7 *w)r   r.   Nr   r   r   r   r   r   r   r   r   r   r   r   r   s        r   r   z"AsyncDatasets.create_from_bigquery>  s)    $ ($/!&!8!8!N;M!N*J7!**2GHH*33^D!**77?KLL*33@@BST!**77GGON  *33@@PPRWX!**77GGKKSR  "**77GGKKVV
 *33@@PPTTUV ''44DDH fd#88B6BF88:F-1-L-L+88 / C C'00	 .M .
 (
$ 112"NN 2 
 
 33E4K4KXVV(

s$   H)I=+I9,$I=I;)I=;I=c                v  K   t        |t              rt        j                  di |}t	        |d      r|j
                  t        d      t	        |j
                  d      r|j
                  j                  t        d      t	        |j
                  j                  d      r |j
                  j                  j                  t        d      t	        |j
                  j                  j                  d      r*|j
                  j                  j                  j                  t        d	      |j
                  j                  j                  j                  j                  d
      sPd
|j
                  j                  j                  j                   |j
                  j                  j                  _	        t        |t              rt        j                  di |}n|st        j                         }| j                  ||j                  |j                  |j                  |j
                         d{   S 7 w)a  Updates a multimodal dataset.

        Args:
          multimodal_dataset:
            Required. A representation of a multimodal dataset.
          config:
            Optional. A configuration for updating the multimodal dataset. If not
            provided, the default configuration will be used.

        Returns:
          A types.MultimodalDataset object representing the updated multimodal
          dataset.
        r.   Nr   r   r   r   r   r   r   r   r   r   r   r   s      r   r   z'AsyncDatasets.update_multimodal_dataset  s    & ($/!&!8!8!N;M!N*J7!**2GHH*33^D!**77?KLL*33@@BST!**77GGON  *33@@PPRWX!**77GGKKSR  "**77GGKKVV
 *33@@PPTTUV ''44DDH fd#88B6BF88:F44#((+88*66'00 5 
 
 	
 
s   H0H92H73H9c                   K   t        |t              rt        j                  di |}n|st        j                         }| j	                  ||       d{   S 7 w)a  Gets a multimodal dataset.

        Args:
          name:
            Required. name of a multimodal dataset.
          config:
            Optional. A configuration for getting the multimodal dataset. If not
            provided, the default configuration will be used.

        Returns:
          A types.MultimodalDataset object representing the updated multimodal
          dataset.
        r   Nr   r   r   s      r   r   z$AsyncDatasets.get_multimodal_dataset  sR     & fd#88B6BF88:F11d1KKKK   AAAAc                   K   t        |t              rt        j                  di |}n|st        j                         }| j	                  ||       d{   S 7 w)r   r   Nr   r   r   s      r   r   z'AsyncDatasets.delete_multimodal_dataset  sR     & fd#88B6BF88:F44F4NNNNr'  r   r   c                  K   t        |t              rt        j                  di |}n|st        j                         }| j	                  |d|i|       d{   }| j                  ||j                         d{   }|d   S 7 .7 w)r   r   rN   Nr   r   r   r   r   s         r   r   zAsyncDatasets.assemble  s     4 fd#00:6:F002F;;!?(  < 
 
	 11"NN 2 
 
 -..

s$   ABB$B=B	>
B	Br   r   c                  K   t        |t              rt        j                  di |}n|st        j                         }| j	                  |t        j
                  |      t        j                  |      |       d{   }| j                  ||j                         d{   }t        j                  t        j                  |d         S 7 P7 -w)r   r   r   r   Nr   r   r   r   r   s          r   r   z%AsyncDatasets.assess_tuning_resources!  s     < fd#..88F..0F99494]4]%5 (-'D'D /(  : 	
 	
	 11"NN 2 
 
 3355:;
 	
	

s$   A=C?C $C$C%,CCr   r   r   r   r  r  "  s>    >B9 9 %-//%
	9 ::;9 
	)	)9B     <@'I I %-//%
	I 2:;;2
I .688.
I <DDD<
I  8@AA8
!I& 889'I( 
	)	))I\ #&*-1FJ%)FJFJ? sm? sm	?
 &c]? 5BBC? c]? "+"B"BC? BBC? 
	)	)?D NR44$,U-I-I$J4		)	)4r #9=	5 sm5 556	5
 
	 	 5t %)&*LP; SM; sm	;
 HHI; 
	)	);| OS3!%"J"JK3		-	-3p #&*FJ%)FJFJ= sm= sm	=
 5BBC= c]= "+"B"BC= BBC= 
	 	 =~3"333" 3" 
c3h	3"r GK	AW "99AW BBC	AW
 
	 	 AWN GK	>
 "99>
 BBC	>

 
	 	 >
H GK	L L BBC	L
 
	 	 L< GK	O O BBC	O
 
	)	)O< GK>B*/ */ "%"B"BC	*/
 ::;*/ 
*/b GK<@4
 4
 	4

 "%"B"BC4
 8894
 
	2	24
r   r  )N)'r#  ra   loggingr   typingr   r   r   urllib.parser   google.genair   r   r	   r
  google.genai._commonr
   r   r   r    r   	getLoggerr   r   r  objectr   r(   r2   r5   r:   r<   rD   rF   rH   
BaseModulerJ   r  r   r   r   <module>r4     s  $     ' ' " $   - : :   
		4	5
 /3tCH~v-.DcN+ 
#s(^. /31tCH~v-.1DcN+1 
#s(^1l /3tCH~v-.DcN+ 
#s(^B /3tCH~v-.DcN+ 
#s(^  /3tCH~v-.DcN+ 
#s(^& /3tCH~v-.DcN+ 
#s(^  /3tCH~v-.DcN+ 
#s(^( /3tCH~v-.DcN+ 
#s(^& /3tCH~v-.DcN+ 
#s(^4g
{%% g
Ts
K** s
r   