
                            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 rS r\R"                  " \R$                  R&                  5      \R(                   " S S\R*                  5      5       5       r\R"                  " \R$                  R.                  \R$                  R0                  5      \R(                   " S S\5      5       5       rg)z$Vertex AI endpoints predict command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)endpoints_util)flags)region_utilc                 x    [         R                  " U S[        R                  S9  [         R                  " U 5        g )Nzto do online prediction)prompt_func)r   AddEndpointResourceArgr   PromptForOpRegionAddPredictInstanceArgparsers    #lib/surface/ai/endpoints/predict.py_AddArgsr      s/    //1 f%    c                 >   U R                   R                  R                  5       nUR                  5       S   U l        [
        R                  " XR                  SS9   [        R                  " US9n[        R                  " U R                  5      nU[        R                  :X  a  UR                  X$5      nOUR                  X$5      nU R!                  S5      (       d%  [        R"                  " UR$                  5      U l        UsSSS5        $ ! , (       d  f       g= f)z Run Vertex AI online prediction.locationsIdT)regionis_prediction)versionformatN)CONCEPTSendpointParseAsDictr   r	   AiplatformEndpointOverridesr   EndpointsClientr
   ReadInstancesFromArgsjson_requestr   
GA_VERSIONPredictPredictBetaIsSpecifiedGetDefaultFormatpredictionsr   )argsr   endpoint_refendpoints_clientinstances_jsonresultss         r   _Runr0   &   s    ''--/,##%m4$+00kk7--g>#99$:K:KLN)&&& ((Fg ,,\JgH%%"33G4G4GHdk7 7 7s   B(D
Dc                   .    \ rS rSrSr\S 5       rS rSrg)	PredictGa:     Run Vertex AI online prediction.

   `{command}` sends a prediction request to Vertex AI endpoint for the
   given instances. This command will read up to 100 instances, though the
   service itself will accept instances up to the payload limit size
   (currently, 1.5MB).

## EXAMPLES

To predict against an endpoint ``123'' under project ``example'' in region
``us-central1'', run:

  $ {command} 123 --project=example --region=us-central1
  --json-request=input.json
c                     [        U 5        g N)r   r   s    r   ArgsPredictGa.ArgsM   s
    Vr   c                 6    [        U[        R                  5      $ r6   )r0   r   r%   selfr+   s     r   RunPredictGa.RunQ   s    i**++r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr7   r<   __static_attributes__r>   r   r   r2   r2   :   s        ,r   r2   c                       \ rS rSrSrS rSrg)r'   U   r4   c                 6    [        U[        R                  5      $ r6   )r0   r   BETA_VERSIONr:   s     r   r<   PredictBeta.Runh   s    i,,--r   r>   N)r?   r@   rA   rB   rC   r<   rE   r>   r   r   r'   r'   U   s     .r   r'   N)rC   
__future__r   r   r   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   r   r0   ReleaseTracksReleaseTrackGAUniverseCompatibleCommandr2   BETAALPHAr'   r>   r   r   <module>rV      s    + &  ' 6 ( 3 7 8 / 5&( D%%((), ,  *,2 D%%**D,=,=,C,CD.) .  E.r   