From 119de52436356541e5f8e6c48d787f3cc96a351b Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 14 Jun 2019 13:24:20 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 253284909 --- tensorflow/python/tools/api/generator/create_python_api.py | 3 +-- tensorflow/tools/api/tests/deprecation_test.py | 7 +++---- tensorflow/virtual_root_template_v1.__init__.py | 6 ++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tensorflow/python/tools/api/generator/create_python_api.py b/tensorflow/python/tools/api/generator/create_python_api.py index 0a799f90003..1bae5ef406a 100644 --- a/tensorflow/python/tools/api/generator/create_python_api.py +++ b/tensorflow/python/tools/api/generator/create_python_api.py @@ -225,8 +225,7 @@ __all__.extend([_s for _s in _names_with_underscore]) if self._api_version == 1: # Add 1.* deprecations. for dest_module, _ in self._module_imports.items(): - if (dest_module and - not dest_module.startswith(_COMPAT_MODULE_PREFIX)): + if not dest_module.startswith(_COMPAT_MODULE_PREFIX): footer_text_map[dest_module] = _DEPRECATION_FOOTER % ( dest_module) diff --git a/tensorflow/tools/api/tests/deprecation_test.py b/tensorflow/tools/api/tests/deprecation_test.py index e3dd61bb612..04bd636c3b2 100644 --- a/tensorflow/tools/api/tests/deprecation_test.py +++ b/tensorflow/tools/api/tests/deprecation_test.py @@ -1,4 +1,3 @@ - # Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +28,7 @@ from tensorflow.python.platform import tf_logging as logging class DeprecationTest(test.TestCase): @test.mock.patch.object(logging, "warning", autospec=True) - def DISABLED_testDeprecatedFunction(self, mock_warning): + def testDeprecatedFunction(self, mock_warning): self.assertEqual(0, mock_warning.call_count) tf.compat.v1.initializers.tables_initializer() self.assertEqual(0, mock_warning.call_count) @@ -70,7 +69,7 @@ class DeprecationTest(test.TestCase): self.assertEqual(1, mock_warning.call_count) @test.mock.patch.object(logging, "warning", autospec=True) - def DISABLED_testDeprecatedFunctionEndpoint(self, mock_warning): + def testDeprecatedFunctionEndpoint(self, mock_warning): array = tf.IndexedSlices( tf.compat.v1.convert_to_tensor(np.array([1, 2])), tf.compat.v1.convert_to_tensor(np.array([0, 2]))) @@ -94,7 +93,7 @@ class DeprecationTest(test.TestCase): self.assertEqual(1, mock_warning.call_count) @test.mock.patch.object(logging, "warning", autospec=True) - def DISABLED_testDeprecatedClassEndpoint(self, mock_warning): + def testDeprecatedClassEndpoint(self, mock_warning): self.assertEqual(0, mock_warning.call_count) tf.io.VarLenFeature(tf.dtypes.int32) self.assertEqual(0, mock_warning.call_count) diff --git a/tensorflow/virtual_root_template_v1.__init__.py b/tensorflow/virtual_root_template_v1.__init__.py index 0e700c1ad27..bb076759e60 100644 --- a/tensorflow/virtual_root_template_v1.__init__.py +++ b/tensorflow/virtual_root_template_v1.__init__.py @@ -120,4 +120,10 @@ try: except ImportError as e: pass +# In V1 API we need to print deprecation messages +from tensorflow.python.util import deprecation_wrapper as _deprecation +if not isinstance(_sys.modules[__name__], _deprecation.DeprecationWrapper): + _sys.modules[__name__] = _deprecation.DeprecationWrapper( + _sys.modules[__name__], "") + # LINT.ThenChange(//tensorflow/virtual_root_template_v2.__init__.py.oss)