Skip to content
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

Don't pass a status to _reader.GetNext() #1086

Merged
merged 4 commits into from Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions tensorboard/backend/event_processing/event_file_loader.py
Expand Up @@ -18,6 +18,8 @@
from __future__ import division
from __future__ import print_function

import inspect

import tensorflow as tf


Expand Down Expand Up @@ -49,8 +51,12 @@ def Load(self):
tf.logging.debug('Loading events from %s', self._file_path)
while True:
try:
with tf.errors.raise_exception_on_not_ok_status() as status:
self._reader.GetNext(status)
if len(inspect.getargspec(self._reader.GetNext).args) is 0:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does checking for length 0 work? When i was looking at this, "self" is considered the first argument (even though it's a bound function):

>>> inspect.getargspec(reader.GetNext).args
['self', 'status']

Oops, went back to look at my example and I got the negation wrong, my bad. I should have said "not args[1:]" but at that point an explicit length check is probably clearer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also looks like pylint is complaining about getargspec being deprecated on py3.6+. For now probably fine to just suppress deprecated-method warning on this line. I think getfullargspec() is the replacement, but it's not available on Python 2...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks yeah - I saw that - I also assumed the code works fine (with the "is 0" check) since it didn't complain about this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it didn't complain because right now with existing tf-nightly len(args) == 2 so this branch isn't triggered. But when tf-nightly picks up your change, len(args) will be == 1 (since "self" will still count as an argument), so this check will still fail, even though the intent is that it should pass. So I think this should be if len(args) == 1: # only the "self" argument to anticipate that change.

self._reader.GetNext()
else:
# GetNext() expects a status argument on TF <= 1.7
with tf.errors.raise_exception_on_not_ok_status() as status:
self._reader.GetNext(status)
except (tf.errors.DataLossError, tf.errors.OutOfRangeError):
# We ignore partial read exceptions, because a record may be truncated.
# PyRecordReader holds the offset prior to the failed read, so retrying
Expand Down
11 changes: 8 additions & 3 deletions tensorboard/loader.py
Expand Up @@ -24,13 +24,14 @@
import collections
import contextlib
import functools
import inspect
import locale
import logging
import os
import re
import sys
import time
import threading
import time
import types # pylint: disable=unused-import

import six
Expand Down Expand Up @@ -115,8 +116,12 @@ def get_next_record(self):
if self._reader is None:
self._reader = self._open()
try:
with tf.errors.raise_exception_on_not_ok_status() as status:
self._reader.GetNext(status)
if len(inspect.getargspec(self._reader.GetNext).args) is 0:
self._reader.GetNext()
else:
# GetNext() expects a status argument on TF <= 1.7
with tf.errors.raise_exception_on_not_ok_status() as status:
self._reader.GetNext(status)
except tf.errors.OutOfRangeError:
# We ignore partial read exceptions, because a record may be truncated.
# PyRecordReader holds the offset prior to the failed read, so retrying
Expand Down