Strictify Python targets in tensorflow/python/saved_model/.

PiperOrigin-RevId: 320071367
Change-Id: Ib2848e4a6bb9f06ad2f506145c17a82ceba6bba4
This commit is contained in:
Cesar Crusius 2020-07-07 15:17:58 -07:00 committed by TensorFlower Gardener
parent 586744d2e4
commit 216ac563c7
3 changed files with 117 additions and 45 deletions

View File

@ -1,6 +1,7 @@
# Description: # Description:
# TensorFlow SavedModel. # TensorFlow SavedModel.
load("//tensorflow:tensorflow.bzl", "py_strict_library")
load("//tensorflow:tensorflow.bzl", "cuda_py_test") load("//tensorflow:tensorflow.bzl", "cuda_py_test")
# buildifier: disable=same-origin-load # buildifier: disable=same-origin-load
@ -15,7 +16,7 @@ package(
exports_files(["LICENSE"]) exports_files(["LICENSE"])
py_library( py_strict_library(
name = "saved_model", name = "saved_model",
srcs = ["saved_model.py"], srcs = ["saved_model.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
@ -37,28 +38,28 @@ py_library(
], ],
) )
py_library( py_strict_library(
name = "constants", name = "constants",
srcs = ["constants.py"], srcs = ["constants.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = ["//tensorflow/python:util"], deps = ["//tensorflow/python:tf_export"],
) )
py_library( py_strict_library(
name = "signature_constants", name = "signature_constants",
srcs = ["signature_constants.py"], srcs = ["signature_constants.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = ["//tensorflow/python:util"], deps = ["//tensorflow/python:tf_export"],
) )
py_library( py_strict_library(
name = "tag_constants", name = "tag_constants",
srcs = ["tag_constants.py"], srcs = ["tag_constants.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = ["//tensorflow/python:util"], deps = ["//tensorflow/python:tf_export"],
) )
py_library( py_strict_library(
name = "builder", name = "builder",
srcs = [ srcs = [
"builder.py", "builder.py",
@ -67,18 +68,20 @@ py_library(
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
":constants", ":constants",
":signature_def_utils",
":utils", ":utils",
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
"//tensorflow/python:framework_for_generated_wrappers", "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:lib", "//tensorflow/python:lib",
"//tensorflow/python:platform", "//tensorflow/python:platform",
"//tensorflow/python:saver", "//tensorflow/python:saver",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python:variables", "//tensorflow/python:variables",
], ],
) )
py_library( py_strict_library(
name = "loader", name = "loader",
srcs = [ srcs = [
"loader.py", "loader.py",
@ -94,6 +97,7 @@ py_library(
"//tensorflow/python:lib", "//tensorflow/python:lib",
"//tensorflow/python:platform", "//tensorflow/python:platform",
"//tensorflow/python:saver", "//tensorflow/python:saver",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python:variables", "//tensorflow/python:variables",
], ],
@ -121,7 +125,7 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "simple_save", name = "simple_save",
srcs = [ srcs = [
"simple_save.py", "simple_save.py",
@ -132,13 +136,13 @@ py_library(
":signature_constants", ":signature_constants",
":signature_def_utils", ":signature_def_utils",
":tag_constants", ":tag_constants",
"//tensorflow/core:protos_all_py", "//tensorflow/python:framework_ops",
"//tensorflow/python:lib", "//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
], ],
) )
py_library( py_strict_library(
name = "main_op", name = "main_op",
srcs = [ srcs = [
"main_op.py", "main_op.py",
@ -149,6 +153,7 @@ py_library(
"//tensorflow/python:control_flow_ops", "//tensorflow/python:control_flow_ops",
"//tensorflow/python:framework_for_generated_wrappers", "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:lookup_ops", "//tensorflow/python:lookup_ops",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python:variables", "//tensorflow/python:variables",
], ],
@ -185,7 +190,7 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "utils", name = "utils",
srcs = [ srcs = [
"utils.py", "utils.py",
@ -196,10 +201,13 @@ py_library(
":constants", ":constants",
":nested_structure_coder", ":nested_structure_coder",
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
"//tensorflow/python:composite_tensor",
"//tensorflow/python:framework_for_generated_wrappers", "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:lib", "//tensorflow/python:lib",
"//tensorflow/python:sparse_tensor", "//tensorflow/python:sparse_tensor",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python/eager:context",
], ],
) )
@ -217,7 +225,7 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "signature_def_utils", name = "signature_def_utils",
srcs = [ srcs = [
"signature_def_utils.py", "signature_def_utils.py",
@ -228,7 +236,9 @@ py_library(
":signature_constants", ":signature_constants",
":utils", ":utils",
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
"//tensorflow/python:errors",
"//tensorflow/python:framework_ops", "//tensorflow/python:framework_ops",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
], ],
) )
@ -263,16 +273,18 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "signature_serialization", name = "signature_serialization",
srcs = [ srcs = [
"signature_serialization.py", "signature_serialization.py",
], ],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
":function_serialization",
":revived_types", ":revived_types",
":signature_constants", ":signature_constants",
"//tensorflow/python:framework_ops", "//tensorflow/python:framework_ops",
"//tensorflow/python:resource_variable_ops",
"//tensorflow/python:tensor_spec", "//tensorflow/python:tensor_spec",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python/eager:def_function", "//tensorflow/python/eager:def_function",
@ -281,7 +293,7 @@ py_library(
], ],
) )
py_library( py_strict_library(
name = "save_context", name = "save_context",
srcs = [ srcs = [
"save_context.py", "save_context.py",
@ -290,7 +302,7 @@ py_library(
deps = [], deps = [],
) )
py_library( py_strict_library(
name = "save", name = "save",
srcs = [ srcs = [
"save.py", "save.py",
@ -314,16 +326,22 @@ py_library(
"//tensorflow/python:constant_op", "//tensorflow/python:constant_op",
"//tensorflow/python:control_flow_ops", "//tensorflow/python:control_flow_ops",
"//tensorflow/python:dtypes", "//tensorflow/python:dtypes",
"//tensorflow/python:error_interpolation",
"//tensorflow/python:errors",
"//tensorflow/python:framework", "//tensorflow/python:framework",
"//tensorflow/python:framework_ops", "//tensorflow/python:framework_ops",
"//tensorflow/python:lib", "//tensorflow/python:lib",
"//tensorflow/python:resource_variable_ops", "//tensorflow/python:resource_variable_ops",
"//tensorflow/python:tensor_util",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python:versions",
"//tensorflow/python/eager:context", "//tensorflow/python/eager:context",
"//tensorflow/python/eager:def_function", "//tensorflow/python/eager:def_function",
"//tensorflow/python/eager:function", "//tensorflow/python/eager:function",
"//tensorflow/python/training/saving:checkpoint_options", "//tensorflow/python/training/saving:checkpoint_options",
"//tensorflow/python/training/saving:functional_saver", "//tensorflow/python/training/saving:functional_saver",
"//tensorflow/python/training/saving:saveable_object_util",
"//tensorflow/python/training/tracking", "//tensorflow/python/training/tracking",
"//tensorflow/python/training/tracking:base", "//tensorflow/python/training/tracking:base",
"//tensorflow/python/training/tracking:graph_view", "//tensorflow/python/training/tracking:graph_view",
@ -349,14 +367,13 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "load", name = "load",
srcs = [ srcs = [
"load.py", "load.py",
], ],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
":constants",
":function_deserialization", ":function_deserialization",
":load_options", ":load_options",
":load_v1_in_v2", ":load_v1_in_v2",
@ -365,17 +382,25 @@ py_library(
":revived_types", ":revived_types",
":utils", ":utils",
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
"//tensorflow/python:array_ops",
"//tensorflow/python:constant_op", "//tensorflow/python:constant_op",
"//tensorflow/python:control_flow_ops",
"//tensorflow/python:dtypes",
"//tensorflow/python:errors",
"//tensorflow/python:framework_ops", "//tensorflow/python:framework_ops",
"//tensorflow/python:init_ops", "//tensorflow/python:gradients",
"//tensorflow/python:lib", "//tensorflow/python:lookup_ops",
"//tensorflow/python:resource_variable_ops", "//tensorflow/python:resource_variable_ops",
"//tensorflow/python:tensor_util", "//tensorflow/python:tensor_util",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
"//tensorflow/python:variables", "//tensorflow/python:variables",
"//tensorflow/python/distribute:distribute_lib", "//tensorflow/python/distribute:distribute_lib",
"//tensorflow/python/distribute:distribute_utils", "//tensorflow/python/distribute:distribute_utils",
"//tensorflow/python/distribute:values", "//tensorflow/python/eager:context",
"//tensorflow/python/eager:function",
"//tensorflow/python/training/saving:checkpoint_options",
"//tensorflow/python/training/saving:saveable_object_util",
"//tensorflow/python/training/tracking", "//tensorflow/python/training/tracking",
"//tensorflow/python/training/tracking:base", "//tensorflow/python/training/tracking:base",
"//tensorflow/python/training/tracking:graph_view", "//tensorflow/python/training/tracking:graph_view",
@ -383,17 +408,26 @@ py_library(
], ],
) )
py_library( py_strict_library(
name = "load_v1_in_v2", name = "load_v1_in_v2",
srcs = [ srcs = [
"load_v1_in_v2.py", "load_v1_in_v2.py",
], ],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
":function_deserialization",
":loader", ":loader",
":signature_serialization", ":signature_serialization",
"//tensorflow/python:array_ops",
"//tensorflow/python:constant_op", "//tensorflow/python:constant_op",
"//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops",
"//tensorflow/python:platform",
"//tensorflow/python:saver", "//tensorflow/python:saver",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python:training_lib",
"//tensorflow/python/eager:context",
"//tensorflow/python/eager:lift_to_graph",
"//tensorflow/python/eager:wrap_function", "//tensorflow/python/eager:wrap_function",
"//tensorflow/python/training/tracking", "//tensorflow/python/training/tracking",
], ],
@ -451,7 +485,7 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "revived_types", name = "revived_types",
srcs = [ srcs = [
"revived_types.py", "revived_types.py",
@ -472,7 +506,7 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "function_serialization", name = "function_serialization",
srcs = [ srcs = [
"function_serialization.py", "function_serialization.py",
@ -481,12 +515,13 @@ py_library(
deps = [ deps = [
":nested_structure_coder", ":nested_structure_coder",
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
"//tensorflow/python/eager:def_function", "//tensorflow/python:func_graph",
"//tensorflow/python:util",
"//tensorflow/python/eager:function", "//tensorflow/python/eager:function",
], ],
) )
py_library( py_strict_library(
name = "function_deserialization", name = "function_deserialization",
srcs = [ srcs = [
"function_deserialization.py", "function_deserialization.py",
@ -494,22 +529,42 @@ py_library(
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
":nested_structure_coder", ":nested_structure_coder",
"//tensorflow/core:protos_all_py",
"//tensorflow/python:framework_ops",
"//tensorflow/python:func_graph",
"//tensorflow/python:function_def_to_graph",
"//tensorflow/python:op_def_registry",
"//tensorflow/python:platform",
"//tensorflow/python:resource_variable_ops",
"//tensorflow/python:tensor_spec",
"//tensorflow/python:tf_decorator",
"//tensorflow/python:type_spec",
"//tensorflow/python:util",
"//tensorflow/python/eager:def_function", "//tensorflow/python/eager:def_function",
"//tensorflow/python/eager:function",
], ],
) )
py_library( py_strict_library(
name = "nested_structure_coder", name = "nested_structure_coder",
srcs = ["nested_structure_coder.py"], srcs = ["nested_structure_coder.py"],
deps = [ deps = [
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
"//tensorflow/python:framework", "//tensorflow/python:dtypes",
"//tensorflow/python:indexed_slices",
"//tensorflow/python:resource_variable_ops",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python:tensor_array_ops", "//tensorflow/python:tensor_array_ops",
"//tensorflow/python:tensor_shape",
"//tensorflow/python:tensor_spec",
"//tensorflow/python:tensor_util",
"//tensorflow/python:util",
"//tensorflow/python/data/ops:dataset_ops", "//tensorflow/python/data/ops:dataset_ops",
"//tensorflow/python/data/ops:iterator_ops", "//tensorflow/python/data/ops:iterator_ops",
"//tensorflow/python/data/ops:optional_ops", "//tensorflow/python/data/ops:optional_ops",
"//tensorflow/python/distribute:values", "//tensorflow/python/distribute:values",
"//tensorflow/python/ops/ragged", "//tensorflow/python/ops/ragged:ragged_tensor",
"//tensorflow/python/ops/ragged:row_partition",
"@six_archive//:six", "@six_archive//:six",
], ],
) )
@ -525,22 +580,25 @@ tf_py_test(
], ],
) )
py_library( py_strict_library(
name = "save_options", name = "save_options",
srcs = ["save_options.py"], srcs = ["save_options.py"],
deps = [ deps = [
"//tensorflow/python:tf_export",
"//tensorflow/python:util",
"@six_archive//:six", "@six_archive//:six",
], ],
) )
py_library( py_strict_library(
name = "load_options", name = "load_options",
srcs = ["load_options.py"], srcs = ["load_options.py"],
deps = [ deps = [
"//tensorflow/python:tf_export",
], ],
) )
py_library( py_strict_library(
name = "method_name_updater", name = "method_name_updater",
srcs = ["method_name_updater.py"], srcs = ["method_name_updater.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
@ -549,6 +607,7 @@ py_library(
":loader", ":loader",
"//tensorflow/python:lib", "//tensorflow/python:lib",
"//tensorflow/python:platform", "//tensorflow/python:platform",
"//tensorflow/python:tf_export",
"//tensorflow/python:util", "//tensorflow/python:util",
], ],
) )

View File

@ -15,7 +15,12 @@
# Description: # Description:
# Keras saving and loading libraries. # Keras saving and loading libraries.
load("//tensorflow:tensorflow.bzl", "py_test")
# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "py_strict_library")
# buildifier: disable=same-origin-load
load("//tensorflow:tensorflow.bzl", "py_strict_test")
package( package(
default_visibility = ["//tensorflow:__subpackages__"], default_visibility = ["//tensorflow:__subpackages__"],
@ -24,7 +29,7 @@ package(
exports_files(["LICENSE"]) exports_files(["LICENSE"])
py_library( py_strict_library(
name = "model_utils", name = "model_utils",
srcs = ["__init__.py"], srcs = ["__init__.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
@ -35,7 +40,7 @@ py_library(
], ],
) )
py_library( py_strict_library(
name = "export_output", name = "export_output",
srcs = ["export_output.py"], srcs = ["export_output.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
@ -44,10 +49,11 @@ py_library(
"//tensorflow/python:dtypes", "//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops", "//tensorflow/python:framework_ops",
"//tensorflow/python/saved_model:signature_def_utils", "//tensorflow/python/saved_model:signature_def_utils",
"@six_archive//:six",
], ],
) )
py_test( py_strict_test(
name = "export_output_test", name = "export_output_test",
srcs = ["export_output_test.py"], srcs = ["export_output_test.py"],
python_version = "PY3", python_version = "PY3",
@ -61,12 +67,14 @@ py_test(
"//tensorflow/python:control_flow_ops", "//tensorflow/python:control_flow_ops",
"//tensorflow/python:dtypes", "//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops", "//tensorflow/python:framework_ops",
"//tensorflow/python:metrics",
"//tensorflow/python:sparse_tensor", "//tensorflow/python:sparse_tensor",
"//tensorflow/python/eager:context",
"//tensorflow/python/saved_model:signature_constants", "//tensorflow/python/saved_model:signature_constants",
], ],
) )
py_library( py_strict_library(
name = "export_utils", name = "export_utils",
srcs = ["export_utils.py"], srcs = ["export_utils.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
@ -78,36 +86,37 @@ py_library(
"//tensorflow/python/saved_model:signature_constants", "//tensorflow/python/saved_model:signature_constants",
"//tensorflow/python/saved_model:signature_def_utils", "//tensorflow/python/saved_model:signature_def_utils",
"//tensorflow/python/saved_model:tag_constants", "//tensorflow/python/saved_model:tag_constants",
"@six_archive//:six",
], ],
) )
py_test( py_strict_test(
name = "export_test", name = "export_test",
srcs = ["export_test.py"], srcs = ["export_test.py"],
python_version = "PY3", python_version = "PY3",
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
":export_output",
":export_utils", ":export_utils",
":mode_keys",
"//tensorflow/python:array_ops", "//tensorflow/python:array_ops",
"//tensorflow/python:client_testlib", "//tensorflow/python:client_testlib",
"//tensorflow/python:constant_op", "//tensorflow/python:constant_op",
"//tensorflow/python:control_flow_ops",
"//tensorflow/python:dtypes", "//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops",
"//tensorflow/python:framework_test_lib", "//tensorflow/python:framework_test_lib",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python/saved_model:signature_constants", "//tensorflow/python/saved_model:signature_constants",
"//tensorflow/python/saved_model:signature_def_utils", "//tensorflow/python/saved_model:signature_def_utils",
], ],
) )
py_library( py_strict_library(
name = "mode_keys", name = "mode_keys",
srcs = ["mode_keys.py"], srcs = ["mode_keys.py"],
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = ["//tensorflow/python:util"],
) )
py_test( py_strict_test(
name = "mode_keys_test", name = "mode_keys_test",
srcs = ["mode_keys_test.py"], srcs = ["mode_keys_test.py"],
python_version = "PY3", python_version = "PY3",

View File

@ -1932,6 +1932,10 @@ register_extension_info(
def py_strict_library(name, **kwargs): def py_strict_library(name, **kwargs):
native.py_library(name = name, **kwargs) native.py_library(name = name, **kwargs)
# Placeholder to use until bazel supports py_strict_test.
def py_strict_test(name, **kwargs):
native.py_test(name = name, **kwargs)
def tf_custom_op_py_library( def tf_custom_op_py_library(
name, name,
srcs = [], srcs = [],