
    _                        d 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 dd
l	mZ ddl	mZ d Zd Zej"                   ej$                  ej&                  j(                         G d dej*                                      Zej"                   ej$                  ej&                  j.                  ej&                  j0                         G d de                    Zy)z+Vertex AI endpoints direct predict command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)endpoints_util)flags)region_utilc                 z    t        j                  | dt        j                         t        j                  |        y )Nzto do online direct prediction)prompt_func)r   AddEndpointResourceArgr   PromptForOpRegionAddDirectPredictInputsArgparsers    *lib/surface/ai/endpoints/direct_predict.py_AddArgsr      s/    &//
 !!&)    c                 6   | j                   j                  j                         }|j                         d   | _        t        j                  || j                  d      5  t        j                  |      }t        j                  | j                        }|t        j                  k(  r|j                  ||      }n|j                  ||      }| j!                  d      s&t        j"                  |j$                  d      | _        |cddd       S # 1 sw Y   yxY w)	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   _Runr1   '   s    ''--/,##%m4$+00dkk --g> 33D4E4EFK)&&& ..|[Ig 22<MgH%"33
//Idk !  s   B&DDc                   &    e Zd ZdZed        Zd Zy)DirectPredictGa  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                     t        |        y N)r   r   s    r   ArgszDirectPredictGa.ArgsO   s
    Vr   c                 6    t        |t        j                        S r6   )r1   r   r'   selfr,   s     r   RunzDirectPredictGa.RunS   s    i**++r   N)__name__
__module____qualname____doc__staticmethodr7   r;    r   r   r3   r3   >   s       ,r   r3   c                       e Zd ZdZd Zy)r)   r4   c                 6    t        |t        j                        S r6   )r1   r   BETA_VERSIONr9   s     r   r;   zDirectPredictBeta.Runh   s    i,,--r   N)r<   r=   r>   r?   r;   rA   r   r   r)   r)   W   s    .r   r)   N)r?   
__future__r   r   r   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   r   r1   DefaultUniverseOnlyReleaseTracksReleaseTrackGACommandr3   BETAALPHAr)   rA   r   r   <module>rP      s    2 &  ' 6 ( 3 7 8 / 5*. D%%((),dll , * ,. D%%**D,=,=,C,CD. . E .r   