
    =                        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  \R                  " \R                  R                  \R                  R                  5       " S	 S
\R                   5      5       rg)z>Implementation of gcloud dataflow jobs update-options command.    )absolute_import)division)unicode_literals)apis)base)
exceptions)	job_utilsc                   .    \ rS rSrSr\S 5       rS rSrg)UpdateOptions   a  Update pipeline options on-the-fly for running Dataflow jobs.

This command can modify properties of running Dataflow jobs. Currently, only
updating autoscaling settings for Streaming Engine jobs is supported.

Adjust the autoscaling settings for Streaming Engine Dataflow jobs by
providing at-least one of --min-num-workers or --max-num-workers or
--worker-utilization-hint (or all 3), or --unset-worker-utilization-hint
(which cannot be run at the same time as --worker-utilization-hint but works
with the others).
Allow a few minutes for the changes to take effect.

Note that autoscaling settings can only be modified on-the-fly for Streaming
Engine jobs. Attempts to modify batch job or Streaming Appliance jobs will
fail.


## EXAMPLES

Modify autoscaling settings to scale between 5-10 workers:

  $ {command} --min-num-workers=5 --max-num-workers=10

Require a job to use at least 2 workers:

  $ {command} --min-num-workers=2

Require a job to use at most 20 workers:

  $ {command} --max-num-workers=20

Adjust the hint of target worker utilization to 70% for horizontal
autoscaling:

  $ {command} --worker-utilization-hint=0.7

"Unset" worker utilization hint so that horizontal scaling will rely on its
default CPU utilization target:

  $ {command} --unset-worker-utilization-hint
c                     [         R                  " U 5        U R                  S[        SS9  U R                  S[        SS9  U R                  S[        SS9  U R                  SS	S
S9  g)z Register flags for this command.--min-num-workerszVLower-bound for autoscaling, between 1-1000. Only supported for streaming-engine jobs.)typehelp--max-num-workerszVUpper-bound for autoscaling, between 1-1000. Only supported for streaming-engine jobs.--worker-utilization-hintzTarget CPU utilization for autoscaling, ranging from 0.1 to 0.9. Only supported for streaming-engine jobs with autoscaling enabled.--unset-worker-utilization-hint
store_truezUnset --worker-utilization-hint. This causes the job autoscaling to fall back to internal tunings if they exist, or otherwise use the default hint value.)actionr   N)r	   ArgsForJobRefadd_argumentintfloat)parsers    +lib/surface/dataflow/jobs/update_options.pyArgsUpdateOptions.ArgsG   s     F#
&	   &	   #	   )G	      c           
      
   UR                   cD  UR                  c7  UR                  c*  UR                  (       d  [        R
                  " / SQS5      eUR                  b'  UR                  (       a  [        R                  " S5      e[        R                  " U5      n[        R                  R                  UR                  UR                  UR                  UR                   UR                  UR                  UR                  S9$ )zCalled when the user runs gcloud dataflow jobs update-options ...

Args:
  args: all the arguments that were provided to this command invocation.

Returns:
  The updated Job
)r   r   r   r   z-You must provide at-least one field to updatezThe arguments --worker-utilization-hint and --unset-worker-utilization-hint are mutually exclusive (as the unset command will unset the given hint), and must be called separately.)
project_id	region_idmin_num_workersmax_num_workersworker_utilization_hintunset_worker_utilization_hint)r"   r#   r$   r%   r   OneOfArgumentsRequiredExceptionConflictingArgumentsExceptionr	   ExtractJobRefr   Jobsr   jobId	projectIdlocation)selfargsjob_refs      r   RunUpdateOptions.Runn   s     	$  (((02266 :  	$$0..44  %%d+G99""$$"",,,, $ < <&*&H&H #  r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r0   __static_attributes__r2   r   r   r   r      s"    (T $ $L,r   r   N)r7   
__future__r   r   r   googlecloudsdk.api_lib.dataflowr   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.dataflowr	   ReleaseTracksReleaseTrackGABETACommandr   r2   r   r   <module>rC      sh    E &  ' 0 ( . 9 D%%(($*;*;*@*@A~DLL ~ B~r   