-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Silence deprecation warning spam about tf_record_iterator #3319
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
Silence deprecation warning spam about tf_record_iterator #3319
Conversation
| try: | ||
| # Learn this one weird trick to make TF deprecation warnings go away. | ||
| from tensorflow.python.util import deprecation | ||
| return deprecation.silence() | ||
| except (ImportError, AttributeError): | ||
| return _NULL_CONTEXT |
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.
You could avoid the _NULL_CONTEXT backport with something like this:
@contextlib.contextmanager
def _silence_deprecation_warnings():
try:
# Learn this one weird trick to make TF deprecation warnings go away.
from tensorflow.python.util import deprecation
cm = deprecation.silence()
except (ImportError, AttributeError):
yield
else:
with cm:
yield(Or cm = None; ...; if cm is not None: ... if you dislike the else.)
If you prefer it as is, then nit: nullcontext, not null_context.
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.
Fixed spelling. IMO it's actually simpler and more readable just to use the null context manager and have an either-or rather than nested context managers?
Especially given that it's essentially no code to backport (I didn't even realize there was a stdlib one in any version until I checked on a whim).
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.
Okay; fine with me if you prefer this.
|
Also, wow: my Noto doesn’t have U+1FA79. I guess there’s still some Tofu |
| try: | ||
| # Learn this one weird trick to make TF deprecation warnings go away. | ||
| from tensorflow.python.util import deprecation | ||
| return deprecation.silence() | ||
| except (ImportError, AttributeError): | ||
| return _NULL_CONTEXT |
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.
Okay; fine with me if you prefer this.
This puts a nice 🩹 over the deprecation warning spam emitted to the console by our usage of
tf.compat.v1.io.tf_record_iterator(which we now do for new TF versions, as of #3185).Actually migrating to something not deprecated is still tracked in #1711.