Update TF OSS API generation script to support OSS keras PIP package.

PiperOrigin-RevId: 359374348
Change-Id: I17b63aea5086250a19b98ad04ad9d17ded3d1f88
This commit is contained in:
Scott Zhu 2021-02-24 14:44:15 -08:00 committed by TensorFlower Gardener
parent e30cc0bfb0
commit c023a82916
4 changed files with 64 additions and 28 deletions

View File

@ -84,12 +84,21 @@ if _module_dir:
_current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "estimator", estimator)
try:
if _os.environ.get("_PREFER_OSS_KERAS", False):
try:
from keras.api._v2 import keras
_current_module.__path__ = (
[_module_util.get_parent_dir(keras)] + _current_module.__path__)
setattr(_current_module, "keras", keras)
except ImportError:
pass
else:
try:
from .python.keras.api._v2 import keras
_current_module.__path__ = (
[_module_util.get_parent_dir(keras)] + _current_module.__path__)
setattr(_current_module, "keras", keras)
except ImportError:
except ImportError:
pass
# Explicitly import lazy-loaded modules to support autocompletion.

View File

@ -75,12 +75,21 @@ if _module_dir:
_current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "estimator", estimator)
try:
if _os.environ.get("_PREFER_OSS_KERAS", False):
try:
from keras.api._v1 import keras
_current_module.__path__ = (
[_module_util.get_parent_dir(keras)] + _current_module.__path__)
setattr(_current_module, "keras", keras)
except ImportError:
pass
else:
try:
from .python.keras.api._v1 import keras
_current_module.__path__ = (
[_module_util.get_parent_dir(keras)] + _current_module.__path__)
setattr(_current_module, "keras", keras)
except ImportError:
except ImportError:
pass
# Explicitly import lazy-loaded modules to support autocompletion.

View File

@ -52,12 +52,21 @@ if _module_dir:
_current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "estimator", estimator)
try:
if _os.environ.get("_PREFER_OSS_KERAS", False):
try:
from keras.api._v2 import keras
_current_module.__path__ = (
[_module_util.get_parent_dir(keras)] + _current_module.__path__)
setattr(_current_module, "keras", keras)
except ImportError:
pass
else:
try:
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)
except ImportError:
except ImportError:
pass
# Explicitly import lazy-loaded modules to support autocompletion.

View File

@ -42,12 +42,21 @@ if _module_dir:
_current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "estimator", estimator)
try:
if _os.environ.get("_PREFER_OSS_KERAS", False):
try:
from keras.api._v1 import keras
_current_module.__path__ = (
[_module_util.get_parent_dir(keras)] + _current_module.__path__)
setattr(_current_module, "keras", keras)
except ImportError:
pass
else:
try:
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)
except ImportError:
except ImportError:
pass
# Explicitly import lazy-loaded modules to support autocompletion.