From a9bac8c984f2b3b6579d25c60b386a3f32d5c537 Mon Sep 17 00:00:00 2001 From: Anna R Date: Mon, 8 Apr 2019 15:38:40 -0700 Subject: [PATCH] Remove pywrap_tensorflow from compat.v1. PiperOrigin-RevId: 242552670 --- tensorflow/compat_template_v1.__init__.py | 1 - tensorflow/tools/api/tests/api_compatibility_test.py | 6 ++++-- tensorflow/tools/compatibility/tf_upgrade_v2.py | 10 +++++++--- tensorflow/tools/compatibility/tf_upgrade_v2_test.py | 7 +++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tensorflow/compat_template_v1.__init__.py b/tensorflow/compat_template_v1.__init__.py index 9549a71c41a..64dd293f113 100644 --- a/tensorflow/compat_template_v1.__init__.py +++ b/tensorflow/compat_template_v1.__init__.py @@ -21,7 +21,6 @@ from __future__ import print_function as _print_function import os as _os # pylint: disable=g-bad-import-order -from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import # API IMPORTS PLACEHOLDER diff --git a/tensorflow/tools/api/tests/api_compatibility_test.py b/tensorflow/tools/api/tests/api_compatibility_test.py index 0c1f9de1a36..c2cafd4284b 100644 --- a/tensorflow/tools/api/tests/api_compatibility_test.py +++ b/tensorflow/tools/api/tests/api_compatibility_test.py @@ -373,8 +373,10 @@ class ApiCompatibilityTest(test.TestCase): golden_file_pattern = os.path.join( resource_loader.get_root_dir_with_all_resources(), _KeyToFilePath('*', api_version)) - self._checkBackwardsCompatibility(tf.compat.v1, golden_file_pattern, - api_version) + self._checkBackwardsCompatibility( + tf.compat.v1, golden_file_pattern, api_version, + additional_private_map={'tf': ['pywrap_tensorflow']}, + omit_golden_symbols_map={'tensorflow': ['pywrap_tensorflow']}) def testAPIBackwardsCompatibilityV2(self): api_version = 2 diff --git a/tensorflow/tools/compatibility/tf_upgrade_v2.py b/tensorflow/tools/compatibility/tf_upgrade_v2.py index dcb5d556564..0c1fdb81f5a 100644 --- a/tensorflow/tools/compatibility/tf_upgrade_v2.py +++ b/tensorflow/tools/compatibility/tf_upgrade_v2.py @@ -672,8 +672,6 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec): "tf.strings.reduce_join", "tf.load_file_system_library": "tf.load_library", - "tf.pywrap_tensorflow": - "tf.compat.v1.pywrap_tensorflow", "tf.bincount": "tf.math.bincount", "tf.confusion_matrix": @@ -1423,7 +1421,13 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec): " returns ResourceVariables by default in 2.0, " "which have well-defined semantics and are stricter about shapes. " "You can disable this behavior by passing use_resource=False, or " - "by calling tf.compat.v1.disable_resource_variables().") + "by calling tf.compat.v1.disable_resource_variables()."), + "tf.pywrap_tensorflow": + (ast_edits.ERROR, + " cannot be converted automatically. " + "`tf.pywrap_tensorflow` will not be distributed with " + "TensorFlow 2.0, please consider an alternative in public " + "TensorFlow APIs.") } # Warnings that are emitted only if a specific arg is found. diff --git a/tensorflow/tools/compatibility/tf_upgrade_v2_test.py b/tensorflow/tools/compatibility/tf_upgrade_v2_test.py index 080b4c93538..f9f9db34381 100644 --- a/tensorflow/tools/compatibility/tf_upgrade_v2_test.py +++ b/tensorflow/tools/compatibility/tf_upgrade_v2_test.py @@ -1572,6 +1572,13 @@ def _log_prob(self, x): _, _, _, new_text = self._upgrade(text) self.assertEqual(new_text, expected_text) + def testPywrapTensorflowWarning(self): + text = "tf.pywrap_tensorflow.foo()" + expected = "tf.pywrap_tensorflow.foo()" + _, _, errors, new_text = self._upgrade(text) + self.assertEqual(expected, new_text) + self.assertIn("`tf.pywrap_tensorflow` will not be distributed", errors[0]) + class TestUpgradeFiles(test_util.TensorFlowTestCase):