MCPcopy Index your code
hub / github.com/tensorflow/tensorboard / start

Function start

tensorboard/manager.py:425–494  ·  view source on GitHub ↗

Start a new TensorBoard instance, or reuse a compatible one. If the cache key determined by the provided arguments and the current working directory (see `cache_key`) matches the cache key of a running TensorBoard process (see `get_all`), that process will be reused. Otherwise, a n

(arguments, timeout=datetime.timedelta(seconds=60))

Source from the content-addressed store, hash-verified

423
424
425def start(arguments, timeout=datetime.timedelta(seconds=60)):
426 """Start a new TensorBoard instance, or reuse a compatible one.
427
428 If the cache key determined by the provided arguments and the current
429 working directory (see `cache_key`) matches the cache key of a running
430 TensorBoard process (see `get_all`), that process will be reused.
431
432 Otherwise, a new TensorBoard process will be spawned with the provided
433 arguments, using the `tensorboard` binary from the system path.
434
435 Args:
436 arguments: List of strings to be passed as arguments to
437 `tensorboard`. (If you have a raw command-line string, see
438 `shlex.split`.)
439 timeout: `datetime.timedelta` object describing how long to wait for
440 the subprocess to initialize a TensorBoard server and write its
441 `TensorBoardInfo` file. If the info file is not written within
442 this time period, `start` will assume that the subprocess is stuck
443 in a bad state, and will give up on waiting for it and return a
444 `StartTimedOut` result. Note that in such a case the subprocess
445 will not be killed. Default value is 60 seconds.
446
447 Returns:
448 A `StartReused`, `StartLaunched`, `StartFailed`, or `StartTimedOut`
449 object.
450 """
451 this_cache_key = cache_key(
452 working_directory=os.getcwd(),
453 arguments=arguments,
454 configure_kwargs={},
455 )
456 match = _find_matching_instance(this_cache_key)
457 if match:
458 return StartReused(info=match)
459
460 (stdout_fd, stdout_path) = tempfile.mkstemp(prefix=".tensorboard-stdout-")
461 (stderr_fd, stderr_path) = tempfile.mkstemp(prefix=".tensorboard-stderr-")
462 start_time_seconds = time.time()
463 explicit_tb = os.environ.get("TENSORBOARD_BINARY", None)
464 try:
465 p = subprocess.Popen(
466 ["tensorboard" if explicit_tb is None else explicit_tb] + arguments,
467 env=_subprocess_environ(),
468 stdout=stdout_fd,
469 stderr=stderr_fd,
470 )
471 except OSError as e:
472 return StartExecFailed(os_error=e, explicit_binary=explicit_tb)
473 finally:
474 os.close(stdout_fd)
475 os.close(stderr_fd)
476
477 poll_interval_seconds = 0.5
478 end_time_seconds = start_time_seconds + timeout.total_seconds()
479 while time.time() < end_time_seconds:
480 time.sleep(poll_interval_seconds)
481 subprocess_result = p.poll()
482 if subprocess_result is not None:

Callers

nothing calls this directly

Calls 13

cache_keyFunction · 0.85
_find_matching_instanceFunction · 0.85
StartReusedClass · 0.85
_subprocess_environFunction · 0.85
StartExecFailedClass · 0.85
StartFailedClass · 0.85
StartLaunchedClass · 0.85
StartTimedOutClass · 0.85
_maybe_read_fileFunction · 0.70
getMethod · 0.65
timeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…