Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker pull figroc/tfsclient:build
- run: ./build.sh buildAll
- run: ./gradle.sh buildAll
39 changes: 19 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle AS builder
FROM gradle
LABEL maintainer="P Chen<figroc@gmail.com>"

RUN apt-get update && apt-get install -y \
Expand All @@ -9,31 +9,30 @@ RUN apt-get update && apt-get install -y \
nodejs npm golang-go && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
pip3 --no-cache-dir install -U pip twine
RUN curl -sSL https://sh.rustup.rs | \
RUSTUP_HOME=/opt/rust/rustup CARGO_HOME=/opt/rust/cargo \
sh -s -- --default-toolchain 1.51.0 --profile default --no-modify-path -y
RUN curl -o mspkg.deb -sSL https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb && \
dpkg -i mspkg.deb && rm -f mspkg.deb && \
apt-get update && apt-get install -y \
dotnet-sdk-3.1 mono-devel nuget && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ENV GRADLE_OPTS="-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx512m" \
GO111MODULE=on RUSTUP_HOME=/opt/rust/rustup PATH=${PATH}:/opt/rust/cargo/bin:/home/gradle/go/bin:/home/gradle/.cargo/bin

FROM gradle AS grpc
RUN ALL_PROXY=$HTTP_PROXY \
git clone -b v1.35.x --depth 1 --progress \
--recurse-submodules --shallow-submodules \
https://github.com/grpc/grpc.git
ENV RUSTUP_HOME=/opt/rust/rustup \
CARGO_HOME=/opt/rust/cargo
RUN curl -fsSL https://sh.rustup.rs | \
sh -s -- --profile default --no-modify-path -y

ENV DOTNET_ROOT=/opt/mono
RUN curl -fsSL https://dot.net/v1/dotnet-install.sh | \
bash /dev/stdin --install-dir ${DOTNET_ROOT}

FROM builder
COPY --from=grpc /home/gradle/grpc grpc
RUN cd grpc && mkdir -p cmake/build && cd cmake/build && \
ARG ALL_PROXY HTTP_PROXY
RUN git clone -b v1.51.x --depth 1 --progress \
--recurse-submodules --shallow-submodules \
https://github.com/grpc/grpc.git && \
cd grpc && mkdir -p cmake/build && cd cmake/build && \
cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DBUILD_SHARED_LIBS=ON \
../.. && \
make && make install && ldconfig && \
cd ../../.. && rm -rf grpc
USER gradle

ENV PATH=${PATH}:${DOTNET_ROOT}:${CARGO_HOME}/bin:/root/.cargo/bin:/root/go/bin
ENV GRADLE_OPTS="-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx512m"
ENV GO111MODULE=on

WORKDIR /work
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A prebuilt tensorflow serving client from the tensorflow serving proto files.

Currently supported build: *C++, Java, Python, Node, Go, Mono, Rust*.
Currently supported build: *C++, Python, Java, Node, Mono, Rust, Go*.

Check tensorflow serving project for details: https://tensorflow.github.io/serving/

Expand All @@ -25,30 +25,20 @@ Grpc tools are needed for building variant packages.

See `Dockerfile` for details.

*NOTE: grpc@1.35 and protobuf@3.14 are required*

Target | Command | Outputs | Artifacts
-------|-----------------|-------------|----------------------------------------
native | `gradle cmake` | build/cmake | [![Publish Status](https://img.shields.io/spack/v/tensorflow-serving-client)](https://github.com/spack/spack/tree/develop/var/spack/repos/builtin/packages/tensorflow-serving-client)
java | `gradle java` | build/libs | [![Publish Status](https://img.shields.io/maven-central/v/io.opil/tensorflow-serving-client)](https://search.maven.org/search?q=g:io.opil%20AND%20a:tensorflow-serving-client)
python | `gradle wheel` | build/dist | [![Publish Status](https://img.shields.io/pypi/v/tensorflow-serving-client-grpc)](https://pypi.org/project/tensorflow-serving-client-grpc)
java | `gradle java` | build/libs | [![Publish Status](https://img.shields.io/maven-central/v/io.opil/tensorflow-serving-client)](https://search.maven.org/search?q=g:io.opil%20AND%20a:tensorflow-serving-client)
node | `gradle node` | build/node | [![Publish Status](https://img.shields.io/npm/v/tensorflow-serving-client)](https://www.npmjs.com/package/tensorflow-serving-client)
go | `gradle golang` | build/go | [![Publish Status](https://img.shields.io/github/v/tag/figroc/tensorflow-serving-client?label=go&sort=semver)](https://github.com/figroc/tensorflow-serving-client)
mono | `gradle mono` | build/mono | [![Publish Status](https://img.shields.io/nuget/v/tensorflow-serving-client)](https://www.nuget.org/packages/tensorflow-serving-client)
rust | `gradle rust` | build/cargo | [![Publish Status](https://img.shields.io/crates/v/tensorflow-serving-client)](https://crates.io/crates/tensorflow-serving-client)
go | `gradle golang` | build/go | [![Publish Status](https://img.shields.io/github/v/tag/figroc/tensorflow-serving-client?label=go&sort=semver)](https://github.com/figroc/tensorflow-serving-client)

## using docker

Invoke `./build.sh` instead of `gradle` to build artifacts using the docker.

The building container runs as user `gradle` whose UID:GID is 1000:1000.
It goes well given that the UID:GID pair of the user matches the one in the host OS.

Otherwise you have to configure it manually. There are two approaches you can take either:

1. Create a new user in the host OS to match the UID:GID pair of `gradle`.
2. Make the dirs `.gradle`, `build` and `obj` in the project root to be world-writable.
Invoke `./gradle.sh` instead of `gradle` to build artifacts using the docker.

## known issues

* protobuf 3.12.3 is buggy (protocolbuffers/protobuf#7683)
* *Java, Node, Mono, Rust, Go* are excluded from `./gradle.sh buildAll`
43 changes: 21 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,31 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.12"
classpath "com.google.protobuf:protobuf-gradle-plugin:0.9.4"
}
}

//---export-begin---//
ext {
vers = [tfs: file("VERSION").text.trim(),
jvm: "8",
grpc: "1.35.0",
proto: "3.14.0"]
grpc: "1.51.3",
proto: "3.21.6"]
dist = [build: "release",
name: [_: project.name,
title: project.name.tokenize("-").collect{it.capitalize()}.join(" "),
snake: project.name.replaceAll("-", "_")],
version: [_: vers.tfs,
major: vers.tfs.tokenize('.').first(),
grpc: [_: vers.grpc,
dotnet: vers.grpc.tokenize(".").withIndex().collect{ v, i ->
i == 0 ? ((v as int) + 1) : v
}.join("."),
node: "1.3.2",
rust: "0.7.0"],
dotnet: "2.46.5",
go: "1.51.0",
node: "1.8.21",
rust: "0.12.1"],
proto: [_: vers.proto,
go: "1.4.3",
node: "6.11.2",
rust: "2.22.0"]],
go: "1.5.4",
node: "7.1.2",
rust: "2.28.0"]],
license: "Apache-2.0",
author: [_: "P Chen <figroc@gmail.com>",
id: "figroc",
Expand Down Expand Up @@ -67,40 +66,40 @@ apply plugin: "signing"

apply from: "gradle/grpc.gradle"
apply from: "gradle/cmake.gradle"
apply from: "gradle/java.gradle"
apply from: "gradle/wheel.gradle"
apply from: "gradle/rust.gradle"
apply from: "gradle/java.gradle"
apply from: "gradle/node.gradle"
apply from: "gradle/golang.gradle"
apply from: "gradle/mono.gradle"
apply from: "gradle/rust.gradle"
apply from: "gradle/golang.gradle"

task buildAll {
dependsOn "cmake"
dependsOn "java"
dependsOn "wheel"
dependsOn "node"
dependsOn "golang"
dependsOn "mono"
dependsOn "rust"
// dependsOn "rust"
// dependsOn "java"
// dependsOn "node"
// dependsOn "mono"
// dependsOn "golang"
}

apply from: "gradle/ossrh.gradle"

task publishAll {
dependsOn "publish"
dependsOn "twine"
dependsOn "crate"
dependsOn "npmjs"
dependsOn "nuget"
dependsOn "crate"
}

task __sources__(type: Delete) {
dependsOn "__cpp__"
dependsOn "__java__"
dependsOn "__python__"
dependsOn "__rust__"
dependsOn "__java__"
dependsOn "__node__"
dependsOn "__golang__"
dependsOn "__csharp__"
dependsOn "__rust__"
delete ".github", "build.sh", "update.sh", "Dockerfile", "gradle"
}
30 changes: 0 additions & 30 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion crate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ documentation = "https://docs.rs/${TFSCLIENT_NAME}"
categories = ["api-bindings", "science"]

[dependencies]
futures = "0.3.15"
futures = "0.3.31"
grpcio = "${TFSCLIENT_VERSION_GRPC_RUST}"
protobuf = "${TFSCLIENT_VERSION_PROTO_RUST}"

Expand Down
10 changes: 10 additions & 0 deletions gradle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e
cd $(dirname ${BASH_SOURCE[0]})

builder="figroc/tfsclient:build"
workspace=/work/tensorflow-serving-client
docker run --rm -w=${workspace} \
-e ALL_PROXY -e GOPROXY -e HTTP_PROXY \
-v $(pwd):${workspace} ${builder} gradle "$@"
2 changes: 1 addition & 1 deletion gradle/golang.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ task installProtocGenGo(type: Exec) {
onlyIf {
pathOfExecutable("protoc-gen-go") == ""
}
commandLine "go", "get", "github.com/golang/protobuf/protoc-gen-go@v${dist.version.proto.go}"
commandLine "go", "install", "github.com/golang/protobuf/protoc-gen-go@v${dist.version.proto.go}"
}

task generateProtoGo {
Expand Down
6 changes: 1 addition & 5 deletions gradle/mono.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ task mono {
inputs.dir distEnv.source
outputs.dir distEnv.output
doLast {
exec {
environment buildEnviron(distEnv)
commandLine "nuget", "restore", "mono.csproj"
}
exec {
environment buildEnviron(distEnv)
commandLine "dotnet", "build", "-t:build;pack", "mono.csproj"
Expand All @@ -23,7 +19,7 @@ task nuget(type: Exec) {
dependsOn "mono"
inputs.dir mono.distEnv.output
environment buildEnviron(mono.distEnv)
commandLine "nuget", "push", "${mono.distEnv.output}/${mono.distEnv.build}/${project.name}.${project.version}.nupkg"
commandLine "dotnet", "nuget", "push", "${mono.distEnv.output}/${mono.distEnv.build}/${project.name}.${project.version}.nupkg"
}

task __csharp__() {
Expand Down
4 changes: 2 additions & 2 deletions gradle/ossrh.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: "maven-publish"

task sourcesJar(type: Jar) {
classifier "sources"
archiveClassifier = "sources"
from sourceSets.generated.java
}

task javadocJar(type: Jar) {
classifier "javadoc"
archiveClassifier = "javadoc"
from javadoc
}

Expand Down
2 changes: 1 addition & 1 deletion mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.12

require (
github.com/golang/protobuf v${TFSCLIENT_VERSION_PROTO_GO}
google.golang.org/grpc v${TFSCLIENT_VERSION_GRPC}
google.golang.org/grpc v${TFSCLIENT_VERSION_GRPC_GO}
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "${TFSCLIENT_NAME}",
"version": "${TFSCLIENT_VERSION}",
"dependencies": {
"@grpc/proto-loader": "^0.5.6",
"@grpc/proto-loader": "^0.7.13",
"@grpc/grpc-js": "^${TFSCLIENT_VERSION_GRPC_NODE}",
"protobufjs": "^${TFSCLIENT_VERSION_PROTO_NODE}"
},
Expand Down
74 changes: 74 additions & 0 deletions proto/tsl/protobuf/coordination_config.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
syntax = "proto3";

package tensorflow;

option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf";

// Represents a job type and the number of tasks under this job.
// For example, ("worker", 20) implies that there will be 20 worker tasks.
message CoordinatedJob {
string name = 1;
int32 num_tasks = 2;
}

// Coordination service configuration parameters.
// The system picks appropriate values for fields that are not set.
message CoordinationServiceConfig {
// Type of coordination service implementation to enable.
// For example, setting the service type as "standalone" starts a service
// instance on the leader task to provide the coordination services such as
// heartbeats and consistent key-value store.
string service_type = 1;

// Address where the coordination service instance is hosted.
string service_leader = 2;

// Whether to enable the health check mechanism.
bool enable_health_check = 3;

// Maximum wait time for all members in the cluster to be registered.
int64 cluster_register_timeout_in_ms = 4;

// Heartbeat timeout, if a task does not record heartbeat in this time
// window, it will be considered disconnected.
// Note: This is also used as a grace period to accept any heartbeats after
// the agent has disconnected, to account for the lag time between the service
// recording the state change and the agent stopping heartbeats.
int64 heartbeat_timeout_in_ms = 5;

// The list of `CoordinatedJob`s that will register in coordination service.
reserved 6;
repeated CoordinatedJob coordinated_job_list = 10;

// Denotes how long to wait for all coordination agents to reach the barriers
// (after the first shutdown request) before disconnecting together. If
// set to 0, no barrier is imposed upon shutdown and each worker can
// disconnect individually.
int64 shutdown_barrier_timeout_in_ms = 7;

// If set, agents do not make an explicit Shutdown() call. Service will only
// find out about the disconnecte agent via stale heartbeats. Used for
// testing.
bool agent_destruction_without_shutdown = 8;

// The list of jobs which are recoverable. If a task in this list fails,
// it will not propagate error to other tasks.
// If empty, no jobs will be recoverable and every task failure will cause
// error propagation to other tasks.
repeated string recoverable_jobs = 9;

// If a task restarts with a new incarnation, we may allow it to reconnect
// silently. This is useful when we know that a task can immediately resume
// work upon re-connecting to the service.
bool allow_new_incarnation_to_reconnect = 11;

// Disables coordination service.
// Some libraries enable coordination service by default even if the user did
// not specify any config. This field allows users to explicitly disable
// coordination service under all situations.
bool force_disable = 12;

// Use long polling to get error from coordination service as the error
// propagation mechanism.
bool poll_for_error_from_service_at_startup = 13;
}
Loading