-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Debugger Plugin] Fix Python unit tests for TF2 #2583
Changes from all commits
5cd83e6
e578b0e
febcd0e
7db7a6b
05949e0
ddc7316
b08ea52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
import numpy as np | ||
import portpicker # pylint: disable=import-error | ||
from six.moves import urllib # pylint: disable=wrong-import-order | ||
import tensorflow as tf # pylint: disable=wrong-import-order | ||
import tensorflow.compat.v1 as tf # pylint: disable=wrong-import-order | ||
from tensorflow.python import debug as tf_debug # pylint: disable=wrong-import-order | ||
from werkzeug import test as werkzeug_test # pylint: disable=wrong-import-order | ||
from werkzeug import wrappers # pylint: disable=wrong-import-order | ||
|
@@ -44,11 +44,14 @@ | |
from tensorboard.plugins.debugger import interactive_debugger_plugin | ||
from tensorboard.util import test_util | ||
|
||
# These unit tests for Debugger Plugin V1 are tied to TF1.x behavior | ||
# (`tf.Session`s). | ||
tf.disable_v2_behavior() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting: simply adding In the short term, this patch is great because it lets us continue to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a comment here. The Debugger Plugin is currently tied to v1 behavior ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, that makes sense. But if session and node behavior were the only (This isn’t necessarily a blocking question, but I would be interested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirmed what you said. It seems that making only the change of
leads to hanging tests. This looks like some unexpected behavior in how As you said, this doesn't have to be blocking. I can make a TODO item for myself to investigate it and potentially file bug for tensorflow while merging this PR. LMK WYT. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using This is good to merge; feel free to investigate iff you feel like it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'll merge the PR. Thanks for the review. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me be concrete: the patch that I’m talking about is simply diff --git a/tensorboard/plugins/debugger/interactive_debugger_plugin_test.py b/tensorboard/plugins/debugger/interactive_debugger_plugin_test.py
index 1b127456..653af030 100644
--- a/tensorboard/plugins/debugger/interactive_debugger_plugin_test.py
+++ b/tensorboard/plugins/debugger/interactive_debugger_plugin_test.py
@@ -45,6 +45,9 @@ from tensorboard.plugins.debugger import interactive_debugger_plugin
from tensorboard.util import test_util
+tf.compat.v1.disable_v2_behavior()
+
+
_SERVER_URL_PREFIX = '/data/plugin/debugger/'
against This properly disables V2 behavior, does not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged. Thanks for the concrete info. |
||
|
||
|
||
_SERVER_URL_PREFIX = '/data/plugin/debugger/' | ||
|
||
|
||
@test_util.run_v1_only('Test fails to run and clean up properly; they time out.') | ||
class InteractiveDebuggerPluginTest(tf.test.TestCase): | ||
|
||
def setUp(self): | ||
|
@@ -116,14 +119,14 @@ def _deserializeResponse(self, response): | |
def _runSimpleAddMultiplyGraph(self, variable_size=1): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
a = tf.Variable([10.0] * variable_size, name='a') | ||
b = tf.Variable([20.0] * variable_size, name='b') | ||
c = tf.Variable([30.0] * variable_size, name='c') | ||
x = tf.multiply(a, b, name="x") | ||
y = tf.add(x, c, name="y") | ||
|
||
sess.run(tf.compat.v1.global_variables_initializer()) | ||
sess.run(tf.global_variables_initializer()) | ||
|
||
sess = tf_debug.TensorBoardDebugWrapperSession(sess, self._debugger_url) | ||
session_run_results.append(sess.run(y)) | ||
|
@@ -134,12 +137,12 @@ def session_run_job(): | |
def _runMultiStepAssignAddGraph(self, steps): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
a = tf.Variable(10, dtype=tf.int32, name='a') | ||
b = tf.Variable(1, dtype=tf.int32, name='b') | ||
inc_a = tf.compat.v1.assign_add(a, b, name='inc_a') | ||
inc_a = tf.assign_add(a, b, name='inc_a') | ||
|
||
sess.run(tf.compat.v1.global_variables_initializer()) | ||
sess.run(tf.global_variables_initializer()) | ||
|
||
sess = tf_debug.TensorBoardDebugWrapperSession(sess, self._debugger_url) | ||
for _ in range(steps): | ||
|
@@ -151,15 +154,15 @@ def session_run_job(): | |
def _runTfGroupGraph(self): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
a = tf.Variable(10, dtype=tf.int32, name='a') | ||
b = tf.Variable(20, dtype=tf.int32, name='b') | ||
d = tf.constant(1, dtype=tf.int32, name='d') | ||
inc_a = tf.compat.v1.assign_add(a, d, name='inc_a') | ||
inc_b = tf.compat.v1.assign_add(b, d, name='inc_b') | ||
inc_a = tf.assign_add(a, d, name='inc_a') | ||
inc_b = tf.assign_add(b, d, name='inc_b') | ||
inc_ab = tf.group([inc_a, inc_b], name="inc_ab") | ||
|
||
sess.run(tf.compat.v1.global_variables_initializer()) | ||
sess.run(tf.global_variables_initializer()) | ||
|
||
sess = tf_debug.TensorBoardDebugWrapperSession(sess, self._debugger_url) | ||
session_run_results.append(sess.run(inc_ab)) | ||
|
@@ -708,7 +711,7 @@ def testGetSourceOpTraceback(self): | |
def _runInitializer(self): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
a = tf.Variable([10.0] * 10, name='a') | ||
sess = tf_debug.TensorBoardDebugWrapperSession(sess, self._debugger_url) | ||
# Run the initializer with a debugger-wrapped tf.Session. | ||
|
@@ -786,7 +789,7 @@ def testCommDataForUninitializedTensorIsHandledCorrectly(self): | |
def _runHealthPillNetwork(self): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
a = tf.Variable( | ||
[np.nan, np.inf, np.inf, -np.inf, -np.inf, -np.inf, 10, 20, 30], | ||
dtype=tf.float32, name='a') | ||
|
@@ -833,11 +836,11 @@ def testHealthPill(self): | |
def _runAsciiStringNetwork(self): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
str1 = tf.Variable('abc', name='str1') | ||
str2 = tf.Variable('def', name='str2') | ||
str_concat = tf.add(str1, str2, name='str_concat') | ||
sess.run(tf.compat.v1.global_variables_initializer()) | ||
sess.run(tf.global_variables_initializer()) | ||
sess = tf_debug.TensorBoardDebugWrapperSession(sess, self._debugger_url) | ||
session_run_results.append(sess.run(str_concat)) | ||
session_run_thread = threading.Thread(target=session_run_job) | ||
|
@@ -890,11 +893,11 @@ def testAsciiStringTensorIsHandledCorrectly(self): | |
def _runBinaryStringNetwork(self): | ||
session_run_results = [] | ||
def session_run_job(): | ||
with tf.compat.v1.Session() as sess: | ||
with tf.Session() as sess: | ||
str1 = tf.Variable([b'\x01' * 3, b'\x02' * 3], name='str1') | ||
str2 = tf.Variable([b'\x03' * 3, b'\x04' * 3], name='str2') | ||
str_concat = tf.add(str1, str2, name='str_concat') | ||
sess.run(tf.compat.v1.global_variables_initializer()) | ||
sess.run(tf.global_variables_initializer()) | ||
sess = tf_debug.TensorBoardDebugWrapperSession(sess, self._debugger_url) | ||
session_run_results.append(sess.run(str_concat)) | ||
session_run_thread = threading.Thread(target=session_run_job) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add
(as in
test_util.py
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.