正如标题所暗示的那样,我遇到的问题是proto import语句似乎与正确的路径无关。为了具体,请考虑目录中的目录结构(让我们称之为〜/ base):
`>> tree -L 1
├── models
├── my-lib
| ├── nlp
| ├── BUILD
| └── nlp_parser.cc
| └── WORKSPACE
├── serving
└── tensorflow
对于那些不熟悉的人,models
(如在https://github.com/tensorflow/models/中)有张量流(https://github.com/tensorflow/tensorflow)作为git子模块,serving
也是如此。由于这一点加上tensorflow的git子模块在不同的提交和有时不兼容的事实,我已经从项目中删除了gitsubmodule并将它们符号链接到最顶层目录上的tensorflow repo,这样我只能管理一个张量流repo而不是3.那就是我做了以下事情:
`cd models/syntaxnet; rm -rf tensorflow; ln -s ../../tensorflow/ .; cd -`
`cd serving; rm -rf tensorflow tf_models; ln -s ../tensorflow/ .; ln -s ../models .`
现在,我想在my-lib
内构建一个取决于serving
,tensorflow
和models
的目标。我将这些作为本地存储库添加到我的WORKSPACE中,如下所示(cat my-lib/WORKSPACE
):
workspace(name = "myworkspace")
local_repository(
name = "org_tensorflow",
path = __workspace_dir__ + "/../tensorflow",
)
local_repository(
name = "syntaxnet",
path = __workspace_dir__ + "/../models/syntaxnet",
)
local_repository(
name = "tf_serving",
path = __workspace_dir__ + "/../serving",
)
load('@org_tensorflow//tensorflow:workspace.bzl', 'tf_workspace')
tf_workspace("~/base/tensorflow", "@org_tensorflow")
# ===== gRPC dependencies =====
bind(
name = "libssl",
actual = "@boringssl_git//:ssl",
)
bind(
name = "zlib",
actual = "@zlib_archive//:zlib",
)
这是我的BUILD文件(cat my-lib/nlp/BUILD
):
load("@tf_serving//tensorflow_serving:serving.bzl", "serving_proto_library")
cc_binary(
name = "nlp_parser",
srcs = [ "nlp_parser.cc" ],
linkopts = ["-lm"],
deps = [
"@org_tensorflow//tensorflow/core:core_cpu",
"@org_tensorflow//tensorflow/core:framework",
"@org_tensorflow//tensorflow/core:lib",
"@org_tensorflow//tensorflow/core:protos_all_cc",
"@org_tensorflow//tensorflow/core:tensorflow",
"@syntaxnet//syntaxnet:parser_ops_cc",
"@syntaxnet//syntaxnet:sentence_proto",
"@tf_serving//tensorflow_serving/servables/tensorflow:session_bundle_config_proto",
"@tf_serving//tensorflow_serving/servables/tensorflow:session_bundle_factory",
"@org_tensorflow//tensorflow/contrib/session_bundle",
"@org_tensorflow//tensorflow/contrib/session_bundle:signature",
],
)
最后,这是构建的输出(cd my-lib; bazel build nlp/nlp_parser --verbose_failures
):
INFO: Found 1 target...
ERROR: /home/blah/blah/external/org_tensorflow/tensorflow/core/debug/BUILD:33:1: null failed: linux-sandbox failed: error executing command
(cd /home/blah/blah/execroot/my-lib && \
exec env - \
/home/blah/blah/execroot/my-lib/_bin/linux-sandbox @/home/blah/blah/execroot/my-lib/bazel-sandbox/c65fa6b6-9b7d-4710-b19c-4d42a3e6a667-31.params -- bazel-out/host/bin/external/protobuf/protoc '--cpp_out=bazel-out/local-fastbuild/genfiles/external/org_tensorflow' '--plugin=protoc-gen-grpc=bazel-out/host/bin/external/grpc/grpc_cpp_plugin' '--grpc_out=bazel-out/local-fastbuild/genfiles/external/org_tensorflow' -Iexternal/org_tensorflow -Ibazel-out/local-fastbuild/genfiles/external/org_tensorflow -Iexternal/protobuf/src -Ibazel-out/local-fastbuild/genfiles/external/protobuf/src external/org_tensorflow/tensorflow/core/debug/debug_service.proto).
bazel-out/local-fastbuild/genfiles/external/protobuf/src: warning: directory does not exist.
tensorflow/core/util/event.proto: File not found.
tensorflow/core/debug/debug_service.proto: Import "tensorflow/core/util/event.proto" was not found or had errors.
tensorflow/core/debug/debug_service.proto:38:25: "Event" is not defined.
Target //nlp:nlp_parser failed to build
INFO: Elapsed time: 0.776s, Critical Path: 0.42s
在WORKSPACE中将模块添加为local_repository的正确方法是什么,以便原型导入有效?
答案 0 :(得分:2)
在尝试根据Ubuntu上的tensorflow构建我的项目后,我遇到了类似的问题。在OS X上构建它之后。最终为我工作的是使用const tasks = this.state.tasks.map((task) => {
var editable = this.state.editableTasks.filter(id => id === task.Id).length > 0;
return (
<li key={task.Id} className="list-group-item" style={{minHeight: '50px'}}>
<div className="pull-left" style={{width: '50%'}}>
{editable ? <input type="text" /> : <span>{task.Name}</span>}
</div>
<div className="pull-right" style={{marginTop: '-5px', width: '50%'}}>
<div className="pull-right">
<button className="btn btn-default" onClick={() => {this.AddSubTask(task.Id)}}>Add</button>
<button className="btn btn-default" onClick={() => { this.EditTask(task.Id)}}>{editable ? 'Save' : 'Edit'}</button>
</div>
</div>
</li>
//What I have currently tried:
//for(var i = 0; i < task.SubTasks.length; i++) {
//<ul>
//<li>
//...etc
//</li>
//</ul>
//}
//{task.SubTasks.map((subtask) => {
//<ul>
//<li>
//...etc
//</li>
//</ul>
//)};
);
});
return (
<div className="table-wrapper">
<div className="task-container">
<h3>{this.props.rowName}</h3>
</div>
<ul id="tasksContainer">
{tasks}
<li className="list-group-item list-group-item-last"><input type="button" value="Add Task" onClick={this.createTask.bind(this)} className="btn btn-success btn-override" /></li>
</ul>
</div>
);
禁用沙盒