Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen path prefix #5570

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 16 additions & 2 deletions tensorboard/plugins/core/core_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import mimetypes
import posixpath
import zipfile
import os
import binascii

from werkzeug import utils
from werkzeug import wrappers
Expand Down Expand Up @@ -536,7 +538,15 @@ def define_flags(self, parser):
""",
)

parser.add_argument(
parser.add_argument(
"--gen_path_prefix",
action="store_true",
help="""\
automatically generate path_prefix and print it to STDOUT; in case --path_prefix is also given on the command line, the auto-generated path_prefix will have priority and overwrite the value from the --path_prefix command line\
""",
)

parser.add_argument(
"--window_title",
metavar="TEXT",
type=str,
Expand Down Expand Up @@ -711,7 +721,11 @@ def fix_flags(self, flags):
"--detect_file_replacement=true"
)

flags.path_prefix = flags.path_prefix.rstrip("/")
if flags.gen_path_prefix:
flags.path_prefix = "/" + binascii.hexlify(os.urandom(32)).decode()
print("NOTE: using auto-generated path_prefix=" + flags.path_prefix)

flags.path_prefix = flags.path_prefix.rstrip("/")
if flags.path_prefix and not flags.path_prefix.startswith("/"):
raise FlagsError(
"Path prefix must start with slash, but got: %r."
Expand Down