Skip to content

Conversation

@caisq
Copy link
Contributor

@caisq caisq commented May 20, 2018

  • Binary strings (strings that cannot be encoded in JSON, as is the case
    with output tensors of Summary ops) are now converted to a printable
    format using Python's binascii.b2a_qp().
  • To prevent overloading the frontend and frontend-backend
    communication, long string elements are truncated at 40 bytes.
  • Display dtype 'object' as 'string' for clarity.

caisq added 2 commits May 19, 2018 23:40
* Binary strings (strings that cannot be encoded in JSON, as is the case
  with output tensors of Summary ops) is now converted to a printable
  format using Python's `binascii.b2a_qp()`.
* To prevent overloading the frontend and frontend-backend
  communication, long string elements are truncated at 40 bytes.
* Display dtype 'object' as 'string' for clarity.
@caisq caisq requested a review from chihuahua May 20, 2018 03:51
@caisq
Copy link
Contributor Author

caisq commented May 20, 2018

@chihuahua See screenshot for the effect of this CL.

image

@caisq
Copy link
Contributor Author

caisq commented May 21, 2018

@chihuahua @nfelt It seems that the Travis test jobs are failing for unrelated reasons:

Traceback (most recent call last):
File "/home/travis/.bazel-output-base/bazel-sandbox/7413091653513360136/execroot/org_tensorflow_tensorboard/bazel-out/k8-fastbuild/bin/tensorboard/plugins/pr_curve/pr_curves_plugin_test.runfiles/org_tensorflow_tensorboard/tensorboard/plugins/pr_curve/pr_curves_plugin_test.py", line 27, in
import tensorflow as tf
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/init.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/python/init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)

@jart
Copy link
Contributor

jart commented May 21, 2018

If you run bazel test //tensorboard/... and it works, I'll use admin privileges to merge anyway.

This is a known issue. Kokoro switched to GCC 4.9 because NVidia and Docker, which isn't compatible with RHEL, CentOS, Ubuntu14, Travis, etc. I got them to reconsider that decision last week. We're still waiting on the new nightlies to go live. The same thing happened back in January. I'm reaching that point where I'm about to roll my own binaries. Would you support me?

Copy link
Member

@chihuahua chihuahua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Shanqing for fixing this bug!

def translate_dtype(dtype):
"""Translate numpy dtype into a string.
The 'object' type is understood as a tenosrflow string and translated into
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: TensorFlow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"""Process a buffer for human-readable display.
This function performs the following operation on each of the buffers in `s`.
1. Truncate input buffer if the length of the buffer is greater than
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe briefly offer some rationale on why we truncate in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

length = len(s)
if length > limit:
return (binascii.b2a_qp(s[:limit]) +
b' (length-%s truncated at %s bytes)' % (length, limit))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think both should be %ds.

length = len(s)
if length > limit:
return (binascii.b2a_qp(s[:limit]) +
b' (length-%s truncated at %s bytes)' % (length, limit))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also nit: Any reason for this to be a binary string specifically (prefixed with b')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for Python2-3 compatibility. Without the b, the string will end up being a unicode string in Python3 and cannot be concatenated with the output of binascii.b2a_qp.

Copy link
Contributor Author

@caisq caisq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the review! @chihuahua

def translate_dtype(dtype):
"""Translate numpy dtype into a string.
The 'object' type is understood as a tenosrflow string and translated into
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"""Process a buffer for human-readable display.
This function performs the following operation on each of the buffers in `s`.
1. Truncate input buffer if the length of the buffer is greater than
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

length = len(s)
if length > limit:
return (binascii.b2a_qp(s[:limit]) +
b' (length-%s truncated at %s bytes)' % (length, limit))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for Python2-3 compatibility. Without the b, the string will end up being a unicode string in Python3 and cannot be concatenated with the output of binascii.b2a_qp.

@caisq
Copy link
Contributor Author

caisq commented May 23, 2018

@jart thanks for the info on the test failures. I've run the tests and made sure the tests all pass under both py2 and py3. So I'll merge the PR now.

@chihuahua Thanks again for your review!!

@caisq
Copy link
Contributor Author

caisq commented May 24, 2018

@jart This PR is ready for merging.

@jart
Copy link
Contributor

jart commented May 24, 2018

I feel guilty merging when Travis is red, but it appears to be a pylint error, and we just removed that in #1207.

@jart jart merged commit 5f7331f into tensorflow:master May 24, 2018
@caisq
Copy link
Contributor Author

caisq commented May 24, 2018

Thanks, @jart!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants