
                            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 r\	R"                  " \	R$                  R&                  \	R$                  R(                  5       " S S\	R*                  5      5       r\	R"                  " \	R$                  R.                  5       " S S\	R*                  5      5       rg)z1ai-platform jobs submit batch prediction command.    )absolute_import)division)unicode_literals)jobs)arg_parsers)base)flags)	jobs_util)labels_utilc                    [         R                  " SS9nUR                  [         R                  " SSS[        R
                  " SS9SS95        UR                  [        R                  " 5       R                  5        UR                  U 5        g	)
z%Add arguments for accelerator config.zAccelerator Configuration.helpz--accelerator-countT   )lower_boundzCThe number of accelerators to attach to the machines. Must be >= 1.)requireddefaulttyper   N)
r   ArgumentGroupAddArgumentArgumentr   
BoundedIntr
   AcceleratorFlagMap
choice_argAddToParser)parseraccelerator_config_groups     1lib/surface/ai_platform/jobs/submit/prediction.py_AddAcceleratorFlagsr      s}    !//') &&t}}!!a0(   &&""$//1&&v.    c                    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  U R                  S[        R                  " SS9SSSS9  [        R
                  " 5       R                  R                  U 5        U R                  SSSS9  U R                  SSSS9  U R                  SS[        SS9  U R                  SS[        SS9  [        R                  R                  U 5        [        R                  R                  U 5        [        R                  " U 5        g)z3Add arguments for `jobs submit prediction` command.jobz!Name of the batch prediction job.r   T)r   z--model-dirz9Cloud Storage location where the model files are located.z--modelz(Name of the model to use for prediction.z	--versionzModel version to be used.

This flag may only be given if --model is specified. If unspecified, the default
version of the model will be used. To list versions for a model, run

    $ gcloud ai-platform versions list
z--input-pathsr   )
min_length
INPUT_PATHa)  Cloud Storage paths to the instances to run prediction on.

Wildcards (```*```) accepted at the *end* of a path. More than one path can be
specified if multiple file patterns are needed. For example,

  gs://my-bucket/instances*,gs://my-bucket/other-instances1

will match any objects whose names start with `instances` in `my-bucket` as well
as the `other-instances1` bucket, while

  gs://my-bucket/instance-dir/*

will match any objects in the `instance-dir` "directory" (since directories
aren't a first-class Cloud Storage concept) of `my-bucket`.
)r   r   metavarr   z--output-pathzOCloud Storage path to which to save the output. Example: gs://my-bucket/output.)r   r   z--regionz,The Compute Engine region to run the job in.z--max-worker-countFzbThe maximum number of workers to be used for parallel processing. Defaults to 10 if not specified.)r   r   r   z--batch-sizezThe number of records per batch. The service will buffer batch_size number of records in memory before invoking TensorFlow. Defaults to 64 if not specified.N)add_argumentadd_mutually_exclusive_groupr   ArgListr
   DataFormatFlagMapr   r   intr	   SIGNATURE_NAMERUNTIME_VERSIONr   AddCreateLabelsFlags)r   model_groups     r   _AddSubmitPredictionArgsr.   .   s   e"EF33T3B++  - @  B  	 	!,  * **66v>(  ) 	9  ; 	/	  1 	0	  2 ""6*##F+""6*r   c                   .    \ rS rSrSr\S 5       rS rSrg)
Predictiont   *Start an AI Platform batch prediction job.c                 l    [        U 5        U R                  R                  [        R                  5        g N)r.   display_info	AddFormatr
   
JOB_FORMATr   s    r   ArgsPrediction.Argsy   s$    V$
!!)"6"67r   c                    [         R                  " 5       R                  UR                  5      n[        R
                  " 5       n[         R                  " X15      n[         R                  " X1R                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                   UR"                  UR$                  UR&                  US9$ )N)	model_dirmodelversioninput_pathsdata_formatoutput_pathregionruntime_versionmax_worker_count
batch_sizesignature_namelabels)r
   r(   GetEnumForChoicer@   r   
JobsClientParseCreateLabelsSubmitPredictionr!   r<   r=   r>   r?   namerA   rB   rC   rD   rE   rF   selfargsr@   jobs_clientrG   s        r   RunPrediction.Run~   s    --/@@K//#K((;F%%XX..jj$$$$$${{,,..??** r    N	__name__
__module____qualname____firstlineno____doc__staticmethodr9   rQ   __static_attributes__rS   r   r   r0   r0   t   s     38 8r   r0   c                   .    \ rS rSrSr\S 5       rS rSrg)PredictionAlpha   r2   c                     [        U 5        [        U 5        U R                  R                  [        R
                  5        g r4   )r.   r   r5   r6   r
   r7   r8   s    r   r9   PredictionAlpha.Args   s,    V$ 
!!)"6"67r   c                    [         R                  " 5       R                  UR                  5      n[        R
                  " 5       n[         R                  " X15      n[         R                  " X1R                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                   UR"                  UR$                  UR&                  UUR(                  UR*                  S9$ )N)r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   accelerator_typeaccelerator_count)r
   r(   rH   r@   r   rI   rJ   rK   r!   r<   r=   r>   r?   rL   rA   rB   rC   rD   rE   rF   rb   rc   rM   s        r   rQ   PredictionAlpha.Run   s    --/@@K//#K((;F%%XX..jj$$$$$${{,,..??**..002 2r   rS   NrT   rS   r   r   r]   r]      s    28 8
2r   r]   N)rY   
__future__r   r   r    googlecloudsdk.api_lib.ml_enginer   googlecloudsdk.callioper   r   $googlecloudsdk.command_lib.ml_enginer	   r
   $googlecloudsdk.command_lib.util.argsr   r   r.   ReleaseTracksReleaseTrackGABETACommandr0   ALPHAr]   rS   r   r   <module>rp      s    8 &  ' 1 / ( 6 : </"C+L D%%((%%**, ,< D%%++,2dll 2 -2r   