MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / as_dict

Method as_dict

tensorflow/python/training/server_lib.py:336–361  ·  view source on GitHub ↗

Returns a dictionary from job names to their tasks. For each job, if the task index space is dense, the corresponding value will be a list of network addresses; otherwise it will be a dictionary mapping (sparse) task indices to the corresponding addresses. Returns: A dict

(self)

Source from the content-addressed store, hash-verified

334 return "ClusterSpec({" + ", ".join(string_items) + "})"
335
336 def as_dict(self):
337 """Returns a dictionary from job names to their tasks.
338
339 For each job, if the task index space is dense, the corresponding
340 value will be a list of network addresses; otherwise it will be a
341 dictionary mapping (sparse) task indices to the corresponding
342 addresses.
343
344 Returns:
345 A dictionary mapping job names to lists or dictionaries
346 describing the tasks in those jobs.
347 """
348 ret = {}
349 for job in self.jobs:
350 task_indices = self.task_indices(job)
351 if len(task_indices) == 0:
352 ret[job] = {}
353 continue
354 if max(task_indices) + 1 == len(task_indices):
355 # Return a list because the task indices are dense. This
356 # matches the behavior of `as_dict()` before support for
357 # sparse jobs was added.
358 ret[job] = self.job_tasks(job)
359 else:
360 ret[job] = {i: self.task_address(job, i) for i in task_indices}
361 return ret
362
363 def as_cluster_def(self):
364 """Returns a `tf.train.ClusterDef` protocol buffer based on this cluster."""

Callers 15

__str__Method · 0.95
get_num_workersFunction · 0.45
uidMethod · 0.45
_count_psFunction · 0.45
_count_workerFunction · 0.45
test_uid_for_deepcopyMethod · 0.45

Calls 4

task_indicesMethod · 0.95
job_tasksMethod · 0.95
task_addressMethod · 0.95
maxFunction · 0.50