diff --git a/README.md b/README.md index e044699..87c45de 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,4 @@ Invoke `./gradle.sh` instead of `gradle` to build artifacts using the docker. ## known issues -* *Java, Node, Mono, Rust, Go* are excluded from `./gradle.sh buildAll` +* *Rust* is excluded from `./gradle.sh buildAll` diff --git a/build.gradle b/build.gradle index 78a15af..05d39a5 100644 --- a/build.gradle +++ b/build.gradle @@ -77,10 +77,10 @@ task buildAll { dependsOn "cmake" dependsOn "wheel" // dependsOn "rust" - // dependsOn "java" - // dependsOn "node" - // dependsOn "mono" - // dependsOn "golang" + dependsOn "java" + dependsOn "node" + dependsOn "mono" + dependsOn "golang" } apply from: "gradle/ossrh.gradle" diff --git a/gradle/golang.gradle b/gradle/golang.gradle index 92673b1..3215f5f 100644 --- a/gradle/golang.gradle +++ b/gradle/golang.gradle @@ -7,7 +7,6 @@ task installProtocGenGo(type: Exec) { task generateProtoGo { dependsOn "installProtocGenGo" - finalizedBy "finalizeProtoGo" ext { source = "${protoGenMainDir}/go" } @@ -34,121 +33,36 @@ task generateProtoGo { standardOutput file("${source}/go.mod").newOutputStream() commandLine "envsubst" } - } -} - -static def commonsOfPath(global, String... dirs) { - def commons = null - dirs.each { dir -> - def path = [].toSet() - global.fileTree(dir){ include "**" }.visit { fd -> - if (fd.file.file) return - path.add(fd.path) - } - if (commons == null) { - commons = path - } else { - commons.retainAll(path) + file(source).eachDir { fd -> + file("${source}/go.mod").append("\nreplace ${fd.name} => ./${fd.name}") + var mod = file("${fd.path}/go.mod") + if (!mod.exists()) { + println("generate mod: ${fd.name}/go.mod") + mod.write("module ${fd.name}\n\ngo 1.12") + } } } - if (commons == null) commons = [].toSet() - return commons } -task finalizeProtoGo { +task golang { + dependsOn "generateProto" dependsOn "generateProtoGo" - ext { - source = generateProtoGo.source - rot = "github.com" - sat = "${rot}/tensorflow/tensorflow/tensorflow/go" - ome = "tensorflow" - output = "${buildDir}/go" - } - onlyIf { - file("${source}/${rot}").exists() - } + inputs.dir generateProtoGo.source + outputs.dir generateProtoGo.source doLast { - def gnu = new ByteArrayOutputStream() exec { - ignoreExitValue = true - standardOutput gnu - errorOutput gnu - commandLine "sed", "--version" - } - gnu = gnu.toString().contains("GNU") - def lwb = gnu ? "\\b" : "[[:<:]]" - def rwb = gnu ? "\\b" : "[[:>:]]" - fileTree(source){ include "**/*.go" }.visit { fd -> - if (fd.file.directory) return - exec { - commandLine "sed", "-i.sed", "s@${lwb}${sat}${rwb}@${ome}@g", "${source}/${fd.path}" - } - } - fileTree(source){ include "${sat}/**/*.go" }.visit { fd -> - if (fd.file.directory) return - exec { - commandLine "sed", "-i.sed", "s@^package .*@package ${ome}@g", "${source}/${fd.path}" - } - } - commonsOfPath(project, "${source}/${sat}", "${source}/${ome}").each { dir -> - def pattern = "\"${ome}/${dir}\"" - fileTree(source){ include "${sat}/${dir}/*.go", "${ome}/${dir}/*.go" }.visit { fd -> - if (fd.file.directory) return - def name = new ByteArrayOutputStream() - exec { - ignoreExitValue = true - standardOutput name - commandLine "grep", "-o", "\\w* ${pattern}", "${source}/${fd.path}" - } - name = name.toString().trim().tokenize(" ") - if (name[0] == null) return - name = name.size() == 1 ? name[0].tokenize("/")[-1] : name[0] - println("adjust ${name} in ${fd.path}") - exec { - commandLine "sed", "-i.sed", "\\@${pattern}@d", "${source}/${fd.path}" - } - exec { - commandLine "sed", "-i.sed", "s@${lwb}${name}\\.@@g", "${source}/${fd.path}" - } - } - } - copy { - from "${source}/${sat}" - include "**/*.go" - into "${source}/${ome}" - } - delete { - delete "${source}/${rot}" - delete fileTree(source){ include "**/*.sed" } - } - fileTree(source){ include "*" }.visit { fd -> - if (fd.file.file) return - copy { - from "${source}/go.mod" - into "${source}/${fd.path}" - filter { line -> - line.startsWith("module") ? "module ${fd.path}" : line - } - } - println("generate mod: ${fd.path}/go.mod") - file("${source}/go.mod").append("\nreplace ${fd.path} => ./${fd.path}\n") + workingDir generateProtoGo.source + commandLine "go", "mod", "tidy" } exec { - commandLine "ln", "-nfs", buildDir.relativePath(new File(source)), output + workingDir generateProtoGo.source + commandLine "go", "build", "-v", "-pkgdir", generateProtoGo.source + args(dist.build == "release" ? ["-ldflags", "-s -w"] : []) + args("./...") } } } -task golang(type: Exec) { - dependsOn "generateProtoGo" - inputs.dir generateProtoGo.source - outputs.dir generateProtoGo.source - workingDir generateProtoGo.source - commandLine "go", "build", "-v" - args(dist.build == "release" ? ["-ldflags", "-s -w"] : []) - args("./...") -} - task __golang__ { dependsOn "golang" ext { diff --git a/gradle/grpc.gradle b/gradle/grpc.gradle index bd00c56..1fc1e0f 100644 --- a/gradle/grpc.gradle +++ b/gradle/grpc.gradle @@ -49,7 +49,6 @@ protobuf { outputSubDir = "csharp" } } - all()["generateProto"].finalizedBy "finalizeProtoGrpc" } } @@ -60,22 +59,3 @@ ext { protoGenMainRel = file(projectDir).toPath().relativize(file(protoGenMainDir).toPath()) protoGenMainSub = file(protoGenBaseDir).toPath().relativize(file(protoGenMainDir).toPath()) } - -task finalizeProtoGrpc { - dependsOn "generateProto" - inputs.dir protoGenMainDir - doLast { - delete { - delete fileTree("${protoGenMainDir}/cpp") { - include "**/*.grpc.pb.*" - exclude "**/*_service.grpc.pb.*" - } - } - delete { - delete fileTree("${protoGenMainDir}/python") { - include "**/*_pb2_grpc.py" - exclude "**/*_service_pb2_grpc.py" - } - } - } -} diff --git a/gradle/node.gradle b/gradle/node.gradle index f780ee4..e0f64f8 100644 --- a/gradle/node.gradle +++ b/gradle/node.gradle @@ -23,10 +23,6 @@ task node { workingDir source commandLine "npm", "install" } - exec { - workingDir source - commandLine "npm", "build" - } exec { workingDir source commandLine "npm", "pack" diff --git a/gradle/wheel.gradle b/gradle/wheel.gradle index 475b675..d6ef87b 100644 --- a/gradle/wheel.gradle +++ b/gradle/wheel.gradle @@ -56,7 +56,7 @@ task __python__ { doLast { copy { from wheel.distEnv.source - include "tensorflow/**", "tensorflow_serving/**" + include "tensorflow/**", "tensorflow_serving/**", "tsl/**" into src } exec { diff --git a/proto/tensorflow/core/example/example.proto b/proto/tensorflow/core/example/example.proto index 59e5428..03ea29b 100644 --- a/proto/tensorflow/core/example/example.proto +++ b/proto/tensorflow/core/example/example.proto @@ -10,7 +10,7 @@ option cc_enable_arenas = true; option java_outer_classname = "ExampleProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.example"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/example"; +option go_package = "tensorflow/core/example"; // An Example is a mostly-normalized data format for storing data for // training and inference. It contains a key-value store (features); where diff --git a/proto/tensorflow/core/example/feature.proto b/proto/tensorflow/core/example/feature.proto index e532747..f89cd08 100644 --- a/proto/tensorflow/core/example/feature.proto +++ b/proto/tensorflow/core/example/feature.proto @@ -61,7 +61,7 @@ option cc_enable_arenas = true; option java_outer_classname = "FeatureProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.example"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/example"; +option go_package = "tensorflow/core/example"; // LINT.IfChange // Containers to hold repeated fundamental values. diff --git a/proto/tensorflow/core/framework/allocation_description.proto b/proto/tensorflow/core/framework/allocation_description.proto index 0032cfb..c7384fd 100644 --- a/proto/tensorflow/core/framework/allocation_description.proto +++ b/proto/tensorflow/core/framework/allocation_description.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "AllocationDescriptionProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; message AllocationDescription { // Total number of bytes requested diff --git a/proto/tensorflow/core/framework/attr_value.proto b/proto/tensorflow/core/framework/attr_value.proto index 06024cc..8d5cbef 100644 --- a/proto/tensorflow/core/framework/attr_value.proto +++ b/proto/tensorflow/core/framework/attr_value.proto @@ -10,7 +10,7 @@ option cc_enable_arenas = true; option java_outer_classname = "AttrValueProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Protocol buffer representing the value for an attr used to configure an Op. // Comment indicates the corresponding attr type. Only the field matching the diff --git a/proto/tensorflow/core/framework/cost_graph.proto b/proto/tensorflow/core/framework/cost_graph.proto index f1ff216..73cf925 100644 --- a/proto/tensorflow/core/framework/cost_graph.proto +++ b/proto/tensorflow/core/framework/cost_graph.proto @@ -9,7 +9,7 @@ option cc_enable_arenas = true; option java_outer_classname = "CostGraphProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; message CostGraphDef { message Node { diff --git a/proto/tensorflow/core/framework/full_type.proto b/proto/tensorflow/core/framework/full_type.proto index 0022abf..affe453 100644 --- a/proto/tensorflow/core/framework/full_type.proto +++ b/proto/tensorflow/core/framework/full_type.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "FullTypeProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // LINT.IfChange // Experimental. Represents the complete type information of a TensorFlow value. diff --git a/proto/tensorflow/core/framework/function.proto b/proto/tensorflow/core/framework/function.proto index 8982261..0eae7b1 100644 --- a/proto/tensorflow/core/framework/function.proto +++ b/proto/tensorflow/core/framework/function.proto @@ -10,7 +10,7 @@ option cc_enable_arenas = true; option java_outer_classname = "FunctionProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // A library is a set of named functions. message FunctionDefLibrary { diff --git a/proto/tensorflow/core/framework/graph.proto b/proto/tensorflow/core/framework/graph.proto index ef16dec..89300af 100644 --- a/proto/tensorflow/core/framework/graph.proto +++ b/proto/tensorflow/core/framework/graph.proto @@ -11,7 +11,7 @@ option cc_enable_arenas = true; option java_outer_classname = "GraphProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Represents the graph of operations message GraphDef { diff --git a/proto/tensorflow/core/framework/graph_debug_info.proto b/proto/tensorflow/core/framework/graph_debug_info.proto index af90b5f..908291f 100644 --- a/proto/tensorflow/core/framework/graph_debug_info.proto +++ b/proto/tensorflow/core/framework/graph_debug_info.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "GraphDebugInfoProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; message GraphDebugInfo { // This represents a file/line location in the source code. diff --git a/proto/tensorflow/core/framework/node_def.proto b/proto/tensorflow/core/framework/node_def.proto index daf4c78..958f9b8 100644 --- a/proto/tensorflow/core/framework/node_def.proto +++ b/proto/tensorflow/core/framework/node_def.proto @@ -9,7 +9,7 @@ option cc_enable_arenas = true; option java_outer_classname = "NodeProto"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; message NodeDef { // The name given to this operator. Used for naming inputs, diff --git a/proto/tensorflow/core/framework/op_def.proto b/proto/tensorflow/core/framework/op_def.proto index 42963e8..760ba8c 100644 --- a/proto/tensorflow/core/framework/op_def.proto +++ b/proto/tensorflow/core/framework/op_def.proto @@ -11,7 +11,7 @@ option cc_enable_arenas = true; option java_outer_classname = "OpDefProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Defines an operation. A NodeDef in a GraphDef specifies an Op by // using the "op" field which should match the name of a OpDef. diff --git a/proto/tensorflow/core/framework/resource_handle.proto b/proto/tensorflow/core/framework/resource_handle.proto index 2b6276f..74c4c34 100644 --- a/proto/tensorflow/core/framework/resource_handle.proto +++ b/proto/tensorflow/core/framework/resource_handle.proto @@ -9,7 +9,7 @@ option cc_enable_arenas = true; option java_outer_classname = "ResourceHandle"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Protocol buffer representing a handle to a tensorflow resource. Handles are // not valid across executions, but can be serialized back and forth from within diff --git a/proto/tensorflow/core/framework/step_stats.proto b/proto/tensorflow/core/framework/step_stats.proto index 7976b03..d31f095 100644 --- a/proto/tensorflow/core/framework/step_stats.proto +++ b/proto/tensorflow/core/framework/step_stats.proto @@ -9,7 +9,7 @@ option cc_enable_arenas = true; option java_outer_classname = "StepStatsProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // An allocation/de-allocation operation performed by the allocator. message AllocationRecord { diff --git a/proto/tensorflow/core/framework/tensor.proto b/proto/tensorflow/core/framework/tensor.proto index b092b7e..a192469 100644 --- a/proto/tensorflow/core/framework/tensor.proto +++ b/proto/tensorflow/core/framework/tensor.proto @@ -10,7 +10,7 @@ option cc_enable_arenas = true; option java_outer_classname = "TensorProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Protocol buffer representing a tensor. message TensorProto { diff --git a/proto/tensorflow/core/framework/tensor_description.proto b/proto/tensorflow/core/framework/tensor_description.proto index 5168480..d78736b 100644 --- a/proto/tensorflow/core/framework/tensor_description.proto +++ b/proto/tensorflow/core/framework/tensor_description.proto @@ -10,7 +10,7 @@ option cc_enable_arenas = true; option java_outer_classname = "TensorDescriptionProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; message TensorDescription { // Data type of tensor elements diff --git a/proto/tensorflow/core/framework/tensor_shape.proto b/proto/tensorflow/core/framework/tensor_shape.proto index 286156a..ac475c4 100644 --- a/proto/tensorflow/core/framework/tensor_shape.proto +++ b/proto/tensorflow/core/framework/tensor_shape.proto @@ -5,7 +5,7 @@ option cc_enable_arenas = true; option java_outer_classname = "TensorShapeProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; package tensorflow; diff --git a/proto/tensorflow/core/framework/types.proto b/proto/tensorflow/core/framework/types.proto index 30294ba..71f0ae2 100644 --- a/proto/tensorflow/core/framework/types.proto +++ b/proto/tensorflow/core/framework/types.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "TypesProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // (== suppress_warning documentation-presence ==) // LINT.IfChange diff --git a/proto/tensorflow/core/framework/variable.proto b/proto/tensorflow/core/framework/variable.proto index 2f3ee3d..38f5638 100644 --- a/proto/tensorflow/core/framework/variable.proto +++ b/proto/tensorflow/core/framework/variable.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "VariableProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Indicates when a distributed variable will be synced. enum VariableSynchronization { diff --git a/proto/tensorflow/core/framework/versions.proto b/proto/tensorflow/core/framework/versions.proto index ceea484..087e896 100644 --- a/proto/tensorflow/core/framework/versions.proto +++ b/proto/tensorflow/core/framework/versions.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "VersionsProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework"; +option go_package = "tensorflow/core/framework"; // Version information for a piece of serialized data // diff --git a/proto/tensorflow/core/protobuf/cluster.proto b/proto/tensorflow/core/protobuf/cluster.proto index cc86353..ce06c24 100644 --- a/proto/tensorflow/core/protobuf/cluster.proto +++ b/proto/tensorflow/core/protobuf/cluster.proto @@ -21,7 +21,7 @@ option cc_enable_arenas = true; option java_outer_classname = "ClusterProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.distruntime"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // This file contains protos to be used when defining a TensorFlow // cluster. diff --git a/proto/tensorflow/core/protobuf/config.proto b/proto/tensorflow/core/protobuf/config.proto index 83e9852..809e460 100644 --- a/proto/tensorflow/core/protobuf/config.proto +++ b/proto/tensorflow/core/protobuf/config.proto @@ -15,7 +15,7 @@ option cc_enable_arenas = true; option java_outer_classname = "ConfigProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; message GPUOptions { // Fraction of the total GPU memory to allocate for each process. diff --git a/proto/tensorflow/core/protobuf/debug.proto b/proto/tensorflow/core/protobuf/debug.proto index 111c488..5cd2976 100644 --- a/proto/tensorflow/core/protobuf/debug.proto +++ b/proto/tensorflow/core/protobuf/debug.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "DebugProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // Option for watching a node in TensorFlow Debugger (tfdbg). message DebugTensorWatch { diff --git a/proto/tensorflow/core/protobuf/error_codes.proto b/proto/tensorflow/core/protobuf/error_codes.proto index 0e1b8d4..5ee78bf 100644 --- a/proto/tensorflow/core/protobuf/error_codes.proto +++ b/proto/tensorflow/core/protobuf/error_codes.proto @@ -8,4 +8,4 @@ package tensorflow.error.dummy; import public "tsl/protobuf/error_codes.proto"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; diff --git a/proto/tensorflow/core/protobuf/meta_graph.proto b/proto/tensorflow/core/protobuf/meta_graph.proto index 6df9969..3f18743 100644 --- a/proto/tensorflow/core/protobuf/meta_graph.proto +++ b/proto/tensorflow/core/protobuf/meta_graph.proto @@ -16,7 +16,7 @@ option cc_enable_arenas = true; option java_outer_classname = "MetaGraphProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // Protocol buffer containing the following which are necessary to restart // training, run inference. It can be used to serialize/de-serialize memory diff --git a/proto/tensorflow/core/protobuf/named_tensor.proto b/proto/tensorflow/core/protobuf/named_tensor.proto index 0696b89..404ef85 100644 --- a/proto/tensorflow/core/protobuf/named_tensor.proto +++ b/proto/tensorflow/core/protobuf/named_tensor.proto @@ -8,7 +8,7 @@ option cc_enable_arenas = true; option java_outer_classname = "NamedTensorProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // A pair of tensor name and tensor values. message NamedTensorProto { diff --git a/proto/tensorflow/core/protobuf/rewriter_config.proto b/proto/tensorflow/core/protobuf/rewriter_config.proto index 0a2021e..0d425e9 100644 --- a/proto/tensorflow/core/protobuf/rewriter_config.proto +++ b/proto/tensorflow/core/protobuf/rewriter_config.proto @@ -9,7 +9,7 @@ option cc_enable_arenas = true; option java_outer_classname = "RewriterConfigProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; message AutoParallelOptions { bool enable = 1; diff --git a/proto/tensorflow/core/protobuf/rpc_options.proto b/proto/tensorflow/core/protobuf/rpc_options.proto index c8716af..d488382 100644 --- a/proto/tensorflow/core/protobuf/rpc_options.proto +++ b/proto/tensorflow/core/protobuf/rpc_options.proto @@ -4,4 +4,4 @@ package tensorflow.dummy; import public "tsl/protobuf/rpc_options.proto"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; diff --git a/proto/tensorflow/core/protobuf/saved_object_graph.proto b/proto/tensorflow/core/protobuf/saved_object_graph.proto index 3a00db3..42dfa55 100644 --- a/proto/tensorflow/core/protobuf/saved_object_graph.proto +++ b/proto/tensorflow/core/protobuf/saved_object_graph.proto @@ -11,7 +11,7 @@ import "tensorflow/core/protobuf/struct.proto"; import "tensorflow/core/protobuf/trackable_object_graph.proto"; option cc_enable_arenas = true; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // A SavedObjectGraph is part of object-based SavedModels in TF 2.0. It // describes the directed graph of Python objects (or equivalent in other diff --git a/proto/tensorflow/core/protobuf/saver.proto b/proto/tensorflow/core/protobuf/saver.proto index d48a90b..4a2768a 100644 --- a/proto/tensorflow/core/protobuf/saver.proto +++ b/proto/tensorflow/core/protobuf/saver.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "SaverProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.util"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // Protocol buffer representing the configuration of a Saver. message SaverDef { diff --git a/proto/tensorflow/core/protobuf/struct.proto b/proto/tensorflow/core/protobuf/struct.proto index 06d8be3..114b049 100644 --- a/proto/tensorflow/core/protobuf/struct.proto +++ b/proto/tensorflow/core/protobuf/struct.proto @@ -6,7 +6,7 @@ import "tensorflow/core/framework/tensor.proto"; import "tensorflow/core/framework/tensor_shape.proto"; import "tensorflow/core/framework/types.proto"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // `StructuredValue` represents a dynamically typed value representing various // data structures that are inspired by Python data structures typically used in diff --git a/proto/tensorflow/core/protobuf/trackable_object_graph.proto b/proto/tensorflow/core/protobuf/trackable_object_graph.proto index 7e1e190..5ed40ad 100644 --- a/proto/tensorflow/core/protobuf/trackable_object_graph.proto +++ b/proto/tensorflow/core/protobuf/trackable_object_graph.proto @@ -5,7 +5,7 @@ package tensorflow; import "google/protobuf/wrappers.proto"; option cc_enable_arenas = true; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // A TensorBundle addition which saves extra information about the objects which // own variables, allowing for more robust checkpoint loading into modified diff --git a/proto/tensorflow/core/protobuf/verifier_config.proto b/proto/tensorflow/core/protobuf/verifier_config.proto index 6c3b7cb..92f9a2f 100644 --- a/proto/tensorflow/core/protobuf/verifier_config.proto +++ b/proto/tensorflow/core/protobuf/verifier_config.proto @@ -6,7 +6,7 @@ option cc_enable_arenas = true; option java_outer_classname = "VerifierConfigProtos"; option java_multiple_files = true; option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // The config for graph verifiers. message VerifierConfig { diff --git a/proto/tensorflow_serving/apis/classification.proto b/proto/tensorflow_serving/apis/classification.proto index 4de0b7d..85b2d35 100644 --- a/proto/tensorflow_serving/apis/classification.proto +++ b/proto/tensorflow_serving/apis/classification.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow_serving/apis/input.proto"; import "tensorflow_serving/apis/model.proto"; diff --git a/proto/tensorflow_serving/apis/get_model_metadata.proto b/proto/tensorflow_serving/apis/get_model_metadata.proto index 5d765d8..3a34e9f 100644 --- a/proto/tensorflow_serving/apis/get_model_metadata.proto +++ b/proto/tensorflow_serving/apis/get_model_metadata.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; option cc_enable_arenas = true; import "google/protobuf/any.proto"; diff --git a/proto/tensorflow_serving/apis/get_model_status.proto b/proto/tensorflow_serving/apis/get_model_status.proto index 8881247..eaf7df8 100644 --- a/proto/tensorflow_serving/apis/get_model_status.proto +++ b/proto/tensorflow_serving/apis/get_model_status.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow_serving/apis/model.proto"; import "tensorflow_serving/apis/status.proto"; diff --git a/proto/tensorflow_serving/apis/inference.proto b/proto/tensorflow_serving/apis/inference.proto index 16e85ce..0aae646 100644 --- a/proto/tensorflow_serving/apis/inference.proto +++ b/proto/tensorflow_serving/apis/inference.proto @@ -18,6 +18,7 @@ import "tensorflow_serving/apis/model.proto"; import "tensorflow_serving/apis/regression.proto"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; // Inference request such as classification, regression, etc... message InferenceTask { diff --git a/proto/tensorflow_serving/apis/input.proto b/proto/tensorflow_serving/apis/input.proto index e47ff43..6fdb65b 100644 --- a/proto/tensorflow_serving/apis/input.proto +++ b/proto/tensorflow_serving/apis/input.proto @@ -8,6 +8,7 @@ option cc_enable_arenas = true; import "tensorflow/core/example/example.proto"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; // Specifies one or more fully independent input Examples. // See examples at: diff --git a/proto/tensorflow_serving/apis/logging.proto b/proto/tensorflow_serving/apis/logging.proto index 0f9e876..fb14541 100644 --- a/proto/tensorflow_serving/apis/logging.proto +++ b/proto/tensorflow_serving/apis/logging.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow_serving/apis/model.proto"; import "tensorflow_serving/config/logging_config.proto"; diff --git a/proto/tensorflow_serving/apis/model.proto b/proto/tensorflow_serving/apis/model.proto index afd9590..9810fe8 100644 --- a/proto/tensorflow_serving/apis/model.proto +++ b/proto/tensorflow_serving/apis/model.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "google/protobuf/wrappers.proto"; diff --git a/proto/tensorflow_serving/apis/model_management.proto b/proto/tensorflow_serving/apis/model_management.proto index 2eba09b..374cc00 100644 --- a/proto/tensorflow_serving/apis/model_management.proto +++ b/proto/tensorflow_serving/apis/model_management.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow_serving/apis/status.proto"; import "tensorflow_serving/config/model_server_config.proto"; diff --git a/proto/tensorflow_serving/apis/model_service.proto b/proto/tensorflow_serving/apis/model_service.proto index 29a3b07..e94b93d 100644 --- a/proto/tensorflow_serving/apis/model_service.proto +++ b/proto/tensorflow_serving/apis/model_service.proto @@ -6,6 +6,7 @@ import "tensorflow_serving/apis/get_model_status.proto"; import "tensorflow_serving/apis/model_management.proto"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; // ModelService provides methods to query and update the state of the server, // e.g. which models/versions are being served. diff --git a/proto/tensorflow_serving/apis/predict.proto b/proto/tensorflow_serving/apis/predict.proto index e243b7a..8e9fde6 100644 --- a/proto/tensorflow_serving/apis/predict.proto +++ b/proto/tensorflow_serving/apis/predict.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow/core/framework/tensor.proto"; import "tensorflow_serving/apis/model.proto"; diff --git a/proto/tensorflow_serving/apis/prediction_log.proto b/proto/tensorflow_serving/apis/prediction_log.proto index 9deebc7..23d86de 100644 --- a/proto/tensorflow_serving/apis/prediction_log.proto +++ b/proto/tensorflow_serving/apis/prediction_log.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow_serving/apis/classification.proto"; import "tensorflow_serving/apis/inference.proto"; diff --git a/proto/tensorflow_serving/apis/prediction_service.proto b/proto/tensorflow_serving/apis/prediction_service.proto index 44e6554..e4160b0 100644 --- a/proto/tensorflow_serving/apis/prediction_service.proto +++ b/proto/tensorflow_serving/apis/prediction_service.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; option cc_enable_arenas = true; import "tensorflow_serving/apis/classification.proto"; diff --git a/proto/tensorflow_serving/apis/regression.proto b/proto/tensorflow_serving/apis/regression.proto index 5fb79ba..c283755 100644 --- a/proto/tensorflow_serving/apis/regression.proto +++ b/proto/tensorflow_serving/apis/regression.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow_serving/apis/input.proto"; import "tensorflow_serving/apis/model.proto"; diff --git a/proto/tensorflow_serving/apis/session_service.proto b/proto/tensorflow_serving/apis/session_service.proto index cf53c54..e732d86 100644 --- a/proto/tensorflow_serving/apis/session_service.proto +++ b/proto/tensorflow_serving/apis/session_service.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow/core/protobuf/config.proto"; import "tensorflow/core/protobuf/named_tensor.proto"; diff --git a/proto/tensorflow_serving/apis/status.proto b/proto/tensorflow_serving/apis/status.proto index 332d1b7..13e0f7b 100644 --- a/proto/tensorflow_serving/apis/status.proto +++ b/proto/tensorflow_serving/apis/status.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/apis"; import "tensorflow/core/protobuf/error_codes.proto"; diff --git a/proto/tensorflow_serving/config/file_system_storage_path_source.proto b/proto/tensorflow_serving/config/file_system_storage_path_source.proto index 6924fe4..ecfdc3d 100644 --- a/proto/tensorflow_serving/config/file_system_storage_path_source.proto +++ b/proto/tensorflow_serving/config/file_system_storage_path_source.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/config"; // Config proto for FileSystemStoragePathSource. message FileSystemStoragePathSourceConfig { diff --git a/proto/tensorflow_serving/config/log_collector_config.proto b/proto/tensorflow_serving/config/log_collector_config.proto index 4ce01d3..66e7b9d 100644 --- a/proto/tensorflow_serving/config/log_collector_config.proto +++ b/proto/tensorflow_serving/config/log_collector_config.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/config"; option cc_enable_arenas = true; message LogCollectorConfig { diff --git a/proto/tensorflow_serving/config/logging_config.proto b/proto/tensorflow_serving/config/logging_config.proto index 31fbe94..6e73f1e 100644 --- a/proto/tensorflow_serving/config/logging_config.proto +++ b/proto/tensorflow_serving/config/logging_config.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/config"; import "tensorflow_serving/config/log_collector_config.proto"; diff --git a/proto/tensorflow_serving/config/model_server_config.proto b/proto/tensorflow_serving/config/model_server_config.proto index cadc2b6..3837f6e 100644 --- a/proto/tensorflow_serving/config/model_server_config.proto +++ b/proto/tensorflow_serving/config/model_server_config.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package tensorflow.serving; +option go_package = "tensorflow_serving/config"; import "google/protobuf/any.proto"; import "tensorflow_serving/config/file_system_storage_path_source.proto"; diff --git a/proto/tsl/protobuf/coordination_config.proto b/proto/tsl/protobuf/coordination_config.proto index d88afe2..348b16e 100644 --- a/proto/tsl/protobuf/coordination_config.proto +++ b/proto/tsl/protobuf/coordination_config.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package tensorflow; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf"; +option go_package = "tensorflow/core/framework"; // Represents a job type and the number of tasks under this job. // For example, ("worker", 20) implies that there will be 20 worker tasks. diff --git a/proto/tsl/protobuf/error_codes.proto b/proto/tsl/protobuf/error_codes.proto index 32008c0..e29afa2 100644 --- a/proto/tsl/protobuf/error_codes.proto +++ b/proto/tsl/protobuf/error_codes.proto @@ -9,7 +9,7 @@ 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"; +option go_package = "tsl/protobuf"; // The canonical error codes for TensorFlow APIs. // diff --git a/proto/tsl/protobuf/rpc_options.proto b/proto/tsl/protobuf/rpc_options.proto index 17d5fbd..712f61f 100644 --- a/proto/tsl/protobuf/rpc_options.proto +++ b/proto/tsl/protobuf/rpc_options.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package tensorflow; -option go_package = "github.com/google/tsl/tsl/go/protobuf"; +option go_package = "tsl/protobuf"; // RPC options for distributed runtime. message RPCOptions { diff --git a/update.sh b/update.sh index 9de5c7e..f9c42c8 100755 --- a/update.sh +++ b/update.sh @@ -3,20 +3,24 @@ set -e cd $(dirname ${BASH_SOURCE[0]}) -ver="r$(cat VERSION | cut -d'.' -f1,2)" +ver="$(cat VERSION | cut -d'.' -f1,2)" proj=tensorflow-serving-client apis=tensorflow_serving/apis repo=build/upstream goto=proto -norm=('s@(tensorflow/core/)lib/core(/error_codes.proto)@\1protobuf\2@' +#groot="github.com/figroc/tensorflow-serving-client/v${ver%%.*}/go/" +norm=(#'s@(import "tensorflow)_(serving/.*.proto".*)@\1/\2@' + 's@(tensorflow/core/)lib/core(/.*.proto)@\1protobuf\2@' + "s@(option go_package = \")github.com/.*/([a-z_]+)/go(/.*)@\1${groot}\2\3@" + 's@(option go_package = ".*tensorflow/core/)protobuf(/.*)@\1framework\2@' 's@(option go_package = ".*)/[a-z_]*_go_proto(".*)@\1\2@') norm=$(IFS=';'; echo "${norm[*]}") rm -rf ${repo} && mkdir -p ${repo} function fetchRepo {( set -e git -C ${repo} \ - clone --depth 1 -b ${ver} \ + clone --depth 1 -b r${ver} \ https://github.com/tensorflow/${1}.git )} fetchRepo tensorflow tensorflow @@ -24,18 +28,28 @@ fetchRepo serving tensorflow_serving rm -rf ${goto} function importProto {( set -e - if [[ ! -f ${goto}/${1} ]]; then - for p in $(find ${repo} -path "*/${1}"); do - mkdir -p ${goto}/${1%/*} && echo ${1} - sed -E "${norm}" ${p} > ${goto}/${1} + local f=${1} i=${1} + #if [[ "${1}" == tensorflow_serving/* ]]; then + # i=${i/_//} + #elif [[ "${1}" == tensorflow/serving/* ]]; then + # f=${f/\//_} + #fi + if [[ ! -f ${goto}/${i} ]]; then + for p in $(find ${repo} -path "*/${f}"); do + mkdir -p ${goto}/${i%/*} && echo ${p} + local fix="${norm}" + if ! grep 'option go_package = "' ${p} &>/dev/null; then + fix+=";s@^package .*\$@&\\noption go_package = \"${groot}${i%/*}\"\;@" + fi + sed -E "${fix}" ${p} > ${goto}/${i} done - for p in $(grep -s '^import ' ${goto}/${1} \ + for p in $(grep -s '^import ' ${goto}/${i} \ | grep -Eo '((\w|-)+(/|\.))+proto'); do importProto ${p} done fi )} for i in ${repo}/serving/${apis}/*_service.proto; do - importProto ${i#${repo}/serving/} + importProto ${apis}/${i##*/} done importProto ${apis}/prediction_log.proto