Skip to content

Commit

Permalink
Transition TensorFlow Serving to TensorFlow's new WORKSPACE protocol.
Browse files Browse the repository at this point in the history
Actions taken:

- Remove code duplicated from TF's [old WORKSPACE](tensorflow/tensorflow@36d0f2e#diff-5493ff8e9397811510e780de47c57abb70137f1afe85d1519130dc3679d60ce5) file.
- Move all external repository imports to `tf_serving_workspace()` macro.
- Initialize external repositories in WORKSPACE file.

In particular, the last item for TensorFlow corresponds to the following block:
```
load("@org_tensorflow//tensorflow:workspace3.bzl", "workspace")
workspace()
load("@org_tensorflow//tensorflow:workspace2.bzl", "workspace")
workspace()
load("@org_tensorflow//tensorflow:workspace1.bzl", "workspace")
workspace()
load("@org_tensorflow//tensorflow:workspace0.bzl", "workspace")
workspace()
```

PiperOrigin-RevId: 351864461
  • Loading branch information
chsigg authored and tensorflow-copybara committed Jan 14, 2021
1 parent 0acaa63 commit 50a7ef3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 109 deletions.
89 changes: 27 additions & 62 deletions WORKSPACE
@@ -1,5 +1,10 @@
workspace(name = "tf_serving")

# ===== TensorFlow dependency =====
#
# TensorFlow is imported here instead of in tf_serving_workspace() because
# existing automation scripts that bump the TF commit hash expect it here.
#
# To update TensorFlow to a new revision.
# 1. Update the 'git_commit' args below to include the new git hash.
# 2. Get the sha256 hash of the archive with a command such as...
Expand All @@ -8,77 +13,37 @@ workspace(name = "tf_serving")
# 3. Request the new archive to be mirrored on mirror.bazel.build for more
# reliable downloads.
load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive")

tensorflow_http_archive(
name = "org_tensorflow",
sha256 = "95d9b5e48f22942fb16e254f05ab2fbd62dd8b5e4cae2b36d49d511f9eb0243f",
git_commit = "100b443d8fac3108da3240a8130b3e196e9f25d6",
)

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

http_archive(
name = "rules_pkg",
sha256 = "352c090cc3d3f9a6b4e676cf42a6047c16824959b438895a76c2989c6d7c246a",
url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz",
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()

load(
"@org_tensorflow//third_party/toolchains/preconfig/generate:archives.bzl",
"bazel_toolchains_archive",
)

bazel_toolchains_archive()

load(
"@bazel_toolchains//repositories:repositories.bzl",
bazel_toolchains_repositories = "repositories",
)

bazel_toolchains_repositories()

# START: Upstream TensorFlow dependencies
# TensorFlow build depends on these dependencies.
# Needs to be in-sync with TensorFlow sources.
http_archive(
name = "io_bazel_rules_closure",
sha256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9",
strip_prefix = "rules_closure-308b05b2419edb5c8ee0471b67a40403df940149",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz", # 2019-06-13
],
)
http_archive(
name = "bazel_skylib",
sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
],
) # https://github.com/bazelbuild/bazel-skylib/releases

# END: Upstream TensorFlow dependencies

# Please add all new TensorFlow Serving dependencies in workspace.bzl.
# Import all of TensorFlow Serving's external dependencies.
# Downstream projects (projects importing TensorFlow Serving) need to
# duplicate all code below in their WORKSPACE file in order to also initialize
# those external dependencies.
load("//tensorflow_serving:workspace.bzl", "tf_serving_workspace")

tf_serving_workspace()

# Specify the minimum required bazel version.
load("@org_tensorflow//tensorflow:version_check.bzl", "check_bazel_version_at_least")

# Check bazel version requirement, which is stricter than TensorFlow's.
load(
"@org_tensorflow//tensorflow:version_check.bzl",
"check_bazel_version_at_least"
)
check_bazel_version_at_least("3.0.0")

# GRPC deps, required to match TF's. Only after calling tf_serving_workspace()
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

load("@upb//bazel:repository_defs.bzl", "bazel_version_repository")
# Initialize TensorFlow's external dependencies.
load("@org_tensorflow//tensorflow:workspace3.bzl", "workspace")
workspace()
load("@org_tensorflow//tensorflow:workspace2.bzl", "workspace")
workspace()
load("@org_tensorflow//tensorflow:workspace1.bzl", "workspace")
workspace()
load("@org_tensorflow//tensorflow:workspace0.bzl", "workspace")
workspace()

# Initialize bazel package rules' external dependencies.
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

bazel_version_repository(name = "bazel_version")
66 changes: 19 additions & 47 deletions tensorflow_serving/workspace.bzl
@@ -1,51 +1,42 @@
# TensorFlow Serving external dependencies that can be loaded in WORKSPACE
# files.
"""Provides a macro to import all TensorFlow Serving dependencies.
Some of the external dependencies need to be initialized. To do this, duplicate
the initialization code from TensorFlow Serving's WORKSPACE file.
"""

load("@org_tensorflow//third_party:repo.bzl", "tf_http_archive")
load("@org_tensorflow//tensorflow:workspace.bzl", "tf_workspace")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def tf_serving_workspace():
"""All TensorFlow Serving external dependencies."""

tf_workspace(path_prefix = "", tf_repo_name = "org_tensorflow")

# ===== gRPC dependencies =====
native.bind(
name = "libssl",
actual = "@boringssl//:ssl",
)

# gRPC wants the existence of a cares dependence but its contents are not
# actually important since we have set GRPC_ARES=0 in tools/bazel.rc
native.bind(
name = "cares",
actual = "@grpc//third_party/nanopb:nanopb",
# ===== Bazel package rules dependency =====
http_archive(
name = "rules_pkg",
sha256 = "352c090cc3d3f9a6b4e676cf42a6047c16824959b438895a76c2989c6d7c246a",
url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz",
)

# ===== RapidJSON (rapidjson.org) dependencies =====
# ===== RapidJSON (rapidjson.org) dependency =====
http_archive(
name = "com_github_tencent_rapidjson",
urls = [
"https://github.com/Tencent/rapidjson/archive/v1.1.0.zip",
],
url = "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip",
sha256 = "8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab",
strip_prefix = "rapidjson-1.1.0",
build_file = "@//third_party/rapidjson:BUILD",
)

# ===== libevent (libevent.org) dependencies =====
# ===== libevent (libevent.org) dependency =====
http_archive(
name = "com_github_libevent_libevent",
urls = [
"https://github.com/libevent/libevent/archive/release-2.1.8-stable.zip",
],
url = "https://github.com/libevent/libevent/archive/release-2.1.8-stable.zip",
sha256 = "70158101eab7ed44fd9cc34e7f247b3cae91a8e4490745d9d6eb7edc184e4d96",
strip_prefix = "libevent-release-2.1.8-stable",
build_file = "@//third_party/libevent:BUILD",
)

# ===== Override TF & TF Text defined 'ICU'. (we need a version that contains all data).
# ===== ICU dependency =====
# Note: This overrides the dependency from TensorFlow with a version
# that contains all data.
http_archive(
name = "icu",
strip_prefix = "icu-release-64-2",
Expand All @@ -59,21 +50,6 @@ def tf_serving_workspace():
patch_args = ["-p1", "-s"],
)

# ===== Pin `com_google_absl` with the same version(and patch) with Tensorflow.
tf_http_archive(
name = "com_google_absl",
build_file = str(Label("@org_tensorflow//third_party:com_google_absl.BUILD")),
# TODO: Remove the patch when https://github.com/abseil/abseil-cpp/issues/326 is resolved
# and when TensorFlow is build against CUDA 10.2
patch_file = str(Label("@org_tensorflow//third_party:com_google_absl_fix_mac_and_nvcc_build.patch")),
sha256 = "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a", # SHARED_ABSL_SHA
strip_prefix = "abseil-cpp-df3ea785d8c30a9503321a3d35ee7d35808f190d",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
"https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
],
)

# ===== TF.Text dependencies
# NOTE: Before updating this version, you must update the test model
# and double check all custom ops have a test:
Expand All @@ -82,9 +58,7 @@ def tf_serving_workspace():
name = "org_tensorflow_text",
sha256 = "05cc1b0eda8f4f734cb81d4389a637d26372b8621cb4c4a7e30ee5bc1e8c63da",
strip_prefix = "text-2.3.0",
urls = [
"https://github.com/tensorflow/text/archive/v2.3.0.zip",
],
url = "https://github.com/tensorflow/text/archive/v2.3.0.zip",
patches = ["@//third_party/tf_text:tftext.patch"],
patch_args = ["-p1"],
repo_mapping = {"@com_google_re2": "@com_googlesource_code_re2"},
Expand All @@ -94,9 +68,7 @@ def tf_serving_workspace():
name = "com_google_sentencepiece",
strip_prefix = "sentencepiece-1.0.0",
sha256 = "c05901f30a1d0ed64cbcf40eba08e48894e1b0e985777217b7c9036cac631346",
urls = [
"https://github.com/google/sentencepiece/archive/1.0.0.zip",
],
url = "https://github.com/google/sentencepiece/archive/1.0.0.zip",
)

http_archive(
Expand Down

0 comments on commit 50a7ef3

Please sign in to comment.