Skip to content

Use external repository for protobuf dependency. - #1289

Merged
vrv merged 1 commit into
tensorflow:masterfrom
davidzchen:python-path
May 26, 2016
Merged

vrv merged 1 commit into
tensorflow:masterfrom
davidzchen:python-path

Conversation

@davidzchen

Copy link
Copy Markdown
Contributor

Currently, TensorFlow uses a Git submodule for its dependency on
protobuf. This was due to the hack used in protobuf for building Python
support with Bazel, which was required since Bazel's Python rules did
not support adding directories to PYTHONPATH. Now that the new
imports attribute has been added to the Python rules in Bazel 0.2 and
the hack for Python support in protobuf has been removed, this change
removes the google/protobuf Git submodule and adds an external
repository for including protobuf.

Fixes #1069

@tensorflow-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@vrv

vrv commented Feb 25, 2016

Copy link
Copy Markdown

So this require the entire world to upgrade to bazel 0.2, right?

@tensorflow-jenkins: test this please, but note that this probably will fail if the answer to the above question is "yes", since we haven't updated Jenkins to bazel 0.2 yet.

@davidzchen

Copy link
Copy Markdown
Contributor Author

@vrv - Yes, this would require everyone to upgrade to Bazel 0.2.

Also, the git_repository rule I added for including the protobuf repo references the current protobuf HEAD since my patch for removing the Python hack was just merged (see protocolbuffers/protobuf#1233). Is this fine or should we wait until the next protobuf release?

@davidzchen

Copy link
Copy Markdown
Contributor Author

I see that the Jenkins jobs are failing since the CI machines are running an older version of Bazel, which does not yet contain the imports property for Python rules.

@jendap

jendap commented Mar 1, 2016

Copy link
Copy Markdown
Contributor

We are going to upgrade bazel to 0.2 today anyway in #1206. We will update mac as well and this will work :)

@davidzchen
davidzchen force-pushed the python-path branch 2 times, most recently from a74d275 to dba1a2c Compare March 26, 2016 05:39
@davidzchen

Copy link
Copy Markdown
Contributor Author

I have rebased this patch on HEAD, resolved merge conflicts and made some additional changes since there are now additional targets that use protobuf.

@vrv

vrv commented Mar 26, 2016

Copy link
Copy Markdown

@tensorflow-jenkins : test this please

@vrv

vrv commented Apr 8, 2016

Copy link
Copy Markdown

Can you bump the version of required bazel https://github.com/tensorflow/tensorflow/blob/master/WORKSPACE#L21 here and then we can re-test?

@davidzchen
davidzchen force-pushed the python-path branch 2 times, most recently from 7bee4b8 to 16f3d8b Compare April 8, 2016 02:00
@davidzchen

Copy link
Copy Markdown
Contributor Author

Done.

@vrv

vrv commented Apr 8, 2016

Copy link
Copy Markdown

@tensorflow-jenkins test this please

@martinwicke

Copy link
Copy Markdown
Member

@vrv

vrv commented Apr 8, 2016

Copy link
Copy Markdown

Also looks like build_pip_package needs to be updated.

@davidzchen

Copy link
Copy Markdown
Contributor Author

@martinwicke There seems to be a few. I'll submit a PR to protobuf to add the missing srcs_versions.

@vrv Will do.

@davidzchen

Copy link
Copy Markdown
Contributor Author

Opened protocolbuffers/protobuf#1402.

What is the Bazel command run for http://ci.tensorflow.org/job/tensorflow-pull-requests-cpu-python3/262/consoleFull? I tried bazel test //... but I got an error about the BUILD file for gmock not being found:

❯❯❯ bazel test //...
ERROR: /usr/local/google/home/dzc/Projects/tensorflow/tensorflow/tensorflow/workspace.bzl:21:3: no such package '@gmock_archive//': In new_http_archive rule //external:gmock_archive the 'build_file' attribute does not specify an existing file (/usr/local/google/home/dzc/Projects/tensorflow/tensorflow/google/protobuf/gmock.BUILD does not exist) and referenced by '//external:gtest'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 0.190s
ERROR: Couldn't start the build. Unable to run tests.

Edit: Found the problem. It was because it was looking for gmock.BUILD in google/protobuf. This will need to be changed.

@martinwicke

Copy link
Copy Markdown
Member

The exact command is in the log, but the main point is bazel test
//tensorflow/...

On Fri, Apr 8, 2016 at 14:13 David Z. Chen [email protected] wrote:

Opened protocolbuffers/protobuf#1402 protocolbuffers/protobuf#1402.

What is the Bazel command run for
http://ci.tensorflow.org/job/tensorflow-pull-requests-cpu-python3/262/consoleFull?
I tried bazel test //... but I got an error about the BUILD file for
gmock not being found:

❯❯❯ bazel test //...
ERROR: /usr/local/google/home/dzc/Projects/tensorflow/tensorflow/tensorflow/workspace.bzl:21:3: no such package '@gmock_archive//': In new_http_archive rule //external:gmock_archive the 'build_file' attribute does not specify an existing file (/usr/local/google/home/dzc/Projects/tensorflow/tensorflow/google/protobuf/gmock.BUILD does not exist) and referenced by '//external:gtest'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 0.190s
ERROR: Couldn't start the build. Unable to run tests.

—
You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#1289 (comment)

@davidzchen
davidzchen force-pushed the python-path branch 3 times, most recently from 94b803f to 814bb00 Compare April 19, 2016 22:26
@martinwicke

Copy link
Copy Markdown
Member

Can you update the commit hash for protobuf?

@vrv, @keveman: Just to make sure -- this shouldn't interact with our binary protobuf distribution, right?

@davidzchen

Copy link
Copy Markdown
Contributor Author

I have updated the commit hash in tensorflow/workspace.bzl. I'm still debugging some build and test failures that I found when running bazel test //tensorflow/... on my Goobuntu machine (see below), but let's also run the CI to see if there is anything else that needs to be fixed.

❯❯❯ bazel test //tensorflow/...
WARNING: /usr/local/google/home/dzc/Projects/tensorflow/tensorflow/util/python/BUILD:11:16: in includes attribute of cc_library rule //util/python:python_headers: 'python_include' resolves to 'util/python/python_include' not in 'third_party'. This will be an error in the future
INFO: Found 709 targets and 418 test targets...
INFO: From Compiling external/protobuf/src/google/protobuf/compiler/js/js_generator.cc [for host]:
external/protobuf/src/google/protobuf/compiler/js/js_generator.cc: In function 'std::string google::protobuf::compiler::js::{anonymous}::JSByteGetterSuffix(google::protobuf::compiler::js::{anonymous}::BytesMode)':
external/protobuf/src/google/protobuf/compiler/js/js_generator.cc:492:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ERROR: /usr/local/google/home/dzc/.cache/bazel/_bazel_dzc/97010c3bd7554ebe07410261582c4d5e/external/protobuf/BUILD:581:1: C++ compilation of rule '@protobuf//:pyext/_message.so' failed: gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wl,-z,-relro,-z,no
w -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -iquote ... (remaining 48 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1
In file included from external/protobuf/python/google/protobuf/pyext/extension_dict.cc:34:0:
external/protobuf/python/google/protobuf/pyext/extension_dict.h:51:7: error: expected nested-name-specifier before 'shared_ptr'
 using shared_ptr;
       ^
external/protobuf/python/google/protobuf/pyext/extension_dict.h:51:7: error: 'shared_ptr' has not been declared
external/protobuf/python/google/protobuf/pyext/extension_dict.h:67:3: error: 'shared_ptr' does not name a type
   shared_ptr<Message> owner;
   ^
In file included from external/protobuf/python/google/protobuf/pyext/extension_dict.cc:43:0:
external/protobuf/python/google/protobuf/pyext/message.h:56:7: error: expected nested-name-specifier before 'shared_ptr'
 using shared_ptr;
       ^
external/protobuf/python/google/protobuf/pyext/message.h:56:7: error: 'shared_ptr' not declared
external/protobuf/python/google/protobuf/pyext/message.h:57:12: error: 'std::std' has not been declared
 using std::std::string;
            ^
In file included from external/protobuf/python/google/protobuf/pyext/extension_dict.cc:44:0:
external/protobuf/python/google/protobuf/pyext/repeated_composite_container.h:53:7: error: expected nested-name-specifier before 'shared_ptr'
 using shared_ptr;
       ^
external/protobuf/python/google/protobuf/pyext/repeated_composite_container.h:53:7: error: 'shared_ptr' not declared
In file included from external/protobuf/python/google/protobuf/pyext/extension_dict.cc:45:0:
external/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h:52:7: error: expected nested-name-specifier before 'shared_ptr'
 using shared_ptr;
       ^
external/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h:52:7: error: 'shared_ptr' not declared
external/protobuf/python/google/protobuf/pyext/extension_dict.cc: In function 'google::protobuf::python::ExtensionDict* google::protobuf::python::extension_dict::NewExtensionDict(google::protobuf::python::CMessage*)':
external/protobuf/python/google/protobuf/pyext/extension_dict.cc:251:9: error: 'google::protobuf::python::ExtensionDict' has no member named 'owner'
   self->owner = parent->owner;
         ^
external/protobuf/python/google/protobuf/pyext/extension_dict.cc: In function 'void google::protobuf::python::extension_dict::dealloc(google::protobuf::python::ExtensionDict*)':
external/protobuf/python/google/protobuf/pyext/extension_dict.cc:258:9: error: 'google::protobuf::python::ExtensionDict' has no member named 'owner'
   self->owner.reset();
         ^

INFO: Elapsed time: 44.875s, Critical Path: 33.67s
FAIL: //tensorflow/contrib/ctc:ctc_decoder_ops_test
FAIL: //tensorflow/contrib/ctc:ctc_loss_op_test
FAIL: //tensorflow/contrib/distributions:gaussian_conjugate_posteriors_test

~~~ snipped ~~~

@davidzchen

davidzchen commented May 26, 2016 •

Copy link
Copy Markdown
Contributor Author

Yes, just rebased, updated, and pushed.

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

@tensorflow-jenkins test this please

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

that failed quickly: ERROR: /workspace/tensorflow/workspace.bzl:84:3: no such package '@gmock_archive//': In new_http_archive rule //external:gmock_archive the 'build_file' attribute does not specify an existing file (/workspace/@protobuf/:gmock.BUILD does not exist) and referenced by '//external:gtest'.

@davidzchen

Copy link
Copy Markdown
Contributor Author

Odd. Looking

@davidzchen
davidzchen force-pushed the python-path branch 2 times, most recently from fade8b0 to f5a9740 Compare May 26, 2016 05:14
@davidzchen

Copy link
Copy Markdown
Contributor Author

Seems that this is caused by a bug in this version of Bazel that is fixed in a later version. In any case, it is probably better to have gmock.BUILD live in the tensorflow repo for now, similar to those for other dependencies, until we eventually upgrade to a version of gmock/gtest that has its own BUILD file.

Can you start the tests again?

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

test this please

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

Almost, looks like the pip install doesn't work

Python binary path to be used in PIP install: /usr/bin/python (Major.Minor version: 2.7)
Thu May 26 05:26:43 UTC 2016 : === Using tmpdir: /tmp/tmp.PJlk9Vtu7r
rsync: link_stat "/workspace/bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/google" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
build_pip_package FAILED

@davidzchen

Copy link
Copy Markdown
Contributor Author

I'll take a look. Is the command that the script used to invoke build_pip_package something along the lines of bazel run //tensorflow/tools/pip_package:build_pip_package -- /path/to/destination_dir?

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

Currently, TensorFlow uses a Git submodule for its dependency on
protobuf. This was due to the hack used in protobuf for building Python
support with Bazel, which was required since Bazel's Python rules did
not support adding directories to `PYTHONPATH`. Now that the new
`imports` attribute has been added to the Python rules in Bazel 0.2 and
the hack for Python support in protobuf has been removed, this change
removes the `google/protobuf` Git submodule and adds an external
repository for including protobuf.

This patch also adds gmock.BUILD to the tensorflow repo.

Fixes tensorflow#1069
Fixes tensorflow#2021
@davidzchen

davidzchen commented May 26, 2016 •

Copy link
Copy Markdown
Contributor Author

Should be fixed now. Not sure if this will work but:

@tensorflow-jenkins test this please

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

@tensorflow-jenkins test this please

@davidzchen

davidzchen commented May 26, 2016 •

Copy link
Copy Markdown
Contributor Author

Looks like all the tests passed this time, though on the GitHub UI, the MacOS CPU Tests is still marked as BUILDING even though it has succeeded on Jenkins. Could it be related to this message?

Executed 492 out of 492 tests: 492 tests pass.

Parameterized build ends with SUCCESS at: Thu May 26 16:40:30 UTC 2016 (Elapsed time: 1249 s)
Unable to get pull request builder trigger!!    <~~~~~
Setting status of 278cc4698b757c63edb8248aa051218435cf6415 to SUCCESS with url http://ci.tensorflow.org/job/tensorflow-pull-requests-cpu-python3/552/ and message: 'SUCCESS
 '
Using context: Linux CPU Tests (Python 3)
Finished: SUCCESS

Edit: or maybe not since other logs have that message too. Perhaps there's just some delay.

@vrv

vrv commented May 26, 2016

Copy link
Copy Markdown

Sweet, this is awesome. @martinwicke @caisq okay to merge? (I'll have to do some work internally to bring this change in, but I'll sign up for that this week).

@vrv
vrv merged commit 14ac223 into tensorflow:master May 26, 2016
@davidzchen

davidzchen commented May 26, 2016 •

Copy link
Copy Markdown
Contributor Author

\o/ Thanks!

@martinwicke

Copy link
Copy Markdown
Member

Woot

On Thu, May 26, 2016 at 3:25 PM David Z. Chen [email protected]
wrote:

\o/

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1289 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAjO_VGti6nugRU9vmAFc_GOhwHn_B-1ks5qFh3NgaJpZM4HjOh8
.

@petewarden

Copy link
Copy Markdown
Contributor

Yay!

@StephenOman

Copy link
Copy Markdown

I understand that Bazel is the preferred build tool for TensorFlow. However, it's worth noting that this change has some consequences for developers woking with alternative build tools:

  1. Since the git --recursive option is no longer going to clone Protobuf too, it will have to be cloned manually to get access to the required header files. The documentation needs to be updated to reflect that.
  2. The exact commit version of Protobuf to clone is buried in tensorflow/workspace.bzl rather than in the handy google/protobuf link. This is a pity as having it the original way means letting git worry about checking out the right version. The way it is configured now, future changes to the Protobuf version will need to be updated in several different build instruction files.
  3. As the google/protobuf path no longer exists, any Include Path directives will have to be modified to point to the new local Protobuf clone location. This is also a shame as having a standard folder google/protobuf in the workspace meant configuring the Include Path once in the build file and then forgetting about it. Now there'll be an extra step for each new developer to change it to point to his/her own Protobuf location.

I'd also add a more general request. This kind of change to the repo structure should have a minor release number with some release notes. It took me a good while to figure out why all the Protobuf headers had disappeared from my build environment after I merged in the latest tensorflow:master changes. I thought I had deleted them somehow and went around in circles before finding this PR.

@jendap

jendap commented Jun 4, 2016

Copy link
Copy Markdown
Contributor

We are sorry for the inconvenience @StephenOman!

It is much better to download git repos using bazel. Also for all the builds there is a lot of them, not just protobuf.

What build tool are you using? We have also have (incomplete):

  1. contrib/cmake - it may not work today but could be made work with some effort
  2. contrib/makefile - this one is super new. It is there to build the ios example. We will create CI build for it next week.

Please take a look at those two. Please contribute if one of them would suite you. Once we get them into reasonable state we can enable builds for them in ci.tensorflow.org. That way we make sure no change break that. No more breakage for you :)

@StephenOman

Copy link
Copy Markdown

Thanks for the note @jendap.

I'm wrapping the current C++ API with an Objective C++ interface in order to build a Swift-based iOS app. Complicated, I know! To do this, I'd created a set of Xcode projects to build both Protobuf and TensorFlow libs and am managing the build from there.

@jendap

jendap commented Jun 6, 2016

Copy link
Copy Markdown
Contributor

Take a look at contrib/makefile. We have added it exactly for this reason. It will be recommended way of working in xcode. We will soon have automated build this so it should work in future. But it is very new (may be even broken right now).

@StephenOman

Copy link
Copy Markdown

Right, I see where you are going with this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants