From 1d1f7dfcbdca4ce4acfdd769a3777a9877e90fe3 Mon Sep 17 00:00:00 2001 From: Anna R Date: Fri, 23 Aug 2019 13:58:39 -0700 Subject: [PATCH] Automated rollback of commit 1171258036e73c911d0487a3c2db8272fd9dc6be PiperOrigin-RevId: 265128581 --- tensorflow/BUILD | 4 ++-- tensorflow/api_template.__init__.py | 2 +- tensorflow/api_template_v1.__init__.py | 2 +- .../python/tools/api/generator/create_python_api.py | 3 ++- tensorflow/tools/api/tests/module_test.py | 13 ------------- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tensorflow/BUILD b/tensorflow/BUILD index e601c3b62ff..7a9204200fa 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -812,8 +812,8 @@ genrule( }), outs = ["__init__.py"], cmd = select({ - "api_version_2": "cp $(@D)/_api/v2/v2.py $(OUTS) && sed -i'.original' 's:from . import:from . _api.v2 import:g' $(OUTS)", - "//conditions:default": "cp $(@D)/_api/v1/v1.py $(OUTS) && sed -i'.original' 's:from . import:from ._api.v1 import:g' $(OUTS)", + "api_version_2": "cp $(@D)/_api/v2/v2.py $(OUTS)", + "//conditions:default": "cp $(@D)/_api/v1/v1.py $(OUTS)", }), ) diff --git a/tensorflow/api_template.__init__.py b/tensorflow/api_template.__init__.py index 0aca0756f7d..3d8d92c63e7 100644 --- a/tensorflow/api_template.__init__.py +++ b/tensorflow/api_template.__init__.py @@ -78,7 +78,7 @@ except ImportError: pass try: - from .python.keras.api._v2 import keras + from tensorflow.python.keras.api._v2 import keras _current_module.__path__ = ( [_module_util.get_parent_dir(keras)] + _current_module.__path__) setattr(_current_module, "keras", keras) diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py index ca2e96d4b2e..2962a7a60e2 100644 --- a/tensorflow/api_template_v1.__init__.py +++ b/tensorflow/api_template_v1.__init__.py @@ -69,7 +69,7 @@ except ImportError: pass try: - from .python.keras.api._v1 import keras + from tensorflow.python.keras.api._v1 import keras _current_module.__path__ = ( [_module_util.get_parent_dir(keras)] + _current_module.__path__) setattr(_current_module, "keras", keras) diff --git a/tensorflow/python/tools/api/generator/create_python_api.py b/tensorflow/python/tools/api/generator/create_python_api.py index a3949deac4e..98cd159a63f 100644 --- a/tensorflow/python/tools/api/generator/create_python_api.py +++ b/tensorflow/python/tools/api/generator/create_python_api.py @@ -195,7 +195,8 @@ class _ModuleInitCodeBuilder(object): dest_module_name=parent_module, dest_name=module_split[submodule_index]) else: - import_from = '.' + if submodule_index > 0: + import_from += '.' + '.'.join(module_split[:submodule_index]) self.add_import( symbol=None, source_module_name=import_from, diff --git a/tensorflow/tools/api/tests/module_test.py b/tensorflow/tools/api/tests/module_test.py index 96bd6d73142..257d558cda7 100644 --- a/tensorflow/tools/api/tests/module_test.py +++ b/tensorflow/tools/api/tests/module_test.py @@ -23,7 +23,6 @@ import pkgutil import tensorflow as tf -from tensorflow.python import tf2 from tensorflow.python.platform import test @@ -51,18 +50,6 @@ class ModuleTest(test.TestCase): def testName(self): self.assertEqual('tensorflow', tf.__name__) - def testBuiltInName(self): - # range is a built-in name in Python. Just checking that - # tf.range works fine. - if tf2.enabled(): - self.assertEqual( - 'tf.Tensor([1 2 3 4 5 6 7 8 9], shape=(9,), dtype=int32)', - str(tf.range(1, 10))) - else: - self.assertEqual( - 'Tensor("range:0", shape=(9,), dtype=int32)', - str(tf.range(1, 10))) - if __name__ == '__main__': test.main()