
                         &   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rSS0r\R                   " \R"                  R$                  \R"                  R&                  5       " S S\R(                  5      5       rg)zai-platform explain command.    )absolute_import)division)unicode_literals)predict)base)endpoint_util)flags)predict_utilities)region_utild   EXAMPLESz        To get explanations for an AI Platform version model with the
        version 'version' and with the name 'model-name', run:

          $ {command} explain --model=model-name --version=version           --json-instances=instances.json
        c                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)Explain)   zRun AI Platform explanation.

`{command}` sends an explain 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).
c                 
   U R                  SSSS9  [        R                  " SS9R                  U 5        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  g)z Register flags for this command.z--modelTzName of the model.)requiredhelp)include_globalz	--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-instancesaL          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-instancesa6          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	   GetRegionArgAddToParseradd_mutually_exclusive_group)parsergroups     "lib/surface/ai_platform/explain.pyArgsExplain.Args5   s     	D7KL	d+77?
  	 ///>E	    
   
      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[        R                  " XB5      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:
  Some value that we want to have printed later.
)limit)regionNformatpredictions)r
   ReadInstancesFromArgsjson_requestjson_instancestext_instancesINPUT_INSTANCES_LIMITr   	GetRegionr   MlEndpointOverridesParseModelOrVersionRefmodelversionr   r   IsSpecifiedGetDefaultFormatgetr"   )selfargs	instancesr!   model_or_version_refresultss         r   RunExplain.Runr   s     "77#	%I ""4(F		*	*&	9.EE
**dll$ 4@g 
:
 H%%%66
++m
$&dk N 
:	9s   $AC00
C> N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helpstaticmethodr   r6   __static_attributes__r8   r   r   r   r   )   s&      -: :xr   r   N)r=   
__future__r   r   r    googlecloudsdk.api_lib.ml_enginer   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml_enginer   r	   r
   r   r(   r>   ReleaseTracksReleaseTrackALPHABETACommandr   r8   r   r   <module>rK      s    # &  ' 4 ( > 6 B < 		 D%%++T->->-C-CDcdll c Ecr   