From a0605e23021e907aec290b8637c675af6db01af3 Mon Sep 17 00:00:00 2001 From: P Chen Date: Wed, 31 Aug 2022 23:28:29 +0800 Subject: [PATCH 1/2] fix: update third-party protos and builder image --- Dockerfile | 39 +++++++++++++++++++-------------------- build.gradle | 43 +++++++++++++++++++++---------------------- crate.toml | 2 +- gradle/golang.gradle | 2 +- gradle/mono.gradle | 4 ++-- gradle/ossrh.gradle | 4 ++-- mod.go | 2 +- package.json | 2 +- 8 files changed, 48 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index f64791e..f780098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gradle AS builder +FROM gradle LABEL maintainer="P Chen" RUN apt-get update && apt-get install -y \ @@ -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 diff --git a/build.gradle b/build.gradle index 53351b7..78a15af 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.12" + classpath "com.google.protobuf:protobuf-gradle-plugin:0.9.4" } } @@ -11,8 +11,8 @@ buildscript { 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(" "), @@ -20,15 +20,14 @@ ext { 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 ", id: "figroc", @@ -67,21 +66,21 @@ 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" @@ -89,18 +88,18 @@ 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" } diff --git a/crate.toml b/crate.toml index 39036be..c43523e 100644 --- a/crate.toml +++ b/crate.toml @@ -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}" diff --git a/gradle/golang.gradle b/gradle/golang.gradle index 2528273..92673b1 100644 --- a/gradle/golang.gradle +++ b/gradle/golang.gradle @@ -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 { diff --git a/gradle/mono.gradle b/gradle/mono.gradle index 47b029e..546a288 100644 --- a/gradle/mono.gradle +++ b/gradle/mono.gradle @@ -10,7 +10,7 @@ task mono { doLast { exec { environment buildEnviron(distEnv) - commandLine "nuget", "restore", "mono.csproj" + commandLine "donet", "restore", "mono.csproj" } exec { environment buildEnviron(distEnv) @@ -23,7 +23,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__() { diff --git a/gradle/ossrh.gradle b/gradle/ossrh.gradle index a40af79..fc4ecd9 100644 --- a/gradle/ossrh.gradle +++ b/gradle/ossrh.gradle @@ -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 } diff --git a/mod.go b/mod.go index 9126776..c3c7ec3 100644 --- a/mod.go +++ b/mod.go @@ -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} ) diff --git a/package.json b/package.json index 066580a..b562578 100644 --- a/package.json +++ b/package.json @@ -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}" }, From bd4df475703f741625159be959b8f3c4bd06fd4a Mon Sep 17 00:00:00 2001 From: P Chen Date: Thu, 6 Feb 2025 17:18:52 +0800 Subject: [PATCH 2/2] fix: add missing tsl protos --- .github/workflows/main.yml | 3 +- README.md | 20 +-- build.sh | 30 ---- gradle.sh | 10 ++ gradle/mono.gradle | 4 - proto/tsl/protobuf/coordination_config.proto | 74 +++++++++ proto/tsl/protobuf/error_codes.proto | 155 +++++++++++++++++++ proto/tsl/protobuf/rpc_options.proto | 41 +++++ update.sh | 31 ++-- 9 files changed, 299 insertions(+), 69 deletions(-) delete mode 100755 build.sh create mode 100755 gradle.sh create mode 100644 proto/tsl/protobuf/coordination_config.proto create mode 100644 proto/tsl/protobuf/error_codes.proto create mode 100644 proto/tsl/protobuf/rpc_options.proto diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78342d5..9d61994 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/README.md b/README.md index 714e14d..e044699 100644 --- a/README.md +++ b/README.md @@ -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/ @@ -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` diff --git a/build.sh b/build.sh deleted file mode 100755 index b9cab88..0000000 --- a/build.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -e -cd $(dirname ${BASH_SOURCE[0]}) - -builder="figroc/tfsclient:build" - -if [[ -z "$(docker images -q ${builder})" ]]; then - docker build -t ${builder} --build-arg HTTP_PROXY=${ALL_PROXY} . -fi - -if [[ "$(uname)" != "Darwin" && "$(id -u)" != "1000" ]]; then - ( - echo "WARNING: Current user $(whoami)($(id -u):$(id -g))" \ - "does not match the user gradle(1000:1000) in the container." - echo "The building might fail for unable to access dirs:" \ - ".gralde, build and obj." - ) 1>&2 - for d in .gradle build obj; do - mkdir -p ${d} - chmod -R go+rw ${d} - done - chmod go+rw . -fi - -workspace=/work/tensorflow-serving-client - -docker run --rm -w=${workspace} \ - -e ALL_PROXY -e GOPROXY -e HTTP_PROXY=${ALL_PROXY} \ - -v $(pwd):${workspace} ${builder} gradle --no-daemon "$@" diff --git a/gradle.sh b/gradle.sh new file mode 100755 index 0000000..3cb8445 --- /dev/null +++ b/gradle.sh @@ -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 "$@" diff --git a/gradle/mono.gradle b/gradle/mono.gradle index 546a288..08c105b 100644 --- a/gradle/mono.gradle +++ b/gradle/mono.gradle @@ -8,10 +8,6 @@ task mono { inputs.dir distEnv.source outputs.dir distEnv.output doLast { - exec { - environment buildEnviron(distEnv) - commandLine "donet", "restore", "mono.csproj" - } exec { environment buildEnviron(distEnv) commandLine "dotnet", "build", "-t:build;pack", "mono.csproj" diff --git a/proto/tsl/protobuf/coordination_config.proto b/proto/tsl/protobuf/coordination_config.proto new file mode 100644 index 0000000..d88afe2 --- /dev/null +++ b/proto/tsl/protobuf/coordination_config.proto @@ -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; +} diff --git a/proto/tsl/protobuf/error_codes.proto b/proto/tsl/protobuf/error_codes.proto new file mode 100644 index 0000000..32008c0 --- /dev/null +++ b/proto/tsl/protobuf/error_codes.proto @@ -0,0 +1,155 @@ +syntax = "proto3"; + +// TODO(b/247876220): Change package and java_package once we figure out how to +// migrate. + +package tensorflow.error; + +option cc_enable_arenas = true; +option java_outer_classname = "ErrorCodesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/google/tsl/tsl/go/protobuf"; + +// The canonical error codes for TensorFlow APIs. +// +// Warnings: +// +// - Do not change any numeric assignments. +// - Changes to this list should only be made if there is a compelling +// need that can't be satisfied in another way. Such changes +// must be approved by at least two OWNERS. +// - These error codes must match gRPC and protobuf error codes (except for +// DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_). +// +// Sometimes multiple error codes may apply. Services should return +// the most specific error code that applies. For example, prefer +// OUT_OF_RANGE over FAILED_PRECONDITION if both codes apply. +// Similarly prefer NOT_FOUND or ALREADY_EXISTS over FAILED_PRECONDITION. +enum Code { + // Not an error; returned on success + OK = 0; + + // The operation was cancelled (typically by the caller). + CANCELLED = 1; + + // Unknown error. An example of where this error may be returned is + // if a Status value received from another address space belongs to + // an error-space that is not known in this address space. Also + // errors raised by APIs that do not return enough error information + // may be converted to this error. + UNKNOWN = 2; + + // Client specified an invalid argument. Note that this differs + // from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments + // that are problematic regardless of the state of the system + // (e.g., a malformed file name). + INVALID_ARGUMENT = 3; + + // Deadline expired before operation could complete. For operations + // that change the state of the system, this error may be returned + // even if the operation has completed successfully. For example, a + // successful response from a server could have been delayed long + // enough for the deadline to expire. + DEADLINE_EXCEEDED = 4; + + // Some requested entity (e.g., file or directory) was not found. + // For privacy reasons, this code *may* be returned when the client + // does not have the access right to the entity. + NOT_FOUND = 5; + + // Some entity that we attempted to create (e.g., file or directory) + // already exists. + ALREADY_EXISTS = 6; + + // The caller does not have permission to execute the specified + // operation. PERMISSION_DENIED must not be used for rejections + // caused by exhausting some resource (use RESOURCE_EXHAUSTED + // instead for those errors). PERMISSION_DENIED must not be + // used if the caller can not be identified (use UNAUTHENTICATED + // instead for those errors). + PERMISSION_DENIED = 7; + + // The request does not have valid authentication credentials for the + // operation. + UNAUTHENTICATED = 16; + + // Some resource has been exhausted, perhaps a per-user quota, or + // perhaps the entire file system is out of space. + RESOURCE_EXHAUSTED = 8; + + // Operation was rejected because the system is not in a state + // required for the operation's execution. For example, directory + // to be deleted may be non-empty, an rmdir operation is applied to + // a non-directory, etc. + // + // A litmus test that may help a service implementor in deciding + // between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: + // (a) Use UNAVAILABLE if the client can retry just the failing call. + // (b) Use ABORTED if the client should retry at a higher-level + // (e.g., restarting a read-modify-write sequence). + // (c) Use FAILED_PRECONDITION if the client should not retry until + // the system state has been explicitly fixed. E.g., if an "rmdir" + // fails because the directory is non-empty, FAILED_PRECONDITION + // should be returned since the client should not retry unless + // they have first fixed up the directory by deleting files from it. + // (d) Use FAILED_PRECONDITION if the client performs conditional + // REST Get/Update/Delete on a resource and the resource on the + // server does not match the condition. E.g., conflicting + // read-modify-write on the same resource. + FAILED_PRECONDITION = 9; + + // The operation was aborted, typically due to a concurrency issue + // like sequencer check failures, transaction aborts, etc. + // + // See litmus test above for deciding between FAILED_PRECONDITION, + // ABORTED, and UNAVAILABLE. + ABORTED = 10; + + // Operation tried to iterate past the valid input range. E.g., seeking or + // reading past end of file. + // + // Unlike INVALID_ARGUMENT, this error indicates a problem that may + // be fixed if the system state changes. For example, a 32-bit file + // system will generate INVALID_ARGUMENT if asked to read at an + // offset that is not in the range [0,2^32-1], but it will generate + // OUT_OF_RANGE if asked to read from an offset past the current + // file size. + // + // There is a fair bit of overlap between FAILED_PRECONDITION and + // OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific + // error) when it applies so that callers who are iterating through + // a space can easily look for an OUT_OF_RANGE error to detect when + // they are done. + OUT_OF_RANGE = 11; + + // Operation is not implemented or not supported/enabled in this service. + UNIMPLEMENTED = 12; + + // Internal errors. Means some invariant expected by the underlying + // system has been broken. If you see one of these errors, + // something is very broken. + INTERNAL = 13; + + // The service is currently unavailable. This is a most likely a + // transient condition and may be corrected by retrying with + // a backoff. + // + // See litmus test above for deciding between FAILED_PRECONDITION, + // ABORTED, and UNAVAILABLE. + UNAVAILABLE = 14; + + // Unrecoverable data loss or corruption. + DATA_LOSS = 15; + + // An extra enum entry to prevent people from writing code that + // fails to compile when a new code is added. + // + // Nobody should ever reference this enumeration entry. In particular, + // if you write C++ code that switches on this enumeration, add a default: + // case instead of a case that mentions this enumeration entry. + // + // Nobody should rely on the value (currently 20) listed here. It + // may change in the future. + DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_ = 20; +} diff --git a/proto/tsl/protobuf/rpc_options.proto b/proto/tsl/protobuf/rpc_options.proto new file mode 100644 index 0000000..17d5fbd --- /dev/null +++ b/proto/tsl/protobuf/rpc_options.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +package tensorflow; + +option go_package = "github.com/google/tsl/tsl/go/protobuf"; + +// RPC options for distributed runtime. +message RPCOptions { + // If true, always use RPC to contact the session target. + // + // If false (the default option), TensorFlow may use an optimized + // transport for client-master communication that avoids the RPC + // stack. This option is primarily for used testing the RPC stack. + bool use_rpc_for_inprocess_master = 1; + + // The compression algorithm to be used. One of "deflate", "gzip". + string compression_algorithm = 2; + + // If compression_algorithm is set, the compression level to be used. + // From 0 (no compression), up to 3. + int32 compression_level = 3; + + // Setting cache_rpc_response to true will enable sender side caching of + // response for RecvTensorAsync and RecvBufAsync to allow receiver to retry + // requests . This is only necessary when the network fabric is experiencing a + // significant error rate. Without it we'll fail a step on an network error, + // while with it we'll be able to complete long steps (like complex + // initializations) in the face of some network errors during RecvTensor. + bool cache_rpc_response = 4; + + // Disables TCP connection sharing when opening a new RPC channel. + bool disable_session_connection_sharing = 5; + + // Setting num_channels_per_target > 0 allows uses of multiple channels to + // communicate to the same target. This can be used to improve the aggregate + // throughput on high speed links (e.g 100G) where single connection is not + // sufficient to maximize link utilization. Note that a single RPC only goes + // on a single channel, this only helps in situations where there are multiple + // transfers to the same target overlapping in time. + int32 num_channels_per_target = 6; +} diff --git a/update.sh b/update.sh index 1e9f094..9de5c7e 100755 --- a/update.sh +++ b/update.sh @@ -5,22 +5,19 @@ cd $(dirname ${BASH_SOURCE[0]}) ver="r$(cat VERSION | cut -d'.' -f1,2)" proj=tensorflow-serving-client -repo=build/proto -goto=proto apis=tensorflow_serving/apis +repo=build/upstream +goto=proto norm=('s@(tensorflow/core/)lib/core(/error_codes.proto)@\1protobuf\2@' 's@(option go_package = ".*)/[a-z_]*_go_proto(".*)@\1\2@') norm=$(IFS=';'; echo "${norm[*]}") -rm -rf ${repo} +rm -rf ${repo} && mkdir -p ${repo} function fetchRepo {( set -e - mkdir -p ${repo}/tmp - git -C ${repo}/tmp \ + git -C ${repo} \ clone --depth 1 -b ${ver} \ https://github.com/tensorflow/${1}.git - mv ${repo}/tmp/${1}/${2} ${repo}/ - rm -rf ${repo}/tmp )} fetchRepo tensorflow tensorflow fetchRepo serving tensorflow_serving @@ -28,19 +25,17 @@ fetchRepo serving tensorflow_serving rm -rf ${goto} function importProto {( set -e if [[ ! -f ${goto}/${1} ]]; then - echo "${1}" - mkdir -p ${goto}/${1%/*} - sed -E "${norm}" ${repo}/${1} >${goto}/${1} - local proto=( $(grep '^import ' ${goto}/${1} \ - | grep -Eo '((\w|-)+(/|\.))+proto') ) - for p in ${proto[@]}; do - if [[ "${p:0:10}" == "tensorflow" ]]; then - importProto ${p} - fi + for p in $(find ${repo} -path "*/${1}"); do + mkdir -p ${goto}/${1%/*} && echo ${1} + sed -E "${norm}" ${p} > ${goto}/${1} + done + for p in $(grep -s '^import ' ${goto}/${1} \ + | grep -Eo '((\w|-)+(/|\.))+proto'); do + importProto ${p} done fi )} -for i in ${repo}/${apis}/*_service.proto; do - importProto ${i#${repo}/} +for i in ${repo}/serving/${apis}/*_service.proto; do + importProto ${i#${repo}/serving/} done importProto ${apis}/prediction_log.proto