Skip to content

Commit

Permalink
print version with tensorboard --version (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
shashvatshahi1998 authored and nfelt committed Apr 18, 2019
1 parent 8acf7a0 commit df4ac42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion tensorboard/plugins/core/core_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ def define_flags(self, parser):
See tensorboard/backend/event_processing/event_file_inspector.py for more info.\
''')

parser.add_argument(
'--version',
action='store_true',
help='Prints the version of Tensorboard')

parser.add_argument(
'--tag',
Expand Down Expand Up @@ -459,7 +464,9 @@ def define_flags(self, parser):
def fix_flags(self, flags):
"""Fixes standard TensorBoard CLI flags to parser."""
FlagsError = base_plugin.FlagsError
if flags.inspect:
if flags.version:
pass
elif flags.inspect:
if flags.logdir and flags.event_file:
raise FlagsError(
'Must specify either --logdir or --event_file, but not both.')
Expand Down
5 changes: 4 additions & 1 deletion tensorboard/plugins/core/core_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@
class FakeFlags(object):
def __init__(
self,
inspect,
inspect=False,
version=False,
logdir='',
event_file='',
db='',
path_prefix=''):
self.inspect = inspect
self.version = version
self.logdir = logdir
self.event_file = event_file
self.db = db
Expand Down Expand Up @@ -80,6 +82,7 @@ def testRoutesProvided(self):
def testFlag(self):
loader = core_plugin.CorePluginLoader()
loader.fix_flags(FakeFlags(inspect=True, logdir='/tmp'))
loader.fix_flags(FakeFlags(version=True))
loader.fix_flags(FakeFlags(inspect=True, event_file='/tmp/event.out'))
loader.fix_flags(FakeFlags(inspect=False, logdir='/tmp'))
loader.fix_flags(FakeFlags(inspect=False, db='sqlite:foo'))
Expand Down
3 changes: 3 additions & 0 deletions tensorboard/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def main(self, ignored_argv=('',)):
event_file = os.path.expanduser(self.flags.event_file)
efi.inspect(self.flags.logdir, event_file, self.flags.tag)
return 0
if self.flags.version:
print(version.VERSION)
return 0
try:
server = self._make_server()
sys.stderr.write('TensorBoard %s at %s (Press CTRL+C to quit)\n' %
Expand Down

0 comments on commit df4ac42

Please sign in to comment.