diff --git a/tensorflow/contrib/proto/BUILD b/tensorflow/contrib/proto/BUILD index b27142cf4a6..c167fd70189 100644 --- a/tensorflow/contrib/proto/BUILD +++ b/tensorflow/contrib/proto/BUILD @@ -4,7 +4,7 @@ licenses(["notice"]) # Apache 2.0 exports_files(["LICENSE"]) -load("//tensorflow/core:platform/default/build_config_root.bzl", "if_static") +load("//tensorflow:tensorflow.bzl", "tf_py_test") py_library( name = "proto", @@ -14,5 +14,15 @@ py_library( deps = [ "//tensorflow/contrib/proto/python/ops:decode_proto_op_py", "//tensorflow/contrib/proto/python/ops:encode_proto_op_py", + "//tensorflow/python:proto_ops", + ], +) + +tf_py_test( + name = "import_test", + srcs = ["import_test.py"], + additional_deps = [ + ":proto", + "//tensorflow/python:client_testlib", ], ) diff --git a/tensorflow/contrib/proto/__init__.py b/tensorflow/contrib/proto/__init__.py index bc5a49de78e..1fe17324cd9 100644 --- a/tensorflow/contrib/proto/__init__.py +++ b/tensorflow/contrib/proto/__init__.py @@ -21,8 +21,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from tensorflow.contrib.proto.python.ops.decode_proto_op import decode_proto -from tensorflow.contrib.proto.python.ops.encode_proto_op import encode_proto +from tensorflow.python.ops.proto_ops import decode_proto +from tensorflow.python.ops.proto_ops import encode_proto from tensorflow.python.util.all_util import remove_undocumented remove_undocumented(__name__) diff --git a/tensorflow/contrib/proto/import_test.py b/tensorflow/contrib/proto/import_test.py new file mode 100644 index 00000000000..5da74a8c578 --- /dev/null +++ b/tensorflow/contrib/proto/import_test.py @@ -0,0 +1,33 @@ +# Copyright 2018 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. +# ============================================================================= + +"""Backwards compatibility tests for imports of tf.contrib.proto.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from tensorflow.contrib import proto +from tensorflow.python.platform import test + + +class ProtoImportTest(test.TestCase): + + def testImport(self): + self.assertTrue(proto.decode_proto) # Should be accessible + self.assertTrue(proto.encode_proto) # Should be accessible + + +if __name__ == '__main__': + test.main() diff --git a/tensorflow/contrib/proto/python/ops/BUILD b/tensorflow/contrib/proto/python/ops/BUILD index f17065477e1..ac09934b77d 100644 --- a/tensorflow/contrib/proto/python/ops/BUILD +++ b/tensorflow/contrib/proto/python/ops/BUILD @@ -1,44 +1,20 @@ -package(default_visibility = ["//visibility:public"]) - licenses(["notice"]) # Apache 2.0 -exports_files(["LICENSE"]) +package(default_visibility = ["//tensorflow:__subpackages__"]) -load( - "//tensorflow:tensorflow.bzl", - "tf_gen_op_wrapper_py", +# Placeholders for folks with old dependencies. +py_library( + name = "encode_proto_op_py", + srcs = ["encode_proto_op.py"], + deps = [ + "//tensorflow/python:proto_ops", + ], ) py_library( name = "decode_proto_op_py", srcs = ["decode_proto_op.py"], deps = [ - ":gen_decode_proto_op_py", - "//tensorflow/python:framework_ops", - ], -) - -tf_gen_op_wrapper_py( - name = "gen_decode_proto_op_py", - out = "gen_decode_proto_op.py", - deps = [ - "//tensorflow/core:decode_proto_ops_op_lib", - ], -) - -py_library( - name = "encode_proto_op_py", - srcs = ["encode_proto_op.py"], - deps = [ - ":gen_encode_proto_op_py", - "//tensorflow/python:framework_ops", - ], -) - -tf_gen_op_wrapper_py( - name = "gen_encode_proto_op_py", - out = "gen_encode_proto_op.py", - deps = [ - "//tensorflow/core:encode_proto_ops_op_lib", + "//tensorflow/python:proto_ops", ], ) diff --git a/tensorflow/contrib/proto/python/ops/decode_proto_op.py b/tensorflow/contrib/proto/python/ops/decode_proto_op.py index 7dc000ebe49..1347ebe3346 100644 --- a/tensorflow/contrib/proto/python/ops/decode_proto_op.py +++ b/tensorflow/contrib/proto/python/ops/decode_proto_op.py @@ -1,4 +1,3 @@ -# ============================================================================= # Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,14 +11,11 @@ # 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. -# ============================================================================= +# ============================================================================== -# pylint: disable=wildcard-import,unused-import -"""Protocol Buffer decoding from tensors.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function -from tensorflow.contrib.proto.python.ops.gen_decode_proto_op import decode_proto_v2 as decode_proto -from tensorflow.python.framework import ops -ops.NotDifferentiable("DecodeProtoV2") +# pylint: disable=unused-import +from tensorflow.python.ops.proto_ops import decode_proto diff --git a/tensorflow/contrib/proto/python/ops/encode_proto_op.py b/tensorflow/contrib/proto/python/ops/encode_proto_op.py index ac12198b2e4..6c1fcf68566 100644 --- a/tensorflow/contrib/proto/python/ops/encode_proto_op.py +++ b/tensorflow/contrib/proto/python/ops/encode_proto_op.py @@ -11,15 +11,11 @@ # 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. -# ============================================================================= +# ============================================================================== -# pylint: disable=wildcard-import,unused-import -"""Protocol Buffer encoding from tensors.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function -from tensorflow.contrib.proto.python.ops.gen_encode_proto_op import encode_proto -from tensorflow.python.framework import ops - -ops.NotDifferentiable("EncodeProto") +# pylint: disable=unused-import +from tensorflow.python.ops.proto_ops import encode_proto diff --git a/tensorflow/contrib/rpc/python/kernel_tests/rpc_op_test_base.py b/tensorflow/contrib/rpc/python/kernel_tests/rpc_op_test_base.py index d6148715be9..239bf2aa7a2 100644 --- a/tensorflow/contrib/rpc/python/kernel_tests/rpc_op_test_base.py +++ b/tensorflow/contrib/rpc/python/kernel_tests/rpc_op_test_base.py @@ -22,13 +22,12 @@ import itertools import numpy as np -from tensorflow.contrib.proto.python.ops import decode_proto_op -from tensorflow.contrib.proto.python.ops import encode_proto_op from tensorflow.contrib.rpc.python.kernel_tests import test_example_pb2 from tensorflow.contrib.rpc.python.ops import rpc_op from tensorflow.core.protobuf import config_pb2 from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors +from tensorflow.python.ops import proto_ops __all__ = ['I_WARNED_YOU', 'RpcOpTestBase'] @@ -222,7 +221,7 @@ class RpcOpTestBase(object): def testVecHostPortRpcUsingEncodeAndDecodeProto(self): with self.cached_session() as sess: - request_tensors = encode_proto_op.encode_proto( + request_tensors = proto_ops.encode_proto( message_type='tensorflow.contrib.rpc.TestCase', field_names=['values'], sizes=[[3]] * 20, @@ -233,7 +232,7 @@ class RpcOpTestBase(object): method=self.get_method_name('Increment'), address=self._address, request=request_tensors) - _, (response_shape,) = decode_proto_op.decode_proto( + _, (response_shape,) = proto_ops.decode_proto( bytes=response_tensor_strings, message_type='tensorflow.contrib.rpc.TestCase', field_names=['values'], diff --git a/tensorflow/core/api_def/base_api/api_def_DecodeProtoV2.pbtxt b/tensorflow/core/api_def/base_api/api_def_DecodeProtoV2.pbtxt index 22c3524360c..c9e1fc58aad 100644 --- a/tensorflow/core/api_def/base_api/api_def_DecodeProtoV2.pbtxt +++ b/tensorflow/core/api_def/base_api/api_def_DecodeProtoV2.pbtxt @@ -1,5 +1,6 @@ op { graph_op_name: "DecodeProtoV2" + visibility: HIDDEN in_arg { name: "bytes" description: <