message: Add convenient functions in multi_worker_test_base.py for task type, task index, and is_chief of current environment.
diff: @@ -409,3 +409,25 @@ class IndependentWorkerTestBase(test.TestCase):
  def join_independent_workers(self, worker_threads):
  self._coord.join(worker_threads)
  +
  +
  +def get_tf_config_task():
  + return json.loads(os.environ['TF_CONFIG'])['task']
  +
  +
  +def get_tf_config_cluster_spec():
  + return json.loads(os.environ['TF_CONFIG'])['cluster']
  +
  +
  +def get_task_type():
  + return get_tf_config_task()['type']
  +
  +
  +def get_task_index():
  + return get_tf_config_task()['index']
  +
  +
  +def is_chief():
  + return ('chief' not in get_tf_config_cluster_spec()
  + and get_task_type() == 'worker'
  + and get_task_index() == 0)
  