Merge pull request #44855 from geetachavan1/cherrypicks_D90AR

[CherryPick:r2.4]Suppress warnings when listing functions for serialization.
This commit is contained in:
Goldie Gadde 2020-11-13 16:01:51 -08:00 committed by GitHub
commit 69ab8bdd32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ from __future__ import division
from __future__ import print_function
import copy
import warnings
from absl import logging
@ -107,7 +108,9 @@ class AutoTrackable(base.Trackable):
logging_verbosity = logging.get_verbosity()
try:
logging.set_verbosity(logging.FATAL)
attribute_value = getattr(self, attribute_name, None)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
attribute_value = getattr(self, attribute_name, None)
except Exception: # pylint: disable=broad-except
# We really don't want to throw an exception just because some object's
# attribute accessor is broken.