Suppress warnings when listing functions for serialization.

PiperOrigin-RevId: 342271395
Change-Id: Ieedeeb7817f794c41dae3eb06b9b0d3b607fa89a
This commit is contained in:
Katherine Wu 2020-11-13 08:55:39 -08:00 committed by Geeta Chavan
parent 6eee4b02a8
commit 1e548c4db7

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.