
                            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	 rS
 r\R                  \R                  " \R                  R                   5       " S S\R"                  5      5       5       r\R                  \R                  " \R                  R&                  \R                  R(                  5       " S S\5      5       5       rg)z+Vertex AI endpoints direct predict command.    )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 direct prediction)prompt_func)r   AddEndpointResourceArgr	   PromptForOpRegionAddDirectPredictInputsArgparsers    *lib/surface/ai/endpoints/direct_predict.py_AddArgsr      s/    &//
 !!&)    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$                  SS9U l        UsSSS5        $ ! , (       d  f       g= f)	z'Run Vertex AI online direct prediction.locationsIdT)regionis_prediction)versionformatoutputs)key_nameN)CONCEPTSendpointParseAsDictr   r   AiplatformEndpointOverridesr   EndpointsClientr   ReadInputsFromArgsjson_requestr   
GA_VERSIONDirectPredictDirectPredictBetaIsSpecifiedGetDefaultFormatr   r   )argsr   endpoint_refendpoints_clientinputs_jsonresultss         r   _Runr.   $   s    ''--/,##%m4$+00kk --g> 33D4E4EFK)&&& ..|Ig 22<MgH%%"33
//Idk !  s   B'D
Dc                   .    \ rS rSrSr\S 5       rS rSrg)DirectPredictGa;   s  Run Vertex AI online direct prediction.

   `{command}` sends a direct prediction request to Vertex AI endpoint for the
   given instances. The request limit is 10MB.

## EXAMPLES

To direct 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DirectPredictGa.ArgsL   s
    Vr   c                 6    [        U[        R                  5      $ r4   )r.   r   r$   selfr)   s     r   RunDirectPredictGa.RunP   s    i**++r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr5   r:   __static_attributes__r<   r   r   r0   r0   ;   s       ,r   r0   c                       \ rS rSrSrS rSrg)r&   T   r2   c                 6    [        U[        R                  5      $ r4   )r.   r   BETA_VERSIONr8   s     r   r:   DirectPredictBeta.Rune   s    i,,--r   r<   N)r=   r>   r?   r@   rA   r:   rC   r<   r   r   r&   r&   T   s    .r   r&   N)rA   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r   r   r   r	   r   r.   UniverseCompatibleReleaseTracksReleaseTrackGACommandr0   BETAALPHAr&   r<   r   r   <module>rS      s    2 7 ( 3 7 8 / 5*. D%%((),dll , * ,. D%%**D,=,=,C,CD. . E .r   