Skip to content

Commit d736dee

Browse files
committed
replace TensorBoardWSGIApp in plugin tests with TensorBoardWSGI and explicit Reload()
1 parent 2b96c2a commit d736dee

File tree

8 files changed

+19
-48
lines changed

8 files changed

+19
-48
lines changed

tensorboard/plugins/audio/audio_plugin_test.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,12 @@ def setUp(self):
9292
"foo": foo_directory,
9393
"bar": bar_directory,
9494
})
95+
multiplexer.Reload()
9596
context = base_plugin.TBContext(
9697
logdir=self.log_dir, multiplexer=multiplexer)
9798
self.plugin = audio_plugin.AudioPlugin(context)
98-
# Setting a reload interval of -1 disables reloading. We disable reloading
99-
# because we seek to block tests from running til after one reload finishes.
100-
# This setUp method thus manually reloads the multiplexer. TensorBoard would
101-
# otherwise reload in a non-blocking thread.
102-
wsgi_app = application.TensorBoardWSGIApp(
103-
self.log_dir, [self.plugin], multiplexer, reload_interval=-1,
104-
path_prefix='')
99+
wsgi_app = application.TensorBoardWSGI([self.plugin])
105100
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
106-
multiplexer.Reload()
107101

108102
def tearDown(self):
109103
shutil.rmtree(self.log_dir, ignore_errors=True)

tensorboard/plugins/core/core_plugin_test.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,7 @@ def _start_logdir_based_server(self, temp_dir):
302302
multiplexer=self.multiplexer,
303303
window_title='title foo')
304304
self.logdir_based_plugin = core_plugin.CorePlugin(context)
305-
app = application.TensorBoardWSGIApp(
306-
self.logdir,
307-
[self.logdir_based_plugin],
308-
self.multiplexer,
309-
0,
310-
path_prefix='')
305+
app = application.TensorBoardWSGI([self.logdir_based_plugin])
311306
self.logdir_based_server = werkzeug_test.Client(app, wrappers.BaseResponse)
312307

313308
def _start_db_based_server(self):

tensorboard/plugins/debugger/debugger_plugin_testlib.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ def setUp(self):
120120
writer.Close()
121121

122122
# Start a server that will receive requests and respond with health pills.
123-
self.multiplexer = event_multiplexer.EventMultiplexer({
123+
multiplexer = event_multiplexer.EventMultiplexer({
124124
'.': self.log_dir,
125125
'run_foo': run_foo_directory,
126126
})
127+
multiplexer.Reload()
127128
self.debugger_data_server_grpc_port = portpicker.pick_unused_port()
128129

129130
# Fake threading behavior so that threads are synchronous.
@@ -141,12 +142,10 @@ def setUp(self):
141142
self.mock_debugger_data_server_class).start()
142143

143144
self.context = base_plugin.TBContext(
144-
logdir=self.log_dir, multiplexer=self.multiplexer)
145+
logdir=self.log_dir, multiplexer=multiplexer)
145146
self.plugin = debugger_plugin.DebuggerPlugin(self.context)
146147
self.plugin.listen(self.debugger_data_server_grpc_port)
147-
wsgi_app = application.TensorBoardWSGIApp(
148-
self.log_dir, [self.plugin], self.multiplexer, reload_interval=0,
149-
path_prefix='')
148+
wsgi_app = application.TensorBoardWSGI([self.plugin])
150149
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
151150

152151
# The debugger data server should be started at the correct port.

tensorboard/plugins/debugger/interactive_debugger_plugin_test.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,16 @@ def setUp(self):
5555
super(InteractiveDebuggerPluginTest, self).setUp()
5656

5757
self._dummy_logdir = tempfile.mkdtemp()
58-
self._dummy_multiplexer = event_multiplexer.EventMultiplexer({})
58+
dummy_multiplexer = event_multiplexer.EventMultiplexer({})
5959
self._debugger_port = portpicker.pick_unused_port()
6060
self._debugger_url = 'grpc://localhost:%d' % self._debugger_port
6161
context = base_plugin.TBContext(logdir=self._dummy_logdir,
62-
multiplexer=self._dummy_multiplexer)
62+
multiplexer=dummy_multiplexer)
6363
self._debugger_plugin = (
6464
interactive_debugger_plugin.InteractiveDebuggerPlugin(context))
6565
self._debugger_plugin.listen(self._debugger_port)
6666

67-
wsgi_app = application.TensorBoardWSGIApp(
68-
self._dummy_logdir,
69-
[self._debugger_plugin],
70-
self._dummy_multiplexer,
71-
reload_interval=0,
72-
path_prefix='')
67+
wsgi_app = application.TensorBoardWSGI([self._debugger_plugin])
7368
self._server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
7469

7570
def tearDown(self):

tensorboard/plugins/image/images_plugin_test.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,12 @@ def setUp(self):
8686
"foo": foo_directory,
8787
"bar": bar_directory,
8888
})
89+
multiplexer.Reload()
8990
context = base_plugin.TBContext(
9091
logdir=self.log_dir, multiplexer=multiplexer)
9192
plugin = images_plugin.ImagesPlugin(context)
92-
# Setting a reload interval of -1 disables reloading. We disable reloading
93-
# because we seek to block tests from running til after one reload finishes.
94-
# This setUp method thus manually reloads the multiplexer. TensorBoard would
95-
# otherwise reload in a non-blocking thread.
96-
wsgi_app = application.TensorBoardWSGIApp(
97-
self.log_dir, [plugin], multiplexer, reload_interval=-1, path_prefix='')
93+
wsgi_app = application.TensorBoardWSGI([plugin])
9894
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
99-
multiplexer.Reload()
10095
self.routes = plugin.get_plugin_apps()
10196

10297
def tearDown(self):

tensorboard/plugins/interactive_inference/interactive_inference_plugin_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ def setUp(self):
5454
self.context = base_plugin.TBContext(logdir=self.logdir)
5555
self.plugin = interactive_inference_plugin.InteractiveInferencePlugin(
5656
self.context)
57-
wsgi_app = application.TensorBoardWSGIApp(
58-
self.logdir, [self.plugin],
59-
multiplexer=event_multiplexer.EventMultiplexer({}),
60-
reload_interval=0,
61-
path_prefix='')
57+
wsgi_app = application.TensorBoardWSGI([self.plugin])
6258
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
6359

6460
def get_fake_example(self, single_int_value=0):

tensorboard/plugins/mesh/mesh_plugin_test.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,12 @@ def setUp(self):
129129
self.context = base_plugin.TBContext(
130130
logdir=self.log_dir, multiplexer=self.multiplexer)
131131
self.plugin = mesh_plugin.MeshPlugin(self.context)
132-
wsgi_app = application.TensorBoardWSGIApp(
133-
self.log_dir, [self.plugin],
134-
self.multiplexer,
135-
reload_interval=0,
136-
path_prefix="")
137-
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
132+
# Wait until after plugin construction to reload the multiplexer because the
133+
# plugin caches data from the multiplexer upon construction and this affects
134+
# logic tested later down.
138135
self.multiplexer.Reload()
136+
wsgi_app = application.TensorBoardWSGI([self.plugin])
137+
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
139138
self.routes = self.plugin.get_plugin_apps()
140139

141140
def tearDown(self):

tensorboard/plugins/projector/projector_plugin_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ def _SetupWSGIApp(self):
273273
context = base_plugin.TBContext(
274274
logdir=self.log_dir, multiplexer=multiplexer)
275275
self.plugin = projector_plugin.ProjectorPlugin(context)
276-
wsgi_app = application.TensorBoardWSGIApp(
277-
self.log_dir, [self.plugin], multiplexer, reload_interval=0,
278-
path_prefix='')
276+
wsgi_app = application.TensorBoardWSGI([self.plugin])
279277
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
280278

281279
def _Get(self, path):

0 commit comments

Comments
 (0)