Skip to content

Commit 452cd82

Browse files
authored
mesh: fix is_active without multiplexer (#4426)
Summary: The mesh plugin’s `is_active` method had a hard dependency on the event multiplexer, which is not always available, as `TBContext` documents. In fact, the entire `is_active` method can just be `return False`, since TensorBoard core will treat the `"mesh"` plugin as active when `"mesh"` data is available, and that’s all that it was checking, anyway. Test Plan: The mesh plugin appears active in a logdir with mesh data and inactive in one without it, and when launching with `--load_fast` (and thus no multiplexer) there’s no longer any log spam about “Plugin listing: is_active() for mesh failed”. wchargin-branch: mesh-isactive
1 parent 9ad981d commit 452cd82

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

tensorboard/plugins/mesh/mesh_plugin.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,7 @@ def get_plugin_apps(self):
116116
}
117117

118118
def is_active(self):
119-
"""Determines whether this plugin is active.
120-
121-
This plugin is only active if TensorBoard sampled any summaries
122-
relevant to the mesh plugin.
123-
124-
Returns:
125-
Whether this plugin is active.
126-
"""
127-
all_runs = self._multiplexer.PluginRunToTagToContent(
128-
MeshPlugin.plugin_name
129-
)
130-
131-
# The plugin is active if any of the runs has a tag relevant
132-
# to the plugin.
133-
return bool(self._multiplexer and any(six.itervalues(all_runs)))
119+
return False # `list_plugins` as called by TB core suffices
134120

135121
def frontend_metadata(self):
136122
return base_plugin.FrontendMetadata(element_name="mesh-dashboard")

tensorboard/plugins/mesh/mesh_plugin_test.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import numpy as np
2424
import tensorflow as tf
2525
import time
26+
from unittest import mock
2627

2728
from werkzeug import test as werkzeug_test
2829
from werkzeug import wrappers
@@ -36,13 +37,6 @@
3637
from tensorboard.plugins.mesh import plugin_data_pb2
3738
from tensorboard.plugins.mesh import test_utils
3839
from tensorboard.util import test_util as tensorboard_test_util
39-
from mock import patch
40-
41-
try:
42-
# python version >= 3.3
43-
from unittest import mock
44-
except ImportError:
45-
import mock # pylint: disable=unused-import
4640

4741

4842
class MeshPluginTest(tf.test.TestCase):
@@ -129,7 +123,7 @@ def setUp(self):
129123
if step % 2 == 0
130124
else mesh_no_color_extended
131125
)
132-
with patch.object(time, "time", return_value=step):
126+
with mock.patch.object(time, "time", return_value=step):
133127
writer.add_summary(
134128
sess.run(
135129
merged_summary_op,
@@ -264,14 +258,6 @@ def testsEventsAlwaysSortedByStep(self):
264258
self.assertLessEqual(metadata[i - 1]["step"], metadata[i]["step"])
265259

266260
def testIsActive(self):
267-
self.assertTrue(self.plugin.is_active())
268-
269-
@mock.patch.object(
270-
event_multiplexer.EventMultiplexer,
271-
"PluginRunToTagToContent",
272-
return_value={},
273-
)
274-
def testIsInactive(self, get_random_mesh_stub):
275261
self.assertFalse(self.plugin.is_active())
276262

277263

0 commit comments

Comments
 (0)