def testExceptions(self):
        logdir = '/fake/foo'
        multiplexer = event_multiplexer.EventMultiplexer()

        # Fails if there is an unnamed plugin
        with self.assertRaises(ValueError):
            # This plugin lacks a name.
            plugins = [
                FakePlugin(plugin_name=None,
                           is_active_value=True,
                           routes_mapping={})
            ]
            application.TensorBoardWSGIApp(logdir, plugins, multiplexer, 0)

        # Fails if there are two plugins with same name
        with self.assertRaises(ValueError):
            plugins = [
                FakePlugin(plugin_name='foo',
                           is_active_value=True,
                           routes_mapping={}),
                FakePlugin(plugin_name='foo',
                           is_active_value=True,
                           routes_mapping={}),
            ]
            application.TensorBoardWSGIApp(logdir, plugins, multiplexer, 0)
示例#2
0
 def setUp(self):
     self.temp_dir = self._GenerateTestData()
     multiplexer = event_multiplexer.EventMultiplexer(
         size_guidance=application.DEFAULT_SIZE_GUIDANCE,
         purge_orphaned_data=True)
     plugins = [
         FakePlugin(plugin_name='foo', is_active_value=True),
         FakePlugin(plugin_name='bar', is_active_value=False)
     ]
     app = application.TensorBoardWSGIApp(self.temp_dir,
                                          plugins,
                                          multiplexer,
                                          reload_interval=0)
     try:
         self._server = serving.BaseWSGIServer('localhost', 0, app)
         # 0 to pick an unused port.
     except IOError:
         # BaseWSGIServer has a preference for IPv4. If that didn't work, try again
         # with an explicit IPv6 address.
         self._server = serving.BaseWSGIServer('::1', 0, app)
     self._server_thread = threading.Thread(
         target=self._server.serve_forever)
     self._server_thread.daemon = True
     self._server_thread.start()
     self._connection = http_client.HTTPConnection(
         'localhost', self._server.server_address[1])
 def _test(self, name, should_be_okay):
     temp_dir = tempfile.mkdtemp(prefix=self.get_temp_dir())
     self.addCleanup(shutil.rmtree, temp_dir)
     multiplexer = event_multiplexer.EventMultiplexer(
         size_guidance=application.DEFAULT_SIZE_GUIDANCE,
         purge_orphaned_data=True)
     plugins = [
         FakePlugin(plugin_name='foo',
                    is_active_value=True,
                    routes_mapping={}),
         FakePlugin(plugin_name=name,
                    is_active_value=True,
                    routes_mapping={}),
         FakePlugin(plugin_name='bar',
                    is_active_value=False,
                    routes_mapping={})
     ]
     if should_be_okay:
         application.TensorBoardWSGIApp(temp_dir,
                                        plugins,
                                        multiplexer,
                                        reload_interval=0)
     else:
         with self.assertRaisesRegexp(ValueError, r'invalid name'):
             application.TensorBoardWSGIApp(temp_dir,
                                            plugins,
                                            multiplexer,
                                            reload_interval=0)
示例#4
0
    def setUp(self):
        # Populate the log directory with debugger event for run '.'.
        self.log_dir = self.get_temp_dir()
        file_prefix = compat.as_bytes(
            os.path.join(self.log_dir, 'events.debugger'))
        writer = pywrap_tensorflow.EventsWriter(file_prefix)
        writer.WriteEvent(
            self._CreateEventWithDebugNumericSummary(op_name='layers/Matmul',
                                                     output_slot=0,
                                                     wall_time=42,
                                                     step=2,
                                                     list_of_values=[1, 2, 3]))
        writer.WriteEvent(
            self._CreateEventWithDebugNumericSummary(op_name='layers/Matmul',
                                                     output_slot=1,
                                                     wall_time=43,
                                                     step=7,
                                                     list_of_values=[4, 5, 6]))
        writer.WriteEvent(
            self._CreateEventWithDebugNumericSummary(op_name='logits/Add',
                                                     output_slot=0,
                                                     wall_time=1337,
                                                     step=7,
                                                     list_of_values=[7, 8, 9]))
        writer.WriteEvent(
            self._CreateEventWithDebugNumericSummary(
                op_name='logits/Add',
                output_slot=0,
                wall_time=1338,
                step=8,
                list_of_values=[10, 11, 12]))
        writer.Close()

        # Populate the log directory with debugger event for run 'run_foo'.
        run_foo_directory = os.path.join(self.log_dir, 'run_foo')
        os.mkdir(run_foo_directory)
        file_prefix = compat.as_bytes(
            os.path.join(run_foo_directory, 'events.debugger'))
        writer = pywrap_tensorflow.EventsWriter(file_prefix)
        writer.WriteEvent(
            self._CreateEventWithDebugNumericSummary(
                op_name='layers/Variable',
                output_slot=0,
                wall_time=4242,
                step=42,
                list_of_values=[13, 14, 15]))
        writer.Close()

        # Start a server that will receive requests and respond with health pills.
        self.multiplexer = event_multiplexer.EventMultiplexer({
            '.':
            self.log_dir,
            'run_foo':
            run_foo_directory,
        })
        self.plugin = debugger_plugin.DebuggerPlugin()
        wsgi_app = application.TensorBoardWSGIApp(self.log_dir, [self.plugin],
                                                  self.multiplexer,
                                                  reload_interval=0)
        self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
示例#5
0
 def _SetupWSGIApp(self):
   multiplexer = event_multiplexer.EventMultiplexer(
       size_guidance=application.DEFAULT_SIZE_GUIDANCE,
       purge_orphaned_data=True)
   self.plugin = projector_plugin.ProjectorPlugin()
   wsgi_app = application.TensorBoardWSGIApp(
       self.log_dir, [self.plugin], multiplexer, reload_interval=0)
   self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
示例#6
0
 def set_up_with_runs(self, with_graph=True, without_graph=True):
     self.logdir = self.get_temp_dir()
     if with_graph:
         self.generate_run(self._RUN_WITH_GRAPH, include_graph=True)
     if without_graph:
         self.generate_run(self._RUN_WITHOUT_GRAPH, include_graph=False)
     multiplexer = event_multiplexer.EventMultiplexer()
     multiplexer.AddRunsFromDirectory(self.logdir)
     multiplexer.Reload()
     self.plugin = graphs_plugin.GraphsPlugin()
     self.plugin.get_plugin_apps(multiplexer, None)
示例#7
0
    def setUp(self):
        self.log_dir = tempfile.mkdtemp()

        # We use numpy.random to generate audio. We seed to avoid non-determinism
        # in this test.
        numpy.random.seed(42)

        # Create audio summaries for run foo.
        tf.reset_default_graph()
        sess = tf.Session()
        placeholder = tf.placeholder(tf.float32)
        tf.summary.audio(name="baz", tensor=placeholder, sample_rate=44100)
        merged_summary_op = tf.summary.merge_all()
        foo_directory = os.path.join(self.log_dir, "foo")
        writer = tf.summary.FileWriter(foo_directory)
        writer.add_graph(sess.graph)
        for step in xrange(2):
            # The floats (sample data) range from -1 to 1.
            writer.add_summary(sess.run(
                merged_summary_op,
                feed_dict={placeholder: numpy.random.rand(42, 22050) * 2 - 1}),
                               global_step=step)
        writer.close()

        # Create audio summaries for run bar.
        tf.reset_default_graph()
        sess = tf.Session()
        placeholder = tf.placeholder(tf.float32)
        tf.summary.audio(name="quux", tensor=placeholder, sample_rate=44100)
        merged_summary_op = tf.summary.merge_all()
        bar_directory = os.path.join(self.log_dir, "bar")
        writer = tf.summary.FileWriter(bar_directory)
        writer.add_graph(sess.graph)
        for step in xrange(2):
            # The floats (sample data) range from -1 to 1.
            writer.add_summary(sess.run(
                merged_summary_op,
                feed_dict={placeholder: numpy.random.rand(42, 11025) * 2 - 1}),
                               global_step=step)
        writer.close()

        # Start a server with the plugin.
        multiplexer = event_multiplexer.EventMultiplexer({
            "foo": foo_directory,
            "bar": bar_directory,
        })
        plugin = audio_plugin.AudioPlugin()
        wsgi_app = application.TensorBoardWSGIApp(self.log_dir, [plugin],
                                                  multiplexer,
                                                  reload_interval=0)
        self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
        self.routes = plugin.get_plugin_apps(multiplexer, self.log_dir)
示例#8
0
 def setUp(self):
     self.temp_dir = self._GenerateTestData()
     multiplexer = event_multiplexer.EventMultiplexer(
         size_guidance=application.DEFAULT_SIZE_GUIDANCE,
         purge_orphaned_data=True)
     plugins = {}
     app = application.TensorBoardWSGIApp(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)
     self._server_thread.daemon = True
     self._server_thread.start()
     self._connection = http_client.HTTPConnection(
         'localhost', self._server.server_address[1])