Skip to content

Commit 80f38d1

Browse files
authored
Add proto wrappers (#515)
PiperOrigin-RevId: 774807442
1 parent 916967e commit 80f38d1

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ def generate_proto(source, require=True):
102102
'or install the binary package.\n')
103103
sys.exit(-1)
104104

105-
protoc_command = [protoc, '-I../src', '-I.', '--python_out=.', source]
105+
protoc_command = [
106+
protoc,
107+
'-I/usr/include',
108+
'-I.',
109+
'-I./tensorflow_model_analysis/proto',
110+
'--python_out=.',
111+
source,
112+
]
106113
if subprocess.call(protoc_command) != 0:
107114
sys.exit(-1)
108115

tensorflow_model_analysis/proto/BUILD

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,18 @@ licenses(["notice"]) # Apache 2.0
44

55
package(default_visibility = ["//visibility:public"])
66

7-
py_proto_library(
8-
name = "config_py_pb2",
9-
srcs = [
10-
"config.proto",
11-
],
12-
default_runtime = "@com_google_protobuf//:protobuf_python",
13-
protoc = "@com_google_protobuf//:protoc",
14-
deps = [
15-
"@com_google_protobuf//:protobuf_python",
16-
],
7+
filegroup(
8+
name = "proto_files",
9+
src = glob(["*.proto"]),
1710
)
1811

1912
py_proto_library(
20-
name = "metrics_for_slice_py_pb2",
21-
srcs = [
22-
"metrics_for_slice.proto",
23-
],
24-
default_runtime = "@com_google_protobuf//:protobuf_python",
25-
protoc = "@com_google_protobuf//:protoc",
26-
deps = [
27-
"@com_google_protobuf//:protobuf_python",
28-
],
29-
)
30-
31-
py_proto_library(
32-
name = "validation_result",
33-
srcs = [
34-
"validation_result.proto",
35-
],
13+
name = "protos_py_pb2",
14+
srcs = glob(["*.proto"]),
3615
default_runtime = "@com_google_protobuf//:protobuf_python",
3716
protoc = "@com_google_protobuf//:protoc",
3817
deps = [
39-
":config_py_pb2",
40-
":metrics_for_slice_py_pb2",
18+
"__init__.py",
4119
"@com_google_protobuf//:protobuf_python",
4220
],
4321
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2018 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package tensorflow_model_analysis;
18+
19+
import "google/protobuf/wrappers.proto";
20+
21+
message MyMessage {
22+
google.protobuf.DoubleValue my_double = 1;
23+
google.protobuf.FloatValue my_float = 2;
24+
google.protobuf.Int64Value my_int64 = 3;
25+
google.protobuf.UInt64Value my_uint64 = 4;
26+
google.protobuf.Int32Value my_int32 = 5;
27+
google.protobuf.UInt32Value my_uint32 = 6;
28+
google.protobuf.BoolValue my_bool = 7;
29+
google.protobuf.StringValue my_string = 8;
30+
google.protobuf.BytesValue my_bytes = 9;
31+
}

0 commit comments

Comments
 (0)