mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 12:20:11 +01:00
Merge pull request #48899 from geetachavan1/cherrypicks_IAMBJ
[Cherry-Pick:2.5]disable irrelevant logging info for external users
This commit is contained in:
commit
a7b3646440
|
|
@ -21,10 +21,6 @@ from __future__ import print_function
|
|||
import datetime
|
||||
import os
|
||||
from tensorflow.python.compat import compat
|
||||
from tensorflow.python.framework import ops
|
||||
from tensorflow.python.framework import tensor_shape
|
||||
from tensorflow.python.ops import control_flow_v2_toggles
|
||||
from tensorflow.python.ops import variable_scope
|
||||
from tensorflow.python.platform import test
|
||||
|
||||
|
||||
|
|
@ -125,48 +121,6 @@ class CompatTest(test.TestCase):
|
|||
self.assertFalse(compat.forward_compatible(*ten_days_after))
|
||||
self.assertTrue(compat.forward_compatible(*one_day_after))
|
||||
|
||||
def testV2BehaviorLogging(self):
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
try:
|
||||
ops.enable_eager_execution()
|
||||
# Ignore this exception to test log output successfully
|
||||
except ValueError as e:
|
||||
if 'must be called at program startup' not in str(e):
|
||||
raise e
|
||||
|
||||
self.assertIn('Enabling eager execution', ''.join(logs.output))
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
ops.disable_eager_execution()
|
||||
self.assertIn('Disabling eager execution', ''.join(logs.output))
|
||||
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
tensor_shape.enable_v2_tensorshape()
|
||||
self.assertIn('Enabling v2 tensorshape', ''.join(logs.output))
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
tensor_shape.disable_v2_tensorshape()
|
||||
self.assertIn('Disabling v2 tensorshape', ''.join(logs.output))
|
||||
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
variable_scope.enable_resource_variables()
|
||||
self.assertIn('Enabling resource variables', ''.join(logs.output))
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
variable_scope.disable_resource_variables()
|
||||
self.assertIn('Disabling resource variables', ''.join(logs.output))
|
||||
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
ops.enable_tensor_equality()
|
||||
self.assertIn('Enabling tensor equality', ''.join(logs.output))
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
ops.disable_tensor_equality()
|
||||
self.assertIn('Disabling tensor equality', ''.join(logs.output))
|
||||
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
control_flow_v2_toggles.enable_control_flow_v2()
|
||||
self.assertIn('Enabling control flow v2', ''.join(logs.output))
|
||||
with self.assertLogs(level='INFO') as logs:
|
||||
control_flow_v2_toggles.disable_control_flow_v2()
|
||||
self.assertIn('Disabling control flow v2', ''.join(logs.output))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test.main()
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ def enable_tensor_equality():
|
|||
unhashable. Thus tensors can no longer be directly used in sets or as a key in
|
||||
a dictionary.
|
||||
"""
|
||||
logging.info("Enabling tensor equality")
|
||||
logging.vlog(1, "Enabling tensor equality")
|
||||
_tensor_equality_api_usage_gauge.get_cell().set(True)
|
||||
Tensor._USE_EQUALITY = True # pylint: disable=protected-access
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ def disable_tensor_equality():
|
|||
|
||||
This is a legacy behaviour of TensorFlow and is highly discouraged.
|
||||
"""
|
||||
logging.info("Disabling tensor equality")
|
||||
logging.vlog(1, "Disabling tensor equality")
|
||||
_tensor_equality_api_usage_gauge.get_cell().set(False)
|
||||
Tensor._USE_EQUALITY = False # pylint: disable=protected-access
|
||||
|
||||
|
|
@ -5890,7 +5890,7 @@ def enable_eager_execution(config=None, device_policy=None,
|
|||
to this function.
|
||||
"""
|
||||
_api_usage_gauge.get_cell().set(True)
|
||||
logging.info("Enabling eager execution")
|
||||
logging.vlog(1, "Enabling eager execution")
|
||||
if context.default_execution_mode != context.EAGER_MODE:
|
||||
return enable_eager_execution_internal(
|
||||
config=config,
|
||||
|
|
@ -5908,7 +5908,7 @@ def disable_eager_execution():
|
|||
projects from TensorFlow 1.x to 2.x.
|
||||
"""
|
||||
_api_usage_gauge.get_cell().set(False)
|
||||
logging.info("Disabling eager execution")
|
||||
logging.vlog(1, "Disabling eager execution")
|
||||
context.default_execution_mode = context.GRAPH_MODE
|
||||
c = context.context_safe()
|
||||
if c is not None:
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ def enable_v2_tensorshape():
|
|||
"""
|
||||
global _TENSORSHAPE_V2_OVERRIDE # pylint: disable=invalid-name
|
||||
_TENSORSHAPE_V2_OVERRIDE = True
|
||||
logging.info("Enabling v2 tensorshape")
|
||||
logging.vlog(1, "Enabling v2 tensorshape")
|
||||
_api_usage_gauge.get_cell().set(True)
|
||||
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ def disable_v2_tensorshape():
|
|||
"""
|
||||
global _TENSORSHAPE_V2_OVERRIDE # pylint: disable=invalid-name
|
||||
_TENSORSHAPE_V2_OVERRIDE = False
|
||||
logging.info("Disabling v2 tensorshape")
|
||||
logging.vlog(1, "Disabling v2 tensorshape")
|
||||
_api_usage_gauge.get_cell().set(False)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ def enable_control_flow_v2(): # pylint: disable=invalid-name
|
|||
function is not required.
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
logging.info("Enabling control flow v2")
|
||||
logging.vlog(1, "Enabling control flow v2")
|
||||
ops._control_flow_api_gauge.get_cell().set(True)
|
||||
control_flow_util.ENABLE_CONTROL_FLOW_V2 = True
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ def disable_control_flow_v2(): # pylint: disable=invalid-name
|
|||
properly please file a bug.
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
logging.info("Disabling control flow v2")
|
||||
logging.vlog(1, "Disabling control flow v2")
|
||||
ops._control_flow_api_gauge.get_cell().set(False)
|
||||
control_flow_util.ENABLE_CONTROL_FLOW_V2 = False
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ def enable_resource_variables():
|
|||
"""
|
||||
global _DEFAULT_USE_RESOURCE
|
||||
_DEFAULT_USE_RESOURCE = True
|
||||
logging.info("Enabling resource variables")
|
||||
logging.vlog(1, "Enabling resource variables")
|
||||
_api_usage_gauge.get_cell().set(True)
|
||||
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ def disable_resource_variables():
|
|||
"""
|
||||
global _DEFAULT_USE_RESOURCE
|
||||
_DEFAULT_USE_RESOURCE = False
|
||||
logging.info("Disabling resource variables")
|
||||
logging.vlog(1, "Disabling resource variables")
|
||||
_api_usage_gauge.get_cell().set(False)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user