
                             S r SSKJr  SSKJr  SSKJr  SSK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\R                   5      rg)z ai-platform local train command.    )absolute_import)division)unicode_literalsN)base)flags)local_train)log)filesz]{flag} is ignored if --distributed is not provided.
Did you mean to run distributed training?c                   .    \ rS rSrSr\S 5       rS rSrg)RunLocal#   a  Run an AI Platform training job locally.

This command runs the specified module in an environment
similar to that of a live AI Platform Training Job.

This is especially useful in the case of testing distributed models,
as it allows you to validate that you are properly interacting with the
AI Platform cluster configuration. If your model expects a specific
number of parameter servers or workers (i.e. you expect to use the CUSTOM
machine type), use the --parameter-server-count and --worker-count flags to
further specify the desired cluster configuration, just as you would in
your cloud training job configuration:

    $ {command} --module-name trainer.task \
            --package-path /path/to/my/code/trainer \
            --distributed \
            --parameter-server-count 4 \
            --worker-count 8

Unlike submitting a training job, the --package-path parameter can be
omitted, and will use your current working directory.

AI Platform Training sets a TF_CONFIG environment variable on each VM in
your training job. You can use TF_CONFIG to access the cluster description
and the task description for each VM.

Learn more about TF_CONFIG:
https://cloud.google.com/ai-platform/training/docs/distributed-training-details.
c                 N   [         R                  R                  U 5        [         R                  " 5       R                  U 5        [         R                  R                  U 5        [         R
                  R                  U 5        [         R                  R                  U 5        [         R                  " SSS9R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        [         R                  " SS9R                  U 5        g)z Register flags for this command.FT)upload_helpallow_local)localN)r   PACKAGE_PATHAddToParserGetModuleNameFlagDISTRIBUTED
EVALUATORSPARAM_SERVERSGetJobDirFlagWORKERS
START_PORTGetUserArgs)parsers    &lib/surface/ai_platform/local/train.pyArgsRunLocal.ArgsB   s     
""6*	))&1	!!&)	  (	##F+	Et<HHP	MMf%	  (	D!--f5    c           
         UR                   =(       d    [        R                  " 5       n[        R                  R                  [        R                  R                  U5      5      nUR                  =(       d    / nUR                  (       a  UR                  SUR                  45        UR                  c  SOUR                  nUR                  c  SOUR                  nUR                  (       aB  [        R                  " UR                  UUUUR                   =(       d    SUR"                  US9nOUR                  (       a'  [$        R&                  " [(        R+                  SS95        UR                  (       a'  [$        R&                  " [(        R+                  SS95        [        R,                  " UR                  UU[        R.                  " 5       S	9nXpl        g)
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.
z	--job-dirN   r   )	user_argsz--parameter-server-count)flagz--worker-count)args	task_type)package_pathr
   GetCWDospathdirnameabspathr#   job_dirextendworker_countparameter_server_countdistributedr   RunDistributedmodule_nameevaluator_count
start_portr	   warning_BAD_FLAGS_WARNING_MESSAGEformatMakeProcessGetPrimaryNodeName	exit_code)selfr%   r'   package_rootr#   r/   ps_countretvals           r   RunRunLocal.RunO   s\    $$6L77??277??<#@AL$"I||T\\23))11t7H7HL//7qT=X=XH))









#!
//f 
	$	$.55+ 6 - 	.			.55;K5LM&&



224	6f Nr    )r;   N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r@   __static_attributes__ r    r   r   r   #   s     < 
6 
6*r    r   )rF   
__future__r   r   r   r)   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml_enginer   r   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   r7   Commandr   rI   r    r   <module>rP      s?    ' &  ' 	 ( 6 < # * Vt|| Vr    