
    O                        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S r\R&                  " \R(                  R*                  5       " S S\R,                  5      5       r\R&                  " \R(                  R0                  \R(                  R2                  5       " S S\R,                  5      5       rg)zai-platform predict command.    )absolute_import)division)unicode_literals)predict)base)endpoint_util)flags)predict_utilities)region_util)logd   c                 H   U R                  SSSS9  U R                  SSS9  U R                  SS9nUR                  S	S
S9  UR                  SSS9  UR                  SSS9  [        R                  " SS9R	                  U 5        [        R
                  R	                  U 5        g) Register flags for this command.z--modelTzName of the model.)requiredhelpz	--versionzModel version to be used.

If unspecified, the default version of the model will be used. To list model
versions run

  $ {parent_command} versions list
)r   )r   z--json-requesta,        Path to a local file containing the body of JSON request.

      An example of a JSON request:

          {
            "instances": [
              {"x": [1, 2], "y": [3, 4]},
              {"x": [-1, -2], "y": [-3, -4]}
            ]
          }

      This flag accepts "-" for stdin.
      z--json-instancesa<        Path to a local file from which instances are read.
      Instances are in JSON format; newline delimited.

      An example of the JSON instances file:

          {"images": [0.0, ..., 0.1], "key": 3}
          {"images": [0.0, ..., 0.1], "key": 2}
          ...

      This flag accepts "-" for stdin.
      z--text-instancesa&        Path to a local file from which instances are read.
      Instances are in UTF-8 encoded text format; newline delimited.

      An example of the text instances file:

          107,4.9,2.5,4.5,1.7
          100,5.7,2.8,4.1,1.3
          ...

      This flag accepts "-" for stdin.
      )include_globalN)add_argumentadd_mutually_exclusive_groupr	   GetRegionArgAddToParserSIGNATURE_NAME)parsergroups     "lib/surface/ai_platform/predict.py_AddPredictArgsr       s    i$5IJ  	 
-
-t
-
<%
    
   
   D)55f=""6*    c                    [         R                  " U R                  U R                  U R                  [
        S9n[        R                  " U 5      n[        R                  " US9   [         R                  " U R                  U R                  5      nU R                  cO  [         R                  " U R                  U R                  5      (       a  [        R                   R#                  S5        [$        R&                  " X1U R                  S9nSSS5        U R)                  S5      (       d*  [         R*                  " WR-                  S5      5      U l        W$ ! , (       d  f       NP= f)zThis is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  A json object that contains predictions.
)limit)regionNzYou are running on a runtime version >= 1.8. If the signature defined in the model is not serving_default then you must specify it via --signature-name flag, otherwise the command may fail.)signature_nameformatpredictions)r
   ReadInstancesFromArgsjson_requestjson_instancestext_instancesINPUT_INSTANCES_LIMITr   	GetRegionr   MlEndpointOverridesParseModelOrVersionRefmodelversionr    CheckRuntimeVersionr   statusPrintr   PredictIsSpecifiedGetDefaultFormatgetr!   )args	instancesr   model_or_version_refresultss        r   _Runr8   _   s     55


!	#)   &&((7,CC

DLL"#--djj$,,GG	jjCD
 oo8K8KMG 8 
		(	#	##44M"$DK 
.% 87s   $B'E
E#c                   .    \ rS rSrSr\S 5       rS rSrg)r0      }  Run AI Platform online prediction.

`{command}` sends a prediction request to AI Platform 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). If you are predicting on more instances, you should use batch
prediction via

    $ {parent_command} jobs submit prediction.
c                     [        U 5        gr   Nr   r   s    r   ArgsPredict.Args        Fr   c                     [        U5      $ Nr8   selfr4   s     r   RunPredict.Run       :r    N	__name__
__module____qualname____firstlineno____doc__staticmethodr@   rH   __static_attributes__rK   r   r   r0   r0           	  r   r0   c                   .    \ rS rSrSr\S 5       rS rSrg)PredictBeta   r;   c                     [        U 5        gr=   r>   r?   s    r   r@   PredictBeta.Args   rB   r   c                     [        U5      $ rD   rE   rF   s     r   rH   PredictBeta.Run   rJ   r   rK   NrL   rK   r   r   rV   rV      rT   r   rV   N)rQ   
__future__r   r   r    googlecloudsdk.api_lib.ml_enginer   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml_enginer   r	   r
   r   googlecloudsdk.corer   r'   r   r8   ReleaseTracksReleaseTrackGACommandr0   ALPHABETArV   rK   r   r   <module>rg      s    # &  ' 4 ( > 6 B < # <+~#L D%%(()dll  ** D%%++T->->-C-CD$,,  Er   