scalarstop.tf_config

Helpers for TensorFlow’s "TF_CONFIG" environment variable.

Module Contents

Classes

TFConfig

A helper object for querying the TensorFlow configuration in the

class TFConfig(*, tf_config_str: str = '')

A helper object for querying the TensorFlow configuration in the "TF_CONFIG" environment variable.

Parameters

tf_config_str – A string containing a value for the "TF_CONFIG" environment variable. This argument is typically used for testing.

property to_dict(self)Dict[str, Any]

Returns a Python dictionary containing a "TF_CONFIG" configuration.

num_nodes(self, task_type: str)int

Returns the number of nodes belonging to the task type.

Possible task types include:
  • "chief"

  • "worker"

  • "ps"

  • "evaluator"

Or you can pass task_type = "ALL" to count tasks of all types.

Parameters

task_type – The task type for a worker.

Returns

Returns the number of nodes for each type.

property task_type(self)Optional[str]

Returns the current process’s task type.

Possible task types include:
  • None

  • "chief"

  • "worker"

  • "ps"

  • "evaluator"

property task_index(self)int

Returns the current process’s task index.

The task index is a value between 0 and n-1, where n is the number of task processes in your TensorFlow cluster.

This returns 0 if the "TF_CONFIG" environment variable is not configured.

property is_chief(self)bool

Returns True if the current process is the chief node in the cluster.

This method will also return True if the "TF_CONFIG" environment variable is not configured, as that would suggest that this process the chief node–and the only node–in the cluster.