Skip to content

Commit a021aa0

Browse files
committed
client updates and additions
update bazel and build dependencies rename python client bazel package and update wheel scripts add c++ and go client library support minor readme updates
1 parent 3f77d7a commit a021aa0

File tree

17 files changed

+222
-108
lines changed

17 files changed

+222
-108
lines changed

.bazelrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# upstream tensorflow/serving version
2-
build --embed_label=2.2.0
3-
4-
common --experimental_repo_remote_exec
2+
build --embed_label=2.3.0
53

64
build --verbose_failures
75
# enable proper toolchain resolution for cc rules
@@ -14,10 +12,10 @@ build --copt=-O3
1412
build:release --copt=-w
1513
build:release --output_filter=DONT_MATCH_ANYTHING
1614

17-
# grpc build options
18-
build --define=grpc_no_ares=true
15+
# protobuf / grpc build options
1916
build --define=use_fast_cpp_protos=true
2017
build --define=allow_oversize_protos=true
18+
build --define=grpc_no_ares=true
2119

2220
# build with shared gnu libstdc++ instead of static libc++
2321
build:gnulibcpp --@com_github_emacski_bazeltools//toolchain/cpp/clang:use_libcpp="libstdc++"

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
- name: Bazel Build
3333
run: |
3434
docker run --rm -v ${HOME}/.cache/bazel:/root/.cache/bazel --entrypoint chown emacski/tensorflow-serving-arm-client:latest-devel -R root:root /root/.cache/bazel
35-
tools/ci/bazel.sh run --spawn_strategy=local --config=release //python/wheel:build_pure
36-
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_amd64 //python/wheel:build_platform
37-
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm64 //python/wheel:build_platform
38-
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm //python/wheel:build_platform
35+
tools/ci/bazel.sh run //py/wheel:build_pure --config=release
36+
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_amd64 --config=release
37+
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm64 --config=release
38+
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm --config=release
3939
sudo chown -R $(whoami):$(whoami) ${HOME}/.cache/bazel

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
- name: Bazel Build
3333
run: |
3434
docker run --rm -v ${HOME}/.cache/bazel:/root/.cache/bazel --entrypoint chown emacski/tensorflow-serving-arm-client:latest-devel -R root:root /root/.cache/bazel
35-
tools/ci/bazel.sh run --spawn_strategy=local --config=release //python/wheel:build_pure
36-
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_amd64 //python/wheel:build_platform
37-
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm64 //python/wheel:build_platform
38-
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm //python/wheel:build_platform
35+
tools/ci/bazel.sh run //py/wheel:build_pure --config=release
36+
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_amd64 --config=release
37+
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm64 --config=release
38+
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm --config=release
3939
sudo chown -R $(whoami):$(whoami) ${HOME}/.cache/bazel
4040
- name: Create Release
4141
id: create_release

BUILD

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@rules_python//python:defs.bzl", "py_library")
16-
1715
package(default_visibility = ["//visibility:public"])
1816

1917
platform(
@@ -39,12 +37,3 @@ platform(
3937
"@platforms//cpu:arm",
4038
],
4139
)
42-
43-
# python client
44-
45-
py_library(
46-
name = "python",
47-
imports = ["python"],
48-
srcs_version = "PY3",
49-
deps = ["//python:grpc"],
50-
)

README.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,52 @@ Tensorflow Serving ARM Client
55
**EXPERIMENTAL (anything can change)**
66

77
A project for cross building [tensorflow/serving](https://github.com/tensorflow/serving)
8-
grpc api clients targeting popular arm architectures from an x86_64 host.
9-
Additionally, this includes an experimental multi-arch standalone python3 client
10-
(it doesn't depend on the core tensorflow python package).
8+
standalone grpc api clients targeting popular arm architectures from an x86_64 host.
9+
Currently, client libraries can be cross-built for c++, python and go targeting
10+
`linux_amd64`, `linux_arm64` and `linux_arm`.
1111

12-
## Python3 Client
12+
## Project Artifacts
13+
### Python3 Client Library (Wheels)
1314

14-
### Wheels
15+
Currently, platform specific wheels are published for CPython 3.7 on
16+
`linux_amd64`, `linux_arm64` and `linux_arm`. These wheels are full self-contained
17+
grpc client libs and include the `tensorflow_serving`, (protobuf only) `tensorflow`,
18+
`grpcio` and `protobuf` py packages with corresponding extensions where applicable
19+
(no compiling or dev-tools required on the install host).
1520

16-
A pure python3 wheel is maintained that depends on `grpcio` and `protobuf`
17-
python packages.
21+
Additionally, a pure python3 wheel is published that includes the `tensorflow_serving`,
22+
(protobuf only) `tensorflow` packages and depends on external `grpcio` and
23+
`protobuf` python packages.
1824

19-
Currently, platform specific wheels are maintained for CPython 3.7 on
20-
`linux_amd64`, `linux_arm64` and `linux_arm`. These wheels are full
21-
self-contained grpc client libs and include the `tensorflow_serving`,
22-
`tensorflow`, `grpcio` and `protobuf`, python packages with corresponding
23-
compiled extensions where applicable.
24-
25-
**Install with `pip`**
25+
**Install Wheels with `pip`**
2626
```sh
2727
# on linux_amd64 python 3.7
28-
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-cp37-none-manylinux2014_x86_64.whl
28+
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-cp37-none-manylinux2014_x86_64.whl
2929
# on linux_arm64 python 3.7
30-
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-cp37-none-manylinux2014_aarch64.whl
30+
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-cp37-none-manylinux2014_aarch64.whl
3131
# on linux_arm python 3.7
32-
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-cp37-none-manylinux2014_armv7l.whl
33-
# pure python 3 (depends on grpcio and protobuf)
34-
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-py3-none-any.whl
32+
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-cp37-none-manylinux2014_armv7l.whl
33+
# pure python 3 (will also install grpcio and protobuf pypi packages)
34+
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-py3-none-any.whl
35+
```
36+
37+
**Building Wheels From Source**
38+
```sh
39+
git clone git@github.com:emacski/tensorflow-serving-arm-client.git
40+
cd tensorflow-serving-arm-client
41+
42+
# Build Environment
43+
docker run --rm -ti \
44+
-w /tensorflow-serving-arm-client \
45+
-v $PWD:/tensorflow-serving-arm-client \
46+
emacski/tensorflow-serving:latest-devel /bin/bash
47+
```
48+
By default, wheel artifacts will be output to the workspace root
49+
```sh
50+
# pure python
51+
bazel run //py/wheel:build_pure
52+
# with extension
53+
bazel run //py/wheel:build_platform --config=linux_amd64
54+
bazel run //py/wheel:build_platform --config=linux_arm64
55+
bazel run //py/wheel:build_platform --config=linux_arm
3556
```

WORKSPACE

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1818

1919
http_archive(
2020
name = "com_github_emacski_bazeltools",
21-
sha256 = "6f3c9b725b2222ea16e6eabfb8f2a9ec267567f0c05c9c4f36cbd641cd02ff39",
22-
strip_prefix = "bazel-tools-74b14ec277cbc79c328142c561d1edd69e05d3b4",
23-
urls = ["https://github.com/emacski/bazel-tools/archive/74b14ec277cbc79c328142c561d1edd69e05d3b4.tar.gz"],
21+
sha256 = "ac040d00f7f00c9947d61c7b8970a877d907c92e088966c24a0eaeeba5551b19",
22+
strip_prefix = "bazel-tools-250e4a98908fa0c6631ebccdeae930a60fd4c0d5",
23+
urls = ["https://github.com/emacski/bazel-tools/archive/250e4a98908fa0c6631ebccdeae930a60fd4c0d5.tar.gz"],
2424
)
2525

2626
register_toolchains("@com_github_emacski_bazeltools//toolchain/cpp/clang:all")
2727

28+
# python client deps
29+
2830
http_archive(
2931
name = "rules_python",
3032
sha256 = "afe33d4a8091452cb785108f237c7f3dcef56345952aad124954a96d89c4aab6",
@@ -40,63 +42,72 @@ load("@rules_python//python:pip.bzl", "pip_repositories")
4042

4143
pip_repositories()
4244

43-
# tensorflow 2.2.0
44-
# https://github.com/tensorflow/tensorflow
45+
# go client deps
46+
4547
http_archive(
46-
name = "org_tensorflow",
47-
sha256 = "b3d7829fac84e3a26264d84057367730b6b85b495a0fce15929568f4b55dc144",
48-
strip_prefix = "tensorflow-2b96f3662bd776e277f86997659e61046b56c315",
48+
name = "io_bazel_rules_go",
49+
sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc",
4950
urls = [
50-
"https://github.com/tensorflow/tensorflow/archive/2b96f3662bd776e277f86997659e61046b56c315.tar.gz",
51+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
52+
"https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
5153
],
5254
)
5355

54-
# see tensorflow/serving/WORKSPACE and tensorflow/tensorflow/WORKSPACE
5556
http_archive(
56-
name = "io_bazel_rules_closure",
57-
sha256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9",
58-
strip_prefix = "rules_closure-308b05b2419edb5c8ee0471b67a40403df940149",
57+
name = "bazel_gazelle",
58+
sha256 = "222e49f034ca7a1d1231422cdb67066b885819885c356673cb1f72f748a3c9d4",
5959
urls = [
60-
"https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz",
60+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
61+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
6162
],
6263
)
6364

64-
# see tensorflow/serving/WORKSPACE and tensorflow/tensorflow/WORKSPACE
65-
http_archive(
66-
name = "bazel_skylib",
67-
sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0",
68-
urls = [
69-
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
70-
"https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
71-
],
65+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
66+
67+
go_rules_dependencies()
68+
69+
go_register_toolchains(version = "1.16")
70+
71+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
72+
73+
gazelle_dependencies()
74+
75+
go_repository(
76+
name = "org_golang_google_grpc",
77+
commit = "f74f0337644653eba7923908a4d7f79a4f3a267b", # 1.36.0
78+
importpath = "google.golang.org/grpc",
7279
)
7380

74-
# see tensorflow/serving/WORKSPACE
75-
http_archive(
76-
name = "rules_pkg",
77-
sha256 = "f8bf72e76a15d045f786ef0eba92e073a50bbdbd807d237a43a759d36b1b1e2c",
78-
strip_prefix = "rules_pkg-0.2.5/pkg",
79-
urls = ["https://github.com/bazelbuild/rules_pkg/archive/0.2.5.tar.gz"],
81+
go_repository(
82+
name = "org_golang_x_net",
83+
importpath = "golang.org/x/net",
84+
sum = "h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=",
85+
version = "v0.0.0-20190311183353-d8887717615a",
8086
)
8187

82-
# https://github.com/tensorflow/serving
83-
http_archive(
84-
name = "tf_serving",
85-
sha256 = "946c1a58d677686e6b986634b51f4bc19486230c7fc2ab669c8492b0662ad4cc",
86-
strip_prefix = "serving-d22fc192c7ad7b48d9a81346224aff637b8988f1",
87-
urls = [
88-
"https://github.com/tensorflow/serving/archive/d22fc192c7ad7b48d9a81346224aff637b8988f1.tar.gz",
89-
],
88+
go_repository(
89+
name = "org_golang_x_text",
90+
importpath = "golang.org/x/text",
91+
sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
92+
version = "v0.3.0",
9093
)
9194

92-
load("@tf_serving//tensorflow_serving:workspace.bzl", "tf_serving_workspace")
95+
# protobuf / grpc deps
9396

94-
tf_serving_workspace()
97+
http_archive(
98+
name = "com_github_grpc_grpc",
99+
patches = [
100+
"@com_github_emacski_tensorflowservingarmclient//third_party/grpc:cython_library.patch",
101+
],
102+
sha256 = "bb6de0544adddd54662ba1c314eff974e84c955c39204a4a2b733ccd990354b7",
103+
strip_prefix = "grpc-1.36.3",
104+
urls = ["https://github.com/grpc/grpc/archive/v1.36.3.tar.gz"],
105+
)
95106

96107
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
97108

98109
grpc_deps()
99110

100-
load("@upb//bazel:repository_defs.bzl", "bazel_version_repository")
111+
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
101112

102-
bazel_version_repository(name = "bazel_version")
113+
grpc_extra_deps()

cc/BUILD

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2021 Erik Maciejewski
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+
load(
16+
"@com_github_emacski_bazeltools//protobuf:cc.bzl",
17+
"cc_grpc_library",
18+
"cc_proto_library",
19+
)
20+
21+
package(default_visibility = ["//visibility:public"])
22+
23+
cc_grpc_library(
24+
name = "tensorflow_serving",
25+
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
26+
deps = [":tensorflow_serving_protobuf"],
27+
)
28+
29+
cc_proto_library(
30+
name = "tensorflow_serving_protobuf",
31+
deps = ["//proto:protos_all"],
32+
)

go/BUILD

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2021 Erik Maciejewski
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+
load(
16+
"@com_github_emacski_bazeltools//protobuf:go.bzl",
17+
"go_grpc_library",
18+
"go_proto_library",
19+
)
20+
21+
package(default_visibility = ["//visibility:public"])
22+
23+
go_grpc_library(
24+
name = "tensorflow_serving",
25+
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
26+
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow_serving",
27+
deps = [":tensorflow_serving_protobuf"],
28+
)
29+
30+
go_proto_library(
31+
name = "tensorflow_serving_protobuf",
32+
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow_serving",
33+
proto = ["//proto/tensorflow_serving:protos_all"],
34+
deps = [
35+
":tensorflow_core_proto",
36+
":tensorflow_example_proto",
37+
":tensorflow_framework_proto",
38+
],
39+
)
40+
41+
go_proto_library(
42+
name = "tensorflow_core_proto",
43+
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow/core",
44+
proto = ["//proto/tensorflow/core:protos_all"],
45+
deps = [":tensorflow_framework_proto"],
46+
)
47+
48+
go_proto_library(
49+
name = "tensorflow_framework_proto",
50+
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow/core/framework",
51+
proto = ["//proto/tensorflow/core/framework:protos_all"],
52+
)
53+
54+
go_proto_library(
55+
name = "tensorflow_example_proto",
56+
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow/core/example",
57+
proto = ["//proto/tensorflow/core/example:protos_all"],
58+
deps = [":tensorflow_framework_proto"],
59+
)

python/BUILD renamed to py/BUILD

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
# limitations under the License.
1414

1515
load(
16-
"@com_github_emacski_bazeltools//protobuf:python_rules.bzl",
16+
"@com_github_emacski_bazeltools//protobuf:py.bzl",
1717
"py_grpc_library",
1818
"py_proto_library",
1919
)
2020

2121
package(default_visibility = ["//visibility:public"])
2222

23-
py_proto_library(
24-
name = "protobuf",
23+
py_grpc_library(
24+
name = "tensorflow_serving",
25+
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
2526
srcs_version = "PY3",
26-
deps = ["//proto:protos_all"],
27+
deps = [":tensorflow_serving_protobuf"],
2728
)
2829

29-
py_grpc_library(
30-
name = "grpc",
31-
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
30+
py_proto_library(
31+
name = "tensorflow_serving_protobuf",
3232
srcs_version = "PY3",
33-
deps = [":protobuf"],
33+
deps = ["//proto:protos_all"],
3434
)

0 commit comments

Comments
 (0)