Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tensorboard/plugins/core/core_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,25 @@ def define_flags(self, parser):
means keep all samples of that type. For instance "scalars=500,images=0"
keeps 500 scalars and all images. Most users should not need to set this
flag.\
''')

parser.add_argument(
'--url_file',
metavar='FILE',
type=str,
help='''\
An optional file to which to write a URL from which TensorBoard should
be reachable. The URL will include scheme, hostname, and port, and
possibly path if `--path_prefix` is set. Useful when setting `--port=0`,
which automatically selects an unused port. Primarily intended for use
by scripts; for human consumers, this same value is already printed to
stderr.

If provided, this should point to an existing file (which will be
truncated) or a nonexistent file within a directory that exists.

If TensorBoard fails to start (e.g., because the specified port is
already in use), this file will not be written.
''')

def fix_flags(self, flags):
Expand Down
6 changes: 5 additions & 1 deletion tensorboard/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,13 @@ def main(self, ignored_argv=('',)):
return 0
try:
server = self._make_server()
url = server.get_url()
sys.stderr.write('TensorBoard %s at %s (Press CTRL+C to quit)\n' %
(version.VERSION, server.get_url()))
(version.VERSION, url))
sys.stderr.flush()
if self.flags.url_file is not None:
with open(self.flags.url_file, "w") as outfile:
outfile.write("%s\n" % server.get_url())
server.serve_forever()
return 0
except TensorBoardServerException as e:
Expand Down