Change api under tensorflow_estimator/python/estimator/api/ to generate 2.0

API as well.

PiperOrigin-RevId: 225876218
This commit is contained in:
Anna R 2018-12-17 13:08:33 -08:00 committed by TensorFlower Gardener
parent e1d74e4478
commit d5b902c648
2 changed files with 26 additions and 5 deletions

View File

@ -19,6 +19,7 @@ from __future__ import division as _division
from __future__ import print_function as _print_function
import os as _os
import sys as _sys
# API IMPORTS PLACEHOLDER
@ -26,13 +27,23 @@ import os as _os
from tensorflow.python.tools import component_api_helper as _component_api_helper
_component_api_helper.package_hook(
parent_package_str=__name__,
child_package_str=('tensorflow_estimator.python.estimator.api.estimator'))
child_package_str=(
'tensorflow_estimator.python.estimator.api._v2.estimator'))
_current_module = _sys.modules[__name__]
if not hasattr(_current_module, 'estimator'):
_component_api_helper.package_hook(
parent_package_str=__name__,
child_package_str=(
'tensorflow_estimator.python.estimator.api.estimator'))
# Make sure directory containing top level submodules is in
# the __path__ so that "from tensorflow.foo import bar" works.
# We're using bitwise, but there's nothing special about that.
_tf_api_dir = _os.path.dirname(_os.path.dirname(bitwise.__file__)) # pylint: disable=undefined-variable
if _tf_api_dir not in __path__:
if not hasattr(_current_module, '__path__'):
__path__ = [_tf_api_dir]
elif _tf_api_dir not in __path__:
__path__.append(_tf_api_dir)
# Enable TF2 behaviors

View File

@ -19,6 +19,7 @@ from __future__ import division as _division
from __future__ import print_function as _print_function
import os as _os
import sys as _sys
# pylint: disable=g-bad-import-order
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
@ -28,7 +29,15 @@ from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
from tensorflow.python.tools import component_api_helper as _component_api_helper
_component_api_helper.package_hook(
parent_package_str=__name__,
child_package_str=('tensorflow_estimator.python.estimator.api.estimator'))
child_package_str=(
'tensorflow_estimator.python.estimator.api._v1.estimator'))
_current_module = _sys.modules[__name__]
if not hasattr(_current_module, 'estimator'):
_component_api_helper.package_hook(
parent_package_str=__name__,
child_package_str=(
'tensorflow_estimator.python.estimator.api.estimator'))
from tensorflow.python.util.lazy_loader import LazyLoader # pylint: disable=g-import-not-at-top
contrib = LazyLoader('contrib', globals(), 'tensorflow.contrib')
@ -45,10 +54,11 @@ app.flags = flags # pylint: disable=undefined-variable
# Make sure directory containing top level submodules is in
# the __path__ so that "from tensorflow.foo import bar" works.
_tf_api_dir = _os.path.dirname(_os.path.dirname(app.__file__)) # pylint: disable=undefined-variable
if _tf_api_dir not in __path__:
if not hasattr(_current_module, '__path__'):
__path__ = [_tf_api_dir]
elif _tf_api_dir not in __path__:
__path__.append(_tf_api_dir)
# These symbols appear because we import the python package which
# in turn imports from tensorflow.core and tensorflow.python. They
# must come from this module. So python adds these symbols for the