aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-01-30 10:37:42 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-01-30 10:47:44 -0800
commitab2f960947d546079c4fd2e85d87b4df972a7c24 (patch)
tree41d0fdb31af396656ab60d70f6cc6dffae9a4811 /tensorflow/tensorboard
parent0eeed35f6890edcaa7d858166209d1e028139c79 (diff)
Moved logic for constructing the event multiplexer out of the Tensorboard application constructor. This lets us construct plugins that rely on the multiplexer.
Change: 146010100
Diffstat (limited to 'tensorflow/tensorboard')
-rw-r--r--tensorflow/tensorboard/backend/application.py47
-rw-r--r--tensorflow/tensorboard/backend/application_test.py6
-rw-r--r--tensorflow/tensorboard/tensorboard.py7
3 files changed, 27 insertions, 33 deletions
diff --git a/tensorflow/tensorboard/backend/application.py b/tensorflow/tensorboard/backend/application.py
index 086da7f90b..d977491cf2 100644
--- a/tensorflow/tensorboard/backend/application.py
+++ b/tensorflow/tensorboard/backend/application.py
@@ -40,11 +40,18 @@ from werkzeug import wrappers
from tensorflow.python.platform import resource_loader
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.summary import event_accumulator
-from tensorflow.python.summary import event_multiplexer
from tensorflow.tensorboard.backend import process_graph
from tensorflow.tensorboard.lib.python import http_util
+DEFAULT_SIZE_GUIDANCE = {
+ event_accumulator.COMPRESSED_HISTOGRAMS: 500,
+ event_accumulator.IMAGES: 4,
+ event_accumulator.AUDIO: 4,
+ event_accumulator.SCALARS: 1000,
+ event_accumulator.HISTOGRAMS: 50,
+}
+
DATA_PREFIX = '/data'
LOGDIR_ROUTE = '/logdir'
RUNS_ROUTE = '/runs'
@@ -69,15 +76,6 @@ _IMGHDR_TO_MIMETYPE = {
_DEFAULT_IMAGE_MIMETYPE = 'application/octet-stream'
-TENSORBOARD_SIZE_GUIDANCE = {
- event_accumulator.COMPRESSED_HISTOGRAMS: 500,
- event_accumulator.IMAGES: 4,
- event_accumulator.AUDIO: 4,
- event_accumulator.SCALARS: 1000,
- event_accumulator.HISTOGRAMS: 50,
-}
-
-
def _content_type_for_image(encoded_image_string):
image_type = imghdr.what(None, encoded_image_string)
return _IMGHDR_TO_MIMETYPE.get(image_type, _DEFAULT_IMAGE_MIMETYPE)
@@ -103,12 +101,7 @@ class TensorBoardWSGIApp(object):
# responses using send_header.
protocol_version = 'HTTP/1.1'
- def __init__(self,
- logdir,
- plugins,
- size_guidance=None,
- purge_orphaned_data=True,
- reload_interval=60):
+ def __init__(self, logdir, plugins, multiplexer, reload_interval=60):
"""Constructs the TensorBoard application.
Args:
@@ -116,33 +109,25 @@ class TensorBoardWSGIApp(object):
may be a directory, or comma,separated list of directories, or colons
can be used to provide named directories
plugins: Map from plugin name to plugin application.
- size_guidance: Controls how much data of every kind is loaded into memory.
- purge_orphaned_data: "orphaned" data may be left behind due to a
- TF restart or out-of-order execution. If true, purge it when detected.
+ multiplexer: Organizes events data from runs.
reload_interval: How often (in seconds) to reload the Multiplexer
Returns:
A WSGI application that implements the TensorBoard backend.
"""
- if size_guidance is None:
- size_guidance = TENSORBOARD_SIZE_GUIDANCE
- self._registered_plugins = plugins
+ self._plugins = plugins
self._logdir = logdir
- self._size = size_guidance
- self._purge = purge_orphaned_data
+ self._multiplexer = multiplexer
self._reload = reload_interval
self.initialize()
def initialize(self):
"""Setup the TensorBoard application."""
path_to_run = parse_event_files_spec(self._logdir)
- multiplexer = event_multiplexer.EventMultiplexer(
- size_guidance=self._size, purge_orphaned_data=self._purge)
if self._reload:
- start_reloading_multiplexer(multiplexer, path_to_run, self._reload)
+ start_reloading_multiplexer(self._multiplexer, path_to_run, self._reload)
else:
- reload_multiplexer(multiplexer, path_to_run)
- self._multiplexer = multiplexer
+ reload_multiplexer(self._multiplexer, path_to_run)
self.data_applications = {
DATA_PREFIX + LOGDIR_ROUTE:
@@ -174,9 +159,9 @@ class TensorBoardWSGIApp(object):
# Serve the routes from the registered plugins using their name as the route
# prefix. For example if plugin z has two routes /a and /b, they will be
# served as /data/plugin/z/a and /data/plugin/z/b.
- for name in self._registered_plugins:
+ for name in self._plugins:
try:
- plugin = self._registered_plugins[name]
+ plugin = self._plugins[name]
plugin_apps = plugin.get_plugin_apps(self._multiplexer.RunPaths(),
self._logdir)
except Exception as e: # pylint: disable=broad-except
diff --git a/tensorflow/tensorboard/backend/application_test.py b/tensorflow/tensorboard/backend/application_test.py
index fbee0b0764..15884d3fdf 100644
--- a/tensorflow/tensorboard/backend/application_test.py
+++ b/tensorflow/tensorboard/backend/application_test.py
@@ -53,6 +53,7 @@ from tensorflow.python.ops import variables
from tensorflow.python.platform import gfile
from tensorflow.python.platform import resource_loader
from tensorflow.python.platform import test
+from tensorflow.python.summary import event_multiplexer
from tensorflow.python.summary.writer import writer as writer_lib
from tensorflow.python.training import saver as saver_lib
from tensorflow.tensorboard.backend import application
@@ -67,9 +68,12 @@ class TensorboardServerTest(test.TestCase):
def setUp(self):
self.temp_dir = self._GenerateTestData()
+ multiplexer = event_multiplexer.EventMultiplexer(
+ size_guidance=application.DEFAULT_SIZE_GUIDANCE,
+ purge_orphaned_data=True)
plugins = {'projector': projector_plugin.ProjectorPlugin()}
app = application.TensorBoardWSGIApp(
- self.temp_dir, plugins, reload_interval=0)
+ self.temp_dir, plugins, multiplexer, reload_interval=0)
self._server = serving.BaseWSGIServer('localhost', 0, app)
# 0 to pick an unused port.
self._server_thread = threading.Thread(target=self._server.serve_forever)
diff --git a/tensorflow/tensorboard/tensorboard.py b/tensorflow/tensorboard/tensorboard.py
index 2eaacf89e5..887b656130 100644
--- a/tensorflow/tensorboard/tensorboard.py
+++ b/tensorflow/tensorboard/tensorboard.py
@@ -23,6 +23,7 @@ from __future__ import print_function
import os
import socket
+
from werkzeug import serving
from tensorflow.python.platform import app
@@ -30,6 +31,7 @@ from tensorflow.python.platform import flags
from tensorflow.python.platform import resource_loader
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.summary import event_file_inspector as efi
+from tensorflow.python.summary import event_multiplexer
from tensorflow.tensorboard.backend import application
from tensorflow.tensorboard.plugins.projector import plugin as projector_plugin
@@ -115,11 +117,14 @@ class Server(object):
print(msg)
return -1
+ multiplexer = event_multiplexer.EventMultiplexer(
+ size_guidance=application.DEFAULT_SIZE_GUIDANCE,
+ purge_orphaned_data=FLAGS.purge_orphaned_data)
plugins = {'projector': projector_plugin.ProjectorPlugin()}
return application.TensorBoardWSGIApp(
logdir,
plugins,
- purge_orphaned_data=FLAGS.purge_orphaned_data,
+ multiplexer,
reload_interval=FLAGS.reload_interval)
def serve(self):