
    B                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SSK	Jr  SS	K	Jr  SS
K	Jr  SSK	Jr  SSK	Jr  SSKJr  S rS r\R*                  " \R,                  R.                  5      \R0                   " S S\R2                  5      5       5       r\R*                  " \R,                  R6                  \R,                  R8                  5      \R0                   " S S\5      5       5       rg)z)Vertex AI endpoints deploy-model command.    )encoding)
operations)client)base)	constants)endpoint_util)endpoints_util)flags)operations_util)region_util)
validation)logc                    [         R                  " S5      R                  U 5        [         R                  " 5       R                  U 5        [         R                  " X5        [         R
                  " X5        [         R                  " 5       R                  U 5        [         R                  " 5       R                  U 5        [         R                  " S5      R                  U 5        [         R                  " 5       R                  U 5        [         R                  " X5        [         R                  " U S[        R                  S9  U[        R                  :w  a  [         R                   " U S5        gg)z*Prepares for the arguments of the command.zdeployed modelzdeployed-modelzto deploy a model to)prompt_funczto co-host a model onN)r
   GetDisplayNameArgAddToParserGetTrafficSplitArgAddPredictionResourcesArgsAddScaleToZeroArgsGetEnableAccessLoggingArgGetServiceAccountArgGetUserSpecifiedIdArgGetAutoscalingMetricSpecsArgAddModelIdArgAddEndpointResourceArgr   PromptForOpRegionr   
GA_VERSIONAddSharedResourcesArg)parserversions     (lib/surface/ai/endpoints/deploy_model.py_AddArgsr"       s   *+77?((0""636+!!#//7**62./;;FC$$&226:g&//1 	$$$	! %    c                 	   [         R                  " U R                  5        [         R                  " U R                  5        [         R
                  " U R                  U R                  5        [         R                  " U R                  5        U R                  R                  R                  5       nUR                  5       S   U l        [        R                   " XR                  S9   ["        R$                  " US9n[&        R(                  " 5       nU[*        R,                  :X  a  UR/                  UU R0                  U R                  U R                  U R2                  U R4                  U R                  U R6                  U R                  U R8                  U R                  U R:                  U R<                  U R>                  U R@                  U RB                  U RD                  U R                  S9nGOU R                  RF                  R                  5       n[         RH                  " UU R2                  U R4                  U R                  U R6                  U R                  U R                  S9  [         RJ                  " U R                  U RL                  U R6                  U RN                  U RP                  5        URS                  UU R0                  U R                  U R                  U R2                  U RT                  U RV                  U R4                  U R                  U R6                  U R                  U R8                  U R                  U R:                  U R<                  U RX                  U R@                  U RB                  U RD                  UU RN                  U RP                  U RL                  U R                  U RZ                  S9n[\        R^                  " XE[`        Rb                  " URd                  5      5      nUbk  [f        Rh                  " U5      nSU;   aO  S	US   ;   aF  [j        Rl                  Ro                  S
Rq                  UR                  5       S   US   S	   5      5        UsSSS5        $ ! , (       d  f       g= f)z1Deploy a model to an existing Vertex AI endpoint.locationsId)region)r    )machine_typeaccelerator_dictmin_replica_countmax_replica_countrequired_replica_countreservation_affinityautoscaling_metric_specsspotenable_access_loggingdisable_container_loggingservice_accounttraffic_splitdeployed_model_idgpu_partition_size)shared_resources_refr'   r(   r)   r*   r+   r-   )r'   tpu_topologymultihost_gpu_node_countr(   r)   r*   r+   r,   r-   r.   r/   enable_container_loggingr1   r2   r3   r5   min_scaleup_periodidle_scaledown_periodinitial_replica_countr4   min_gpu_driver_versionNdeployedModelidzBDeployed a model to the endpoint {}. Id of the deployed model: {}.endpointsId)9r   ValidateDisplayNamedisplay_nameValidateAutoscalingMetricSpecsr-   ValidateRequiredReplicaCountr+   r)   ValidateGpuPartitionSizer4   CONCEPTSendpointParseAsDictr&   r   AiplatformEndpointOverridesr   EndpointsClientr   OperationsClientr   r   DeployModelmodelr'   acceleratorr*   r,   r.   r/   r0   r1   r2   r3   shared_resourcesValidateSharedResourceArgsValidateScaleToZeroArgsr;   r9   r:   DeployModelBetar6   r7   r8   r<   r   WaitForOpMayber	   ParseOperationnamer   MessageToPyValuer   statusPrintformat)	argsr    endpoint_refendpoints_clientoperation_clientopr5   response_msgresponses	            r!   _Runra   5   s     !2!23++D,I,IJ))$*E*E*.*@*@B%%d&=&=>''--/,##%m4$+00M--g>!224)&&&''

**
++


((++ 22 22!%!<!<#88#'#@#@yy $ : :$($B$B..** 22!44% ( b* "]];;AAC++3((++ 22 22!%!<!<#'#@#@B ((

 
 

$
$d&<&<

!
!4#=#=
 ++

**
++


((((#'#@#@++ 22 22!%!<!<#88#'#@#@yy $ : :#'#@#@..** 223!44 $ : : $ : :!44!%!<!<3 , >b4 #11n;;BGGDFL**<8h	H	$/1J)J

 :;A6*113MB&7=<?	@ U NMMs   &NQ11
Q?c                   .    \ rS rSrSr\S 5       rS rSrg)DeployModelGa     Deploy a model to an existing Vertex AI endpoint.

## EXAMPLES

To deploy a model ``456'' to an endpoint ``123'' under project ``example'' in
region ``us-central1'', run:

  $ {command} 123 --project=example --region=us-central1 --model=456
  --display-name=my_deployed_model
c                     [        U [        R                  5        [        R                  " 5       R                  U 5        g N)r"   r   r   r
   GetDisableContainerLoggingArgr   r   s    r!   ArgsDeployModelGa.Args   s)    VY))*	'')55f=r#   c                 8    [        U[        R                  5        g rg   )ra   r   r   selfrZ   s     r!   RunDeployModelGa.Run   s    y##$r#    N	__name__
__module____qualname____firstlineno____doc__staticmethodrj   ro   __static_attributes__rq   r#   r!   rc   rc      s     	 > >%r#   rc   c                   .    \ rS rSrSr\S 5       rS rSrg)rR      re   c                     [        U [        R                  5        [        R                  " 5       R                  U 5        g rg   )r"   r   BETA_VERSIONr
   GetEnableContainerLoggingArgr   ri   s    r!   rj   DeployModelBeta.Args   s)    VY++,	&&(44V<r#   c                 8    [        U[        R                  5        g rg   )ra   r   r}   rm   s     r!   ro   DeployModelBeta.Run   s    y%%&r#   rq   Nrr   rq   r#   r!   rR   rR      s     	 = ='r#   rR   N)rw   apitools.base.pyr   googlecloudsdk.api_lib.air   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r   r	   r
   r   r   r   googlecloudsdk.corer   r"   ra   ReleaseTracksReleaseTrackGAUniverseCompatibleCommandrc   BETAALPHArR   rq   r#   r!   <module>r      s    0 & 0 6 ( 3 7 8 / 9 5 4 #!*Sl D%%(()%DLL %  *%* D%%**D,=,=,C,CD'm '  E'r#   