
                             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
 Z G d dej                        ZddiZee_        y)z"ai-platform local predict command.    )absolute_import)division)unicode_literals)base)flags)local_utils)predict_utilities)logc                 R   | j                  ddd       t        j                  j                  j	                  |        | j                  d      }|j                  dd       |j                  d	d
       |j                  dd       t        j                  j	                  |        y)z=Add arguments for `gcloud ai-platform local predict` command.z--model-dirTzPath to the model.)requiredhelp)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.
      )r   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.
      N)add_argumentr   FRAMEWORK_MAPPER
choice_argAddToParseradd_mutually_exclusive_groupSIGNATURE_NAME)parsergroups     (lib/surface/ai_platform/local/predict.py_AddLocalPredictArgsr      s    md9MN##//7

-
-t
-
<%
    
   
   ""6*    c                   &    e Zd ZdZed        Zd Zy)PredictzRun prediction locally.c                     t        |        y )N)r   )r   s    r   ArgszPredict.ArgsS   s
     r   c                 "   t         j                  j                  |j                        }|r|j                  j                         nd}|j                  t        j                  j                  d       t        j                  |j                  |j                  |j                  |j                  ||j                        }|j!                  d      s>t#        |t$              r|}n|j'                  d      }t)        j*                  |      |_        |S )N
tensorflowzIf the signature defined in the model is not serving_default then you must specify it via --signature-name flag, otherwise the command may fail.)json_requestjson_instancestext_instances	frameworksignature_nameformatpredictions)r   r   GetEnumForChoicer"   namelowerr#   r
   statusPrintr   
RunPredict	model_dirr   r    r!   IsSpecified
isinstancelistgetr	   GetDefaultFormatr$   )selfargsr"   framework_flagresultsr%   s         r   RunzPredict.RunW   s    &&77GI/8Y^^))+lN"	jj P Q $$&&**** **,G H%	GT	"kk-0%66{CdkNr   N)__name__
__module____qualname____doc__staticmethodr   r6    r   r   r   r   P   s    ! !r   r   DESCRIPTIONa'  *{command}* performs prediction locally with the given instances. It requires the
[TensorFlow SDK](https://www.tensorflow.org/install) be installed locally. The
output format mirrors `gcloud ai-platform predict` (online prediction).

You cannot use this command with custom prediction routines.
N)r:   
__future__r   r   r   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml_enginer   r   r	   googlecloudsdk.corer
   r   Commandr   _DETAILED_HELPdetailed_helpr<   r   r   <module>rE      sT    ) &  ' ( 6 < B #1+hdll D 		 ' r   