Skip to content

Commit

Permalink
Remove deprecated TF 1 API
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 583948832
  • Loading branch information
TensorFlow Hub Authors authored and copybara-github committed Nov 20, 2023
1 parent d76ea21 commit f74a32b
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 6,372 deletions.
182 changes: 7 additions & 175 deletions tensorflow_hub/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ py_library(
visibility = ["//visibility:public"],
deps = [
# Dependencies of the tensorflow_hub library.
":image_util",
":keras_layer",
":module",
":module_v2",
":native_module",
":saved_model_module",
":feature_column",
":feature_column_v2",
":keras_layer",
":config",
# Internal dependency.,
],
Expand All @@ -63,64 +57,14 @@ py_library(
srcs = ["config.py"],
srcs_version = "PY3",
deps = [
# Deps of config.
":compressed_module_resolver",
":native_module",
":registry",
":resolver",
":uncompressed_module_resolver",
],
)

py_library(
name = "feature_column",
srcs = ["feature_column.py"],
srcs_version = "PY3",
deps = [
":module",
"//tensorflow_hub:expect_tensorflow_installed",
# "tensorflow/python/feature_column",
],
)

py_test(
name = "feature_column_test",
srcs = ["feature_column_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":tensorflow_hub",
":test_utils",
"//tensorflow_hub:expect_numpy_installed",
"//tensorflow_hub:expect_tensorflow_installed",
":expect_tensorflow_hub_includes_feature_column_apis",
],
)

py_library(
name = "feature_column_v2",
srcs = ["feature_column_v2.py"],
srcs_version = "PY3",
deps = [
":module",
"//tensorflow_hub:expect_tensorflow_installed",
# "tensorflow/python/feature_column",
],
)

py_test(
name = "feature_column_v2_test",
srcs = ["feature_column_v2_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":tensorflow_hub",
":test_utils",
"//tensorflow_hub:expect_numpy_installed",
"//tensorflow_hub:expect_tensorflow_installed",
":expect_tensorflow_hub_includes_feature_column_v2_apis",
],
)

py_library(
name = "compressed_module_resolver",
srcs = ["compressed_module_resolver.py"],
Expand All @@ -146,108 +90,6 @@ py_test(
],
)

py_library(
name = "image_util",
srcs = ["image_util.py"],
srcs_version = "PY3",
deps = [
":all_protos_py_pb2",
":native_module",
],
)

py_test(
name = "image_util_test",
srcs = ["image_util_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":image_util",
":module",
":native_module",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_library(
name = "module",
srcs = [
"module.py",
"module_impl.py",
"module_spec.py",
],
srcs_version = "PY3",
deps = [
":registry",
":tensor_info",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_test(
name = "module_test",
srcs = ["module_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":module",
":tensor_info",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_library(
name = "saved_model_module",
srcs = ["saved_model_module.py"],
srcs_version = "PY3",
deps = [
":module",
":native_module",
":saved_model_lib",
":tf_utils",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_test(
name = "saved_model_module_test",
srcs = ["saved_model_module_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":tensorflow_hub",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_library(
name = "native_module",
srcs = ["native_module.py"],
srcs_version = "PY3",
deps = [
":all_protos_py_pb2",
":meta_graph_lib",
":module",
":saved_model_lib",
":tf_utils",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_test(
name = "native_module_test",
srcs = ["native_module_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":all_protos_py_pb2",
":native_module",
":tensorflow_hub",
"//tensorflow_hub:expect_numpy_installed",
"//tensorflow_hub:expect_tensorflow_installed",
],
)

py_library(
name = "resolver",
srcs = ["resolver.py"],
Expand All @@ -266,10 +108,13 @@ py_test(
python_version = "PY3",
srcs_version = "PY3",
deps = [
":compressed_module_resolver",
":registry",
":resolver",
":tensorflow_hub",
":test_utils",
":tf_utils",
":uncompressed_module_resolver",
"//tensorflow_hub:expect_tensorflow_installed",
],
)
Expand Down Expand Up @@ -420,7 +265,7 @@ tf_hub_proto_library(
srcs = [
"image_module_info.proto",
"module_attachment.proto",
"module_def.proto",
# End proto files.
],
visibility = ["//:__subpackages__"],
)
Expand All @@ -431,18 +276,6 @@ py_library(
name = "expect_tensorflow_installed",
)

# We expect TensorFlow Hub to support feature_column_v2 related APIs.
# This is for internal bookkeeping only and will always be true.
py_library(
name = "expect_tensorflow_hub_includes_feature_column_v2_apis",
)

# We expect TensorFlow Hub to support feature_column related APIs.
# This is for internal bookkeeping only and will always be true.
py_library(
name = "expect_tensorflow_hub_includes_feature_column_apis",
)

# We expect numpy to already be installed on the system, e.g. via
# `pip install numpy`
py_library(
Expand All @@ -461,8 +294,7 @@ py_library(
srcs = ["module_v2.py"],
srcs_version = "PY3",
deps = [
":module",
":native_module",
":registry",
"//tensorflow_hub:expect_tensorflow_installed",
],
)
Expand Down
16 changes: 0 additions & 16 deletions tensorflow_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,9 @@ def _ensure_keras_2_importable():
# pylint: disable=g-import-not-at-top
# pylint: disable=g-bad-import-order
# Symbols exposed via tensorflow_hub.
from tensorflow_hub.feature_column_v2 import text_embedding_column_v2
from tensorflow_hub.feature_column import image_embedding_column
from tensorflow_hub.feature_column import sparse_text_embedding_column
from tensorflow_hub.feature_column import text_embedding_column
from tensorflow_hub.image_util import attach_image_module_info
from tensorflow_hub.image_util import get_expected_image_size
from tensorflow_hub.image_util import get_num_image_channels
from tensorflow_hub.image_util import ImageModuleInfo
from tensorflow_hub.keras_layer import KerasLayer
from tensorflow_hub.module import eval_function_for_module
from tensorflow_hub.module import load_module_spec
from tensorflow_hub.module import Module
from tensorflow_hub.module_spec import ModuleSpec
from tensorflow_hub.module_v2 import load
from tensorflow_hub.module_v2 import resolve
from tensorflow_hub.native_module import add_signature
from tensorflow_hub.native_module import attach_message
from tensorflow_hub.native_module import create_module_spec
from tensorflow_hub.saved_model_module import create_module_spec_from_saved_model
from tensorflow_hub.version import __version__

from tensorflow_hub.config import _run, _get_extra_deps # pylint: disable=g-multiple-import
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_hub/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# ==============================================================================
"""Configuration to bind implementations on the API."""

# Begin imports for config.py.
from tensorflow_hub import compressed_module_resolver
from tensorflow_hub import native_module
from tensorflow_hub import registry
from tensorflow_hub import resolver
from tensorflow_hub import uncompressed_module_resolver
Expand All @@ -34,7 +34,7 @@ def _install_default_resolvers():
def _run():
_install_default_resolvers()

registry.loader.add_implementation(native_module.Loader())
# End add resolvers.


def _get_extra_deps():
Expand Down
Loading

0 comments on commit f74a32b

Please sign in to comment.