示例#1
0
    def _serve_static_file(self, request, path):
        """Serves the static file located at the given path.

    Args:
      request: A werkzeug Request
      path: The path of the static file, relative to the tensorboard/ directory.

    Returns:
      A werkzeug.Response application.
    """
        # Strip off the leading forward slash.
        orig_path = path.lstrip('/')
        if not self._path_is_safe(orig_path):
            logging.warning('path not safe: %s', orig_path)
            return http_util.Respond(request, 'Naughty naughty!', 'text/plain',
                                     400)
            # Resource loader wants a path relative to //WORKSPACE/tensorflow.
        path = os.path.join('tensorboard', orig_path)
        # Open the file and read it.
        try:
            contents = resource_loader.load_resource(path)
        except IOError:
            # For compatibility with latest version of Bazel, we renamed bower
            # packages to use '_' rather than '-' in their package name.
            # This means that the directory structure is changed too.
            # So that all our recursive imports work, we need to modify incoming
            # requests to map onto the new directory structure.
            path = orig_path
            components = path.split('/')
            components[0] = components[0].replace('-', '_')
            path = ('/').join(components)
            # Bazel keeps all the external dependencies in //WORKSPACE/external.
            # and resource loader wants a path relative to //WORKSPACE/tensorflow/.
            path = os.path.join('../external', path)
            try:
                contents = resource_loader.load_resource(path)
            except IOError:
                logging.info('path %s not found, sending 404', path)
                return http_util.Respond(request,
                                         'Not found',
                                         'text/plain',
                                         code=404)
        mimetype, content_encoding = mimetypes.guess_type(path)
        mimetype = mimetype or 'application/octet-stream'
        return http_util.Respond(request,
                                 contents,
                                 mimetype,
                                 expires=3600,
                                 content_encoding=content_encoding)
示例#2
0
    def _serve_static_file(self, path):
        """Serves the static file located at the given path.

    Args:
      path: The path of the static file, relative to the tensorboard/ directory.
    """
        # Strip off the leading forward slash.
        path = path.lstrip('/')
        if not self._path_is_safe(path):
            logging.info('path %s not safe, sending 404', path)
            # Traversal attack, so 404.
            self.send_error(404)
            return

        if path.startswith('external'):
            path = os.path.join('../', path)
        else:
            path = os.path.join('tensorboard', path)
        # Open the file and read it.
        try:
            contents = resource_loader.load_resource(path)
        except IOError:
            logging.info('path %s not found, sending 404', path)
            self.send_error(404)
            return

        self.send_response(200)

        mimetype = mimetypes.guess_type(path)[0] or 'application/octet-stream'
        self.send_header('Content-Type', mimetype)
        self.end_headers()
        self.wfile.write(contents)
  def _serve_static_file(self, path):
    """Serves the static file located at the given path.

    Args:
      path: The path of the static file, relative to the tensorboard/ directory.
    """
    # Strip off the leading forward slash.
    path = path.lstrip('/')
    if not self._path_is_safe(path):
      logging.info('path %s not safe, sending 404', path)
      # Traversal attack, so 404.
      self.send_error(404)
      return

    if path.startswith('external'):
      path = os.path.join('../', path)
    else:
      path = os.path.join('tensorboard', path)
    # Open the file and read it.
    try:
      contents = resource_loader.load_resource(path)
    except IOError:
      logging.info('path %s not found, sending 404', path)
      self.send_error(404)
      return

    self.send_response(200)

    mimetype = mimetypes.guess_type(path)[0] or 'application/octet-stream'
    self.send_header('Content-Type', mimetype)
    self.end_headers()
    self.wfile.write(contents)
示例#4
0
  def _serve_static_file(self, request, path):
    """Serves the static file located at the given path.

    Args:
      request: A werkzeug Request
      path: The path of the static file, relative to the tensorboard/ directory.

    Returns:
      A werkzeug.Response application.
    """
    # Strip off the leading forward slash.
    orig_path = path.lstrip('/')
    if not self._path_is_safe(orig_path):
      logging.warning('path not safe: %s', orig_path)
      return http_util.Respond(request, 'Naughty naughty!', 'text/plain', 400)
      # Resource loader wants a path relative to //WORKSPACE/tensorflow.
    path = os.path.join('tensorboard', orig_path)
    # Open the file and read it.
    try:
      contents = resource_loader.load_resource(path)
    except IOError:
      # For compatibility with latest version of Bazel, we renamed bower
      # packages to use '_' rather than '-' in their package name.
      # This means that the directory structure is changed too.
      # So that all our recursive imports work, we need to modify incoming
      # requests to map onto the new directory structure.
      path = orig_path
      components = path.split('/')
      components[0] = components[0].replace('-', '_')
      path = ('/').join(components)
      # Bazel keeps all the external dependencies in //WORKSPACE/external.
      # and resource loader wants a path relative to //WORKSPACE/tensorflow/.
      path = os.path.join('../external', path)
      try:
        contents = resource_loader.load_resource(path)
      except IOError:
        logging.warning('path %s not found, sending 404', path)
        return http_util.Respond(request, 'Not found', 'text/plain', code=404)
    mimetype, content_encoding = mimetypes.guess_type(path)
    mimetype = mimetype or 'application/octet-stream'
    return http_util.Respond(
        request,
        contents,
        mimetype,
        expires=3600,
        content_encoding=content_encoding)
示例#5
0
 def get_tag(self):
     """Read the TensorBoard TAG number, and return it or an empty string."""
     try:
         tag = resource_loader.load_resource('tensorboard/TAG').strip()
         logging.info('TensorBoard is tag: %s', tag)
         return tag
     except IOError:
         logging.info('Unable to read TensorBoard tag')
         return ''
示例#6
0
 def get_tag(self):
   """Read the TensorBoard TAG number, and return it or an empty string."""
   try:
     tag = resource_loader.load_resource('tensorboard/TAG').strip()
     logging.info('TensorBoard is tag: %s', tag)
     return tag
   except IOError:
     logging.info('Unable to read TensorBoard tag')
     return ''
示例#7
0
def main(unused_argv=None):
    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)
        logging.info('TensorBoard is in debug mode.')

    if not FLAGS.logdir:
        logging.error(
            'A logdir must be specified. Run `tensorboard --help` for '
            'details and examples.')
        return -1

    logging.info('Starting TensorBoard in directory %s', os.getcwd())

    path_to_run = ParseEventFilesFlag(FLAGS.logdir)
    logging.info('TensorBoard path_to_run is: %s', path_to_run)
    multiplexer = event_multiplexer.EventMultiplexer(
        size_guidance=TENSORBOARD_SIZE_GUIDANCE)

    def _Load():
        start = time.time()
        for (path, name) in six.iteritems(path_to_run):
            multiplexer.AddRunsFromDirectory(path, name)
        multiplexer.Reload()
        duration = time.time() - start
        logging.info('Multiplexer done loading. Load took %0.1f secs',
                     duration)
        t = threading.Timer(LOAD_INTERVAL, _Load)
        t.daemon = True
        t.start()

    t = threading.Timer(0, _Load)
    t.daemon = True
    t.start()

    factory = functools.partial(tensorboard_handler.TensorboardHandler,
                                multiplexer)
    try:
        server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
    except socket.error:
        logging.error(
            'Tried to connect to port %d, but that address is in use.',
            FLAGS.port)
        return -2
    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.warning('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
    server.serve_forever()
示例#8
0
def main(unused_argv=None):
    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)
        logging.info('TensorBoard is in debug mode.')

    if FLAGS.inspect:
        logging.info(
            'Not bringing up TensorBoard, but inspecting event files.')
        efi.inspect(logdir=FLAGS.logdir,
                    event_file=FLAGS.event_file,
                    tag=FLAGS.tag)
        return 0

    if not FLAGS.logdir:
        msg = ('A logdir must be specified. Run `tensorboard --help` for '
               'details and examples.')
        logging.error(msg)
        print(msg)
        return -1

    logging.info('Starting TensorBoard in directory %s', os.getcwd())
    path_to_run = server.ParseEventFilesSpec(FLAGS.logdir)
    logging.info('TensorBoard path_to_run is: %s', path_to_run)

    multiplexer = event_multiplexer.EventMultiplexer(
        size_guidance=server.TENSORBOARD_SIZE_GUIDANCE,
        purge_orphaned_data=FLAGS.purge_orphaned_data)
    server.StartMultiplexerReloadingThread(multiplexer, path_to_run,
                                           FLAGS.reload_interval)
    try:
        tb_server = server.BuildServer(multiplexer, FLAGS.host, FLAGS.port)
    except socket.error:
        if FLAGS.port == 0:
            msg = 'Unable to find any open ports.'
            logging.error(msg)
            print(msg)
            return -2
        else:
            msg = 'Tried to connect to port %d, but address is in use.' % FLAGS.port
            logging.error(msg)
            print(msg)
            return -3

    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.warning('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
    tb_server.serve_forever()
示例#9
0
def main(unused_argv=None):
  logdir = os.path.expanduser(FLAGS.logdir)
  event_file = os.path.expanduser(FLAGS.event_file)

  if FLAGS.debug:
    logging.set_verbosity(logging.DEBUG)
    logging.info('TensorBoard is in debug mode.')

  if FLAGS.inspect:
    logging.info('Not bringing up TensorBoard, but inspecting event files.')
    efi.inspect(logdir, event_file, FLAGS.tag)
    return 0

  if not logdir:
    msg = ('A logdir must be specified. Run `tensorboard --help` for '
           'details and examples.')
    logging.error(msg)
    print(msg)
    return -1

  logging.info('Starting TensorBoard in directory %s', os.getcwd())
  path_to_run = server.ParseEventFilesSpec(logdir)
  logging.info('TensorBoard path_to_run is: %s', path_to_run)

  multiplexer = event_multiplexer.EventMultiplexer(
      size_guidance=server.TENSORBOARD_SIZE_GUIDANCE,
      purge_orphaned_data=FLAGS.purge_orphaned_data)
  server.StartMultiplexerReloadingThread(multiplexer, path_to_run,
                                         FLAGS.reload_interval)
  try:
    tb_server = server.BuildServer(multiplexer, FLAGS.host, FLAGS.port)
  except socket.error:
    if FLAGS.port == 0:
      msg = 'Unable to find any open ports.'
      logging.error(msg)
      print(msg)
      return -2
    else:
      msg = 'Tried to connect to port %d, but address is in use.' % FLAGS.port
      logging.error(msg)
      print(msg)
      return -3

  try:
    tag = resource_loader.load_resource('tensorboard/TAG').strip()
    logging.info('TensorBoard is tag: %s', tag)
  except IOError:
    logging.info('Unable to read TensorBoard tag')
    tag = ''

  status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
  print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
  print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
  tb_server.serve_forever()
示例#10
0
def main(unused_argv=None):
  if FLAGS.debug:
    logging.set_verbosity(logging.DEBUG)
    logging.info('TensorBoard is in debug mode.')

  if not FLAGS.logdir:
    logging.error('A logdir must be specified. Run `tensorboard --help` for '
                  'details and examples.')
    return -1

  logging.info('Starting TensorBoard in directory %s', os.getcwd())

  path_to_run = ParseEventFilesFlag(FLAGS.logdir)
  logging.info('TensorBoard path_to_run is: %s', path_to_run)
  multiplexer = event_multiplexer.EventMultiplexer(
      size_guidance=TENSORBOARD_SIZE_GUIDANCE)
  # Ensure the Multiplexer initializes in a loaded state before it adds runs
  # So it can handle HTTP requests while runs are loading

  multiplexer.Reload()
  def _Load():
    start = time.time()
    for (path, name) in six.iteritems(path_to_run):
      multiplexer.AddRunsFromDirectory(path, name)
    multiplexer.Reload()
    duration = time.time() - start
    logging.info('Multiplexer done loading. Load took %0.1f secs', duration)
    t = threading.Timer(LOAD_INTERVAL, _Load)
    t.daemon = True
    t.start()
  t = threading.Timer(0, _Load)
  t.daemon = True
  t.start()

  factory = functools.partial(tensorboard_handler.TensorboardHandler,
                              multiplexer)
  try:
    server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
  except socket.error:
    logging.error('Tried to connect to port %d, but that address is in use.',
                  FLAGS.port)
    return -2
  try:
    tag = resource_loader.load_resource('tensorboard/TAG').strip()
    logging.info('TensorBoard is tag: %s', tag)
  except IOError:
    logging.warning('Unable to read TensorBoard tag')
    tag = ''

  status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
  print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
  print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
  server.serve_forever()
示例#11
0
  def _serve_static_file(self, path):
    """Serves the static file located at the given path.

    Args:
      path: The path of the static file, relative to the tensorboard/ directory.
    """
    # Strip off the leading forward slash.
    orig_path = path.lstrip('/')
    if not self._path_is_safe(orig_path):
      logging.info('path %s not safe, sending 404', orig_path)
      # Traversal attack, so 404.
      self.send_error(404)
      return
    # Resource loader wants a path relative to //WORKSPACE/tensorflow.
    path = os.path.join('tensorboard', orig_path)
    # Open the file and read it.
    try:
      contents = resource_loader.load_resource(path)
    except IOError:
      # For compatibility with latest version of Bazel, we renamed bower
      # packages to use '_' rather than '-' in their package name.
      # This means that the directory structure is changed too.
      # So that all our recursive imports work, we need to modify incoming
      # requests to map onto the new directory structure.
      path = orig_path
      components = path.split('/')
      components[0] = components[0].replace('-', '_')
      path = ('/').join(components)
      # Bazel keeps all the external dependencies in //WORKSPACE/external.
      # and resource loader wants a path relative to //WORKSPACE/tensorflow/.
      path = os.path.join('../external', path)
      try:
        contents = resource_loader.load_resource(path)
      except IOError:
        logging.info('path %s not found, sending 404', path)
        self.send_error(404)
        return
    mimetype, encoding = mimetypes.guess_type(path)
    mimetype = mimetype or 'application/octet-stream'
    self._respond(contents, mimetype, encoding=encoding)
示例#12
0
def main(unused_argv=None):
    if FLAGS.debug:
        logging.set_verbosity(logging.DEBUG)
        logging.info('TensorBoard is in debug mode.')

    if not FLAGS.logdir:
        logging.error(
            'A logdir must be specified. Run `tensorboard --help` for '
            'details and examples.')
        return -1

    if FLAGS.debug:
        logging.info('Starting TensorBoard in directory %s', os.getcwd())

    path_to_run = ParseEventFilesFlag(FLAGS.logdir)
    multiplexer = event_multiplexer.AutoloadingMultiplexer(
        path_to_run=path_to_run,
        interval_secs=60,
        size_guidance=TENSORBOARD_SIZE_GUIDANCE)

    multiplexer.AutoUpdate(interval=30)

    factory = functools.partial(tensorboard_handler.TensorboardHandler,
                                multiplexer)
    try:
        server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
    except socket.error:
        logging.error(
            'Tried to connect to port %d, but that address is in use.',
            FLAGS.port)
        return -2
    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.warning('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
    server.serve_forever()
示例#13
0
  def _serve_static_file(self, path):
    """Serves the static file located at the given path.

    Args:
      path: The path of the static file, relative to the tensorboard/ directory.
    """
    # Strip off the leading forward slash.
    path = path.lstrip('/')
    if not self._path_is_safe(path):
      logging.info('path %s not safe, sending 404', path)
      # Traversal attack, so 404.
      self.send_error(404)
      return

    if path.startswith('external'):
      # For compatibility with latest version of Bazel, we renamed bower
      # packages to use '_' rather than '-' in their package name.
      # This means that the directory structure is changed too.
      # So that all our recursive imports work, we need to modify incoming
      # requests to map onto the new directory structure.
      components = path.split('/')
      components[1] = components[1].replace('-', '_')
      path = ('/').join(components)
      path = os.path.join('../', path)
    else:
      path = os.path.join('tensorboard', path)
    # Open the file and read it.
    try:
      contents = resource_loader.load_resource(path)
    except IOError:
      logging.info('path %s not found, sending 404', path)
      self.send_error(404)
      return

    self.send_response(200)

    mimetype = mimetypes.guess_type(path)[0] or 'application/octet-stream'
    self.send_header('Content-Type', mimetype)
    self.end_headers()
    self.wfile.write(contents)
示例#14
0
def main(unused_argv=None):
  if FLAGS.debug:
    logging.set_verbosity(logging.DEBUG)
    logging.info('TensorBoard is in debug mode.')

  if not FLAGS.logdir:
    logging.error('A logdir must be specified. Run `tensorboard --help` for '
                  'details and examples.')
    return -1

  if FLAGS.debug:
    logging.info('Starting TensorBoard in directory %s', os.getcwd())

  path_to_run = ParseEventFilesFlag(FLAGS.logdir)
  multiplexer = event_multiplexer.AutoloadingMultiplexer(
      path_to_run=path_to_run, interval_secs=60,
      size_guidance=TENSORBOARD_SIZE_GUIDANCE)

  multiplexer.AutoUpdate(interval=30)

  factory = functools.partial(tensorboard_handler.TensorboardHandler,
                              multiplexer)
  try:
    server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
  except socket.error:
    logging.error('Tried to connect to port %d, but that address is in use.',
                  FLAGS.port)
    return -2
  try:
    tag = resource_loader.load_resource('tensorboard/TAG').strip()
    logging.info('TensorBoard is tag: %s', tag)
  except IOError:
    logging.warning('Unable to read TensorBoard tag')
    tag = ''

  status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
  print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
  print('(You can navigate to http://localhost:%d)' % FLAGS.port)
  server.serve_forever()
示例#15
0
def main(unused_argv=None):
  if FLAGS.debug:
    logging.set_verbosity(logging.DEBUG)
    logging.info('TensorBoard is in debug mode.')

  if not FLAGS.logdir:
    logging.error('A logdir must be specified. Run `tensorboard --help` for '
                  'details and examples.')
    return -1

  logging.info('Starting TensorBoard in directory %s', os.getcwd())
  path_to_run = tensorboard_server.ParseEventFilesSpec(FLAGS.logdir)
  logging.info('TensorBoard path_to_run is: %s', path_to_run)

  multiplexer = event_multiplexer.EventMultiplexer(
      size_guidance=tensorboard_server.TENSORBOARD_SIZE_GUIDANCE)
  tensorboard_server.StartMultiplexerReloadingThread(multiplexer, path_to_run)
  try:
    server = tensorboard_server.BuildServer(multiplexer, FLAGS.host, FLAGS.port)
  except socket.error:
    if FLAGS.port == 0:
      logging.error('Unable to find any open ports.')
    else:
      logging.error('Tried to connect to port %d, but that address is in use.',
                    FLAGS.port)
    return -1

  try:
    tag = resource_loader.load_resource('tensorboard/TAG').strip()
    logging.info('TensorBoard is tag: %s', tag)
  except IOError:
    logging.warning('Unable to read TensorBoard tag')
    tag = ''

  status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
  print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
  print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))
  server.serve_forever()
示例#16
0
 def _serve_index(self, request):
   """Serves the index page (i.e., the tensorboard app itself)."""
   contents = resource_loader.load_resource(
       'tensorboard/components/index.html')
   return http_util.Respond(request, contents, 'text/html', expires=3600)
示例#17
0
def main(unused_argv=None):
  debug = FLAGS.insecure_debug_mode
  logdir = os.path.expanduser(FLAGS.logdir)
  if debug:
    logging.set_verbosity(logging.DEBUG)
    logging.warning('TensorBoard is in debug mode. This is NOT SECURE.')

  if FLAGS.inspect:
    logging.info('Not bringing up TensorBoard, but inspecting event files.')
    event_file = os.path.expanduser(FLAGS.event_file)
    efi.inspect(logdir, event_file, FLAGS.tag)
    return 0

  if not logdir:
    msg = ('A logdir must be specified. Run `tensorboard --help` for '
           'details and examples.')
    logging.error(msg)
    print(msg)
    return -1

  logging.info('Starting TensorBoard in directory %s', os.getcwd())

  plugins = {'projector': projector_plugin.ProjectorPlugin()}
  tb_app = application.TensorBoardWSGIApp(
      logdir,
      plugins,
      purge_orphaned_data=FLAGS.purge_orphaned_data,
      reload_interval=FLAGS.reload_interval)

  try:
    tag = resource_loader.load_resource('tensorboard/TAG').strip()
    logging.info('TensorBoard is tag: %s', tag)
  except IOError:
    logging.info('Unable to read TensorBoard tag')
    tag = ''

  status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
  print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))

  if FLAGS.host == "0.0.0.0":
    try:
      host = socket.gethostbyname(socket.gethostname())
      print('(You can navigate to http://%s:%d)' % (host, FLAGS.port))
    except socket.gaierror:
      pass
  else:
    print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))

  try:
    serving.run_simple(
        FLAGS.host,
        FLAGS.port,
        tb_app,
        threaded=True,
        use_reloader=debug,
        use_evalex=debug,
        use_debugger=debug)
  except socket.error:
    if FLAGS.port == 0:
      msg = 'Unable to find any open ports.'
      logging.error(msg)
      print(msg)
      return -2
    else:
      msg = 'Tried to connect to port %d, but address is in use.' % FLAGS.port
      logging.error(msg)
      print(msg)
      return -3
示例#18
0
def main(unused_argv=None):
    debug = FLAGS.insecure_debug_mode
    logdir = os.path.expanduser(FLAGS.logdir)
    if debug:
        logging.set_verbosity(logging.DEBUG)
        logging.warning('TensorBoard is in debug mode. This is NOT SECURE.')

    if FLAGS.inspect:
        logging.info(
            'Not bringing up TensorBoard, but inspecting event files.')
        event_file = os.path.expanduser(FLAGS.event_file)
        efi.inspect(logdir, event_file, FLAGS.tag)
        return 0

    if not logdir:
        msg = ('A logdir must be specified. Run `tensorboard --help` for '
               'details and examples.')
        logging.error(msg)
        print(msg)
        return -1

    logging.info('Starting TensorBoard in directory %s', os.getcwd())

    plugins = {'projector': projector_plugin.ProjectorPlugin()}
    tb_app = application.TensorBoardWSGIApp(
        logdir,
        plugins,
        purge_orphaned_data=FLAGS.purge_orphaned_data,
        reload_interval=FLAGS.reload_interval)

    try:
        tag = resource_loader.load_resource('tensorboard/TAG').strip()
        logging.info('TensorBoard is tag: %s', tag)
    except IOError:
        logging.info('Unable to read TensorBoard tag')
        tag = ''

    status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
    print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))

    if FLAGS.host == "0.0.0.0":
        try:
            host = socket.gethostbyname(socket.gethostname())
            print('(You can navigate to http://%s:%d)' % (host, FLAGS.port))
        except socket.gaierror:
            pass
    else:
        print('(You can navigate to http://%s:%d)' % (FLAGS.host, FLAGS.port))

    try:
        serving.run_simple(FLAGS.host,
                           FLAGS.port,
                           tb_app,
                           threaded=True,
                           use_reloader=debug,
                           use_evalex=debug,
                           use_debugger=debug)
    except socket.error:
        if FLAGS.port == 0:
            msg = 'Unable to find any open ports.'
            logging.error(msg)
            print(msg)
            return -2
        else:
            msg = 'Tried to connect to port %d, but address is in use.' % FLAGS.port
            logging.error(msg)
            print(msg)
            return -3
示例#19
0
def get_tensorboard_tag():
  """Read the TensorBoard TAG number, and return it or an empty string."""
  tag = resource_loader.load_resource('tensorboard/TAG').strip()
  return tag
def get_graph_def_from_resource(filename):
    """Get a GraphDef proto from within a .par file."""
    return graph_pb2.GraphDef.FromString(
        resource_loader.load_resource(filename))
 def test_exception(self):
     with self.assertRaises(IOError):
         resource_loader.load_resource("/fake/file/path/dne")
示例#22
0
 def testTagFound(self):
   tag = resource_loader.load_resource('tensorboard/TAG')
   self.assertTrue(tag)
 def test_exists(self):
     contents = resource_loader.load_resource(
         "python/platform/resource_loader.py")
     self.assertIn(b"tensorflow", contents)
def get_graph_def_from_resource(filename):
  """Get a GraphDef proto from within a .par file."""
  return graph_pb2.GraphDef.FromString(resource_loader.load_resource(filename))
示例#25
0
 def test_exception(self):
     with self.assertRaises(IOError):
         resource_loader.load_resource("/fake/file/path/dne")
示例#26
0
 def testTagFound(self):
     tag = resource_loader.load_resource('tensorboard/TAG')
     self.assertTrue(tag)
示例#27
0
 def _serve_index(self, request):
     """Serves the index page (i.e., the tensorboard app itself)."""
     contents = resource_loader.load_resource(
         'tensorboard/components/index.html')
     return http_util.Respond(request, contents, 'text/html', expires=3600)
示例#28
0
def get_tensorboard_tag():
    """Read the TensorBoard TAG number, and return it or an empty string."""
    tag = resource_loader.load_resource('tensorboard/TAG').strip()
    return tag