Skip to content

Commit 78f97c2

Browse files
authored
build: update protobuf to 3.19.6 and grpc to 1.48.2 (#6147)
Fixes #5708 and #5703. This updates our protobuf dependency to 3.19.6 in an attempt to address #5708, and provide a cleaner solution to #5703. The choice of 3.19.6 is meant to satisfy two competing constraints: - Current Python protobuf runtimes (the 4.x series) only support generated code from protoc versions 3.19.0+, as discussed in https://protobuf.dev/news/2022-05-06/. As a result, prior to this change, TensorBoard's pip package had to force its pip package dependency to `protobuf < 4` to avoid the errors seen in #5703. This PR lifts that restriction. - Current TensorFlow is still stuck on protobuf 3.x, the same as we have been, and as a result pins its pip package dependency using `protobuf < 3.20` (this could presumably be relaxed to `< 4` but that would require new TF releases). As a result, we must support at least one protobuf runtime version that also works with TF's constraints. Our previous attempt at this upgrade (to ~3.18 or so) caused test failures for Keras (which depends on TB, via TF, for the summary API code), apparently due to a protobuf runtime that was too old for our generated code. At the time, this was puzzling because they were pip-installing a protobuf runtime version that should have been recent enough - but I suspect now that this was a red herring, and bazel test was actually getting the protobuf runtime from the protobuf build dependency, not from the installed Python packages. If we see this failure mode again, we'll have to get Keras to update the protobuf Python runtime available in bazel tests. Lastly, this upgrade lets us clean up some additional issues we had to work around: - We can also upgrade gRPC now, to 1.48.2. I selected this version since it appears to be the most recent version prior to gRPC adopting protobuf 4.x (see grpc/grpc@41ec08c) - We can revert the backported fixes to protobuf and grpc from #5793, since the upgraded dependencies don't require patching - We can back out rules_apple reintroduction from #5561 that we only needed for gRPC
1 parent 15aa812 commit 78f97c2

File tree

6 files changed

+34
-125
lines changed

6 files changed

+34
-125
lines changed

WORKSPACE

+27-67
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ workspace(name = "org_tensorflow_tensorboard")
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44

5-
http_archive(
6-
name = "build_bazel_rules_apple",
7-
sha256 = "0052d452af7742c8f3a4e0929763388a66403de363775db7e90adecb2ba4944b",
8-
urls = [
9-
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz",
10-
"https://github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz",
11-
],
12-
)
13-
145
http_archive(
156
name = "bazel_skylib",
167
sha256 = "07b4117379dde7ab382345c3b0f5edfc6b7cff6c93756eac63da121e0bbcc5de",
@@ -121,74 +112,43 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
121112

122113
sass_repositories()
123114

124-
# Always bump the requirements.txt protobuf dep to be >= the version here.
125-
# Keep this version to be in sync with TensorFlow:
126-
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace2.bzl#L446
127-
# For other projects (e.g. Keras) depending on tb-nightly, generating protobuf code at
128-
# a more recent version than the protobuf runtime supplied by TF's bazel build tooling
129-
# might lead to test failures.
115+
# This dependency specifies the version of protobuf that will be used to compile
116+
# protos as part of TensorBoard's build (i.e., the protoc version).
117+
#
118+
# This version must always be <= the protobuf runtime version, which is the version of
119+
# the "protobuf" pip package as specified in our requirements.txt file.
120+
#
121+
# NOTE: This dependency currently cannot be advanced past 3.19.x. This is because
122+
# TF is currently unable to use a runtime any greater than 3.19.x, see details here:
123+
# https://github.com/tensorflow/tensorflow/blob/9d22f4a0a9499c8e10a4312503e63e0da35ccd94/tensorflow/tools/pip_package/setup.py#L100-L107
124+
#
125+
# As a result of TF's constraint and the above <= requirement, 3.19.x is the most recent
126+
# possible protoc we can use while remaining cross-compatible with TF. At the same time,
127+
# 3.19.x is the minimum possible protoc that will generate compiled proto code that *is*
128+
# compatible with protobuf runtimes >= 4, as discussed here:
129+
# https://developers.google.com/protocol-buffers/docs/news/2022-05-06
130130
http_archive(
131131
name = "com_google_protobuf",
132-
patch_args = ["-p1"],
133-
patches = [
134-
# To maintain compatibility with python 3.10 and greater, we need to patch
135-
# in the following protobuf change:
136-
# https://github.com/grpc/grpc/commit/9d61eada0f47d7be793983638c4a29707b192d0c
137-
#
138-
# To reproduce the patch:
139-
# ```
140-
# $ git clone https://github.com/protocolbuffers/protobuf.git
141-
# $ cd protobuf
142-
# $ git checkout tags/v3.9.2 -b my-patch
143-
# $ git cherry-pick 9d61eada0f47d7be793983638c4a29707b192d0c
144-
# $ git diff HEAD~1 > protobuf.patch
145-
# # Remove trailing whitespace to satisify whitespace_hygiene_test.py.
146-
# $ sed -i 's/[[:space:]]*$//' protobuf.patch
147-
# ```
148-
"//third_party:protobuf.patch",
149-
],
150-
sha256 = "1fbf1c2962af287607232b2eddeaec9b4f4a7a6f5934e1a9276e9af76952f7e0",
151-
strip_prefix = "protobuf-3.9.2",
132+
sha256 = "9a301cf94a8ddcb380b901e7aac852780b826595075577bb967004050c835056",
133+
strip_prefix = "protobuf-3.19.6",
152134
urls = [
153-
"http://mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/v3.9.2.tar.gz",
154-
"https://github.com/protocolbuffers/protobuf/archive/v3.9.2.tar.gz", # 2019-09-23
135+
"http://mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/v3.19.6.tar.gz",
136+
"https://github.com/protocolbuffers/protobuf/archive/v3.19.6.tar.gz", # 2022-09-29
155137
],
156138
)
157139

158140
# gRPC.
141+
#
142+
# NOTE: The version used here must be cross-compatible with our protobuf version.
143+
# As 2023-01-13, 1.48.2 is the most recent gRPC release that was still using a 3.19.x
144+
# version of protobuf in its own builds (more recent releases move to 3.21.x).
159145
http_archive(
160146
name = "com_github_grpc_grpc",
161-
patch_args = ["-p1"],
162-
patches = [
163-
# To maintain compatibility with python 3.10 and greater, we need to patch
164-
# in the following grpc change:
165-
# https://github.com/grpc/grpc/commit/dbe73c9004e483d24168c220cd589fe1824e72bc
166-
#
167-
# To reproduce the patch:
168-
# ```
169-
# $ git clone https://github.com/grpc/grpc.git
170-
# $ cd grpc
171-
# $ git checkout b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd -b my-patch
172-
# $ git cherry-pick dbe73c9004e483d24168c220cd589fe1824e72bc
173-
# $ git diff HEAD~1 > grpc.patch
174-
# ```
175-
#
176-
# Note that we choose b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd as the
177-
# base since it matches the archive (the commit number is in the archive
178-
# file's name). There is no exact corresponding tag to use but the
179-
# nearest might be v1.27.0-pre1.
180-
"//third_party:grpc.patch",
181-
],
182-
sha256 = "b956598d8cbe168b5ee717b5dafa56563eb5201a947856a6688bbeac9cac4e1f",
183-
strip_prefix = "grpc-b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd",
147+
sha256 = "bdb8e98145469d58c69ab9f2c9e0bd838c2836a99b5760bc0ebf658623768f52",
148+
strip_prefix = "grpc-1.48.2",
184149
urls = [
185-
# Same as TF: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace2.bzl#L492
186-
# Currently we can't upgrade gRPC past 1.30.0 without also bumping protobuf to 3.12.0+:
187-
# https://github.com/grpc/grpc/issues/23311.
188-
#
189-
# Inspecting the contents of this archive, the version is v1.27.0-dev.
190-
"http://mirror.tensorflow.org/github.com/grpc/grpc/archive/b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd.tar.gz",
191-
"https://github.com/grpc/grpc/archive/b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd.tar.gz",
150+
"http://mirror.tensorflow.org/github.com/grpc/grpc/archive/v1.48.2.tar.gz",
151+
"https://github.com/grpc/grpc/archive/v1.48.2.tar.gz", # 2022-09-21
192152
],
193153
)
194154

-1.9 KB
Binary file not shown.

tensorboard/pip_package/requirements.txt

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
# Non-vendored runtime dependencies of TensorBoard.
1717

1818
absl-py >= 0.4
19-
grpcio >= 1.24.3
19+
# NOTE: this version should be >= the grpc version in our WORKSPACE file.
20+
grpcio >= 1.48.2
2021
google-auth >= 1.6.3, < 3
2122
google-auth-oauthlib >= 0.4.1, < 0.5
2223
markdown >= 2.6.8
2324
numpy >= 1.12.0
24-
# Protobuf 4.0 is incompatible with TF. Force < 4 until they unblock upgrade.
25-
# See: http://b/182876485
26-
# See: https://github.com/protocolbuffers/protobuf/issues/9954#issuecomment-1128283911
27-
# See: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/tools/pip_package/setup.py?q=protobuf
28-
protobuf >= 3.9.2, < 4
25+
# NOTE: this version must be >= the protoc version in our WORKSPACE file.
26+
# At the same time, any constraints we specify here must allow at least some
27+
# version to be installed that is also compatible with TensorFlow's constraints:
28+
# https://github.com/tensorflow/tensorflow/blob/9d22f4a0a9499c8e10a4312503e63e0da35ccd94/tensorflow/tools/pip_package/setup.py#L100-L107
29+
protobuf >= 3.19.6
2930
requests >= 2.21.0, < 3
3031
setuptools >= 41.0.0
3132
tensorboard-data-server >= 0.6.0, < 0.7.0

third_party/grpc.patch

-33
This file was deleted.

third_party/protobuf.patch

-18
This file was deleted.

third_party/protobuf/BUILD

-1
This file was deleted.

0 commit comments

Comments
 (0)