- Updates existing DeprecationWrapper with the ability to import modules only when they are referred. - Updates how TensorFlow generates public API. Wraps all generated TensorFlow __init__.py modules with this enhanced wrapper. To enable lazy-loading in the future, toggle _LAZY_LOADING flag in create_python_api.py. Once lazy loading is enabled, the wrapper will have the following behaviors: - dir() will always return module?s attributes. - __all__ will always return all public APIs. - __dict__ will be populated as attributes are being referred. - After wrapper instance is created, to add more attributes, use setattr(import does not explicitly call setattr) to make sure dir, __all__, __dict__ are updated. - import * will work as expected. Built and tested with pip package. PiperOrigin-RevId: 257240535
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# ==============================================================================
|
|
"""Compatibility wrapper for TensorFlow modules to support deprecation messages.
|
|
|
|
Please use module_wrapper instead.
|
|
TODO(yifeif): remove once no longer referred by estimator
|
|
"""
|
|
|
|
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
|
|
from tensorflow.python.util import module_wrapper
|
|
|
|
# For backward compatibility for other pip packages that use this class.
|
|
DeprecationWrapper = module_wrapper.TFModuleWrapper
|