Skip to content

Commit 15ff2f5

Browse files
committedOct 5, 2019
fix TensorBoardWSGIApp method signature changed
1 parent 2a012b5 commit 15ff2f5

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed
 

‎jupyter_tensorboard/tensorboard_manager.py

+61-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,63 @@ def _ReloadForever():
108108
return thread
109109

110110

111-
def TensorBoardWSGIApp(logdir, plugins, multiplexer,
111+
def is_tensorboard_greater_than_or_equal_to20():
112+
import tensorflow
113+
version = tensorflow.__version__.split(".")
114+
return int(version[0]) >= 2
115+
116+
117+
def TensorBoardWSGIApp_2x(
118+
flags,
119+
plugins,
120+
data_provider=None,
121+
assets_zip_provider=None,
122+
deprecated_multiplexer=None):
123+
124+
logdir = flags.logdir
125+
multiplexer = deprecated_multiplexer
126+
reload_interval = flags.reload_interval
127+
128+
path_to_run = application.parse_event_files_spec(logdir)
129+
if reload_interval:
130+
thread = start_reloading_multiplexer(
131+
multiplexer, path_to_run, reload_interval)
132+
else:
133+
application.reload_multiplexer(multiplexer, path_to_run)
134+
thread = None
135+
136+
137+
db_uri = None
138+
db_connection_provider = None
139+
140+
plugin_name_to_instance = {}
141+
142+
from tensorboard.plugins import base_plugin
143+
context = base_plugin.TBContext(
144+
data_provider=data_provider,
145+
db_connection_provider=db_connection_provider,
146+
db_uri=db_uri,
147+
flags=flags,
148+
logdir=flags.logdir,
149+
multiplexer=deprecated_multiplexer,
150+
assets_zip_provider=assets_zip_provider,
151+
plugin_name_to_instance=plugin_name_to_instance,
152+
window_title=flags.window_title)
153+
154+
tbplugins = []
155+
for loader in plugins:
156+
plugin = loader.load(context)
157+
if plugin is None:
158+
continue
159+
tbplugins.append(plugin)
160+
plugin_name_to_instance[plugin.plugin_name] = plugin
161+
162+
tb_app = application.TensorBoardWSGI(tbplugins)
163+
manager.add_instance(logdir, tb_app, thread)
164+
return tb_app
165+
166+
167+
def TensorBoardWSGIApp_1x(logdir, plugins, multiplexer,
112168
reload_interval, path_prefix="", reload_task="auto"):
113169
path_to_run = application.parse_event_files_spec(logdir)
114170
if reload_interval:
@@ -122,7 +178,10 @@ def TensorBoardWSGIApp(logdir, plugins, multiplexer,
122178
return tb_app
123179

124180

125-
application.TensorBoardWSGIApp = TensorBoardWSGIApp
181+
if is_tensorboard_greater_than_or_equal_to20():
182+
application.TensorBoardWSGIApp = TensorBoardWSGIApp_2x
183+
else:
184+
application.TensorBoardWSGIApp = TensorBoardWSGIApp_1x
126185

127186

128187
class TensorboardManger(dict):

‎tests/test_tensorboard_integration.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
def tf_logs(tmpdir_factory):
1414

1515
import numpy as np
16-
import tensorflow as tf
16+
try:
17+
import tensorflow.compat.v1 as tf
18+
tf.disable_v2_behavior()
19+
except:
20+
import tensorflow as tf
21+
1722
x = np.random.rand(5)
1823
y = 3 * x + 1 + 0.05 * np.random.rand(5)
1924

‎tox.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[tox]
2-
envlist = {py27,py34,py35,py36}-tensorflow{13,14,15,16,17,18,19,110,111,112,113}
2+
envlist = {py34,py35,py36}-tensorflow{13,14,15,16,17,18,19,110,111,112,113,200}
3+
34

45
[testenv]
56
deps =
@@ -15,6 +16,7 @@ deps =
1516
tensorflow111: tensorflow>=1.11, <1.12
1617
tensorflow112: tensorflow>=1.12, <1.13
1718
tensorflow113: tensorflow<=1.13, <1.14
19+
tensorflow200: tensorflow<=2.0, <2.1
1820

1921
commands =
2022
pytest
@@ -23,4 +25,4 @@ alwayscopy = True
2325

2426
[testenv:py36]
2527
commands =
26-
flake8
28+
flake8

0 commit comments

Comments
 (0)
Please sign in to comment.