r'''Get configuration from TF_CONFIG environment variable.
(cls)
| 104 | |
| 105 | @classmethod |
| 106 | def get_tf_config(cls): |
| 107 | r'''Get configuration from TF_CONFIG environment variable. |
| 108 | ''' |
| 109 | tf_config = json.loads(os.getenv('TF_CONFIG', '{}')) |
| 110 | if not tf_config: |
| 111 | return None |
| 112 | task = tf_config['task'] |
| 113 | cluster = tf_config['cluster'] |
| 114 | task_type = task['type'] |
| 115 | task_id = int(task['index']) |
| 116 | tf_config_type = collections.namedtuple( |
| 117 | 'TfConfig', ['task_type', 'task_id', 'cluster']) |
| 118 | return tf_config_type(task_type, task_id, cluster) |
| 119 | |
| 120 | @property |
| 121 | def cluster_spec(self): |