aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/framework
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-04 16:52:11 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-04 16:57:41 -0700
commita2e3dcdb4f439f05592b3e4698cb25a28d85a3b7 (patch)
tree2d45bd1404bc1169bc847266071f2b4ce8871c78 /tensorflow/python/framework
parent84ada6e2ce3d830f5cf3490e30f408f7459d0eab (diff)
There were two different error reporting formats within TensorFlow: `{{key value}}` and `^^key:value^^`. This change consolidate these two format.
PiperOrigin-RevId: 211550259
Diffstat (limited to 'tensorflow/python/framework')
-rw-r--r--tensorflow/python/framework/error_interpolation.py14
-rw-r--r--tensorflow/python/framework/error_interpolation_test.py22
2 files changed, 18 insertions, 18 deletions
diff --git a/tensorflow/python/framework/error_interpolation.py b/tensorflow/python/framework/error_interpolation.py
index a69018d00d..46bda2e621 100644
--- a/tensorflow/python/framework/error_interpolation.py
+++ b/tensorflow/python/framework/error_interpolation.py
@@ -15,7 +15,7 @@
"""Function for interpolating formatted errors from the TensorFlow runtime.
Exposes the function `interpolate` to interpolate messages with tags of the form
-^^type:name:format^^.
+{{type name}}.
"""
from __future__ import absolute_import
@@ -32,7 +32,7 @@ import six
from tensorflow.python.util import tf_stack
_NAME_REGEX = r"[A-Za-z0-9.][A-Za-z0-9_.\-/]*?"
-_TAG_REGEX = r"\^\^({name}):({name})\^\^".format(name=_NAME_REGEX)
+_TAG_REGEX = r"{{{{({name}) ({name})}}}}".format(name=_NAME_REGEX)
_INTERPOLATION_REGEX = r"^(.*?)({tag})".format(tag=_TAG_REGEX)
_INTERPOLATION_PATTERN = re.compile(_INTERPOLATION_REGEX)
@@ -48,8 +48,8 @@ def _parse_message(message):
"""Parses the message.
Splits the message into separators and tags. Tags are named tuples
- representing the string ^^type:name^^ and they are separated by
- separators. For example, in "123^^node:Foo^^456^^node:Bar^^789", there are
+ representing the string {{type name}} and they are separated by
+ separators. For example, in "123{{node Foo}}456{{node Bar}}789", there are
two tags and three separators. The separators are the numeric characters.
Args:
@@ -58,7 +58,7 @@ def _parse_message(message):
Returns:
(list of separator strings, list of _ParseTags).
- For example, if message is "123^^node:Foo^^456" then this function
+ For example, if message is "123{{node Foo}}456" then this function
returns (["123", "456"], [_ParseTag("node", "Foo")])
"""
seps = []
@@ -276,7 +276,7 @@ def interpolate(error_message, graph):
message.
Returns:
- The string with tags of the form ^^type:name^^ interpolated.
+ The string with tags of the form {{type name}} interpolated.
"""
seps, tags = _parse_message(error_message)
subs = []
@@ -288,7 +288,7 @@ def interpolate(error_message, graph):
except KeyError:
op = None
- msg = "^^%s:%s^^" % (t.type, t.name)
+ msg = "{{%s %s}}" % (t.type, t.name)
if op is not None:
field_dict = compute_field_dict(op)
if t.type == "node":
diff --git a/tensorflow/python/framework/error_interpolation_test.py b/tensorflow/python/framework/error_interpolation_test.py
index a7c7bbf28b..d312b825d2 100644
--- a/tensorflow/python/framework/error_interpolation_test.py
+++ b/tensorflow/python/framework/error_interpolation_test.py
@@ -167,20 +167,20 @@ class InterpolateFilenamesAndLineNumbersTest(test.TestCase):
self.assertEqual(interpolated_string, normal_string)
def testOneTagWithAFakeNameResultsInPlaceholders(self):
- one_tag_string = "^^node:MinusOne^^"
+ one_tag_string = "{{node MinusOne}}"
interpolated_string = error_interpolation.interpolate(
one_tag_string, self.graph)
self.assertEqual(one_tag_string, interpolated_string)
def testTwoTagsNoSeps(self):
- two_tags_no_seps = "^^node:One^^^^node:Three^^"
+ two_tags_no_seps = "{{node One}}{{node Three}}"
interpolated_string = error_interpolation.interpolate(
two_tags_no_seps, self.graph)
self.assertRegexpMatches(interpolated_string,
"constant_op.py:[0-9]+.*constant_op.py:[0-9]+")
def testTwoTagsWithSeps(self):
- two_tags_with_seps = ";;;^^node:Two^^,,,^^node:Three^^;;;"
+ two_tags_with_seps = ";;;{{node Two}},,,{{node Three}};;;"
interpolated_string = error_interpolation.interpolate(
two_tags_with_seps, self.graph)
expected_regex = (
@@ -206,23 +206,23 @@ class InterpolateDeviceSummaryTest(test.TestCase):
self.graph = self.three.graph
def testNodeZeroHasNoDeviceSummaryInfo(self):
- message = "^^colocation_node:zero^^"
+ message = "{{colocation_node zero}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertIn("No device assignments were active", result)
def testNodeOneHasExactlyOneInterpolatedDevice(self):
- message = "^^colocation_node:one^^"
+ message = "{{colocation_node one}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertEqual(2, result.count("tf.device(/cpu)"))
def testNodeTwoHasTwoInterpolatedDevice(self):
- message = "^^colocation_node:two^^"
+ message = "{{colocation_node two}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertEqual(2, result.count("tf.device(/cpu)"))
self.assertEqual(2, result.count("tf.device(/cpu:0)"))
def testNodeThreeHasFancyFunctionDisplayNameForInterpolatedDevice(self):
- message = "^^colocation_node:three^^"
+ message = "{{colocation_node three}}"
result = error_interpolation.interpolate(message, self.graph)
num_devices = result.count("tf.device")
self.assertEqual(2, num_devices)
@@ -256,12 +256,12 @@ class InterpolateColocationSummaryTest(test.TestCase):
self.graph = node_three.graph
def testNodeThreeHasColocationInterpolation(self):
- message = "^^colocation_node:Three_with_one^^"
+ message = "{{colocation_node Three_with_one}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertIn("colocate_with(One)", result)
def testNodeFourHasColocationInterpolationForNodeThreeOnly(self):
- message = "^^colocation_node:Four_with_three^^"
+ message = "{{colocation_node Four_with_three}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertIn("colocate_with(Three_with_one)", result)
self.assertNotIn(
@@ -269,13 +269,13 @@ class InterpolateColocationSummaryTest(test.TestCase):
"Node One should not appear in Four_with_three's summary:\n%s" % result)
def testNodeFiveHasColocationInterpolationForNodeOneAndTwo(self):
- message = "^^colocation_node:Five_with_one_with_two^^"
+ message = "{{colocation_node Five_with_one_with_two}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertIn("colocate_with(One)", result)
self.assertIn("colocate_with(Two)", result)
def testColocationInterpolationForNodeLackingColocation(self):
- message = "^^colocation_node:One^^"
+ message = "{{colocation_node One}}"
result = error_interpolation.interpolate(message, self.graph)
self.assertIn("No node-device colocations", result)
self.assertNotIn("Two", result)