Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metadata_store_service_go_proto build error #113

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz",
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lowering the io_bazel_rules_go and bazel_gazelle versions had issues to build other targets in the workspace (e.g., pip wheels, and cc). let's keep them as is for now? Please also see the background in the metadata_store/BUILD comment below.

"https://github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz",
],
sha256 = "e88471aea3a3a4f19ec1310a55ba94772d087e9ce46e41ae38ecebe17935de7b",
sha256 = "492c3ac68ed9dcf527a07e6a1b2dcbf199c6bf8b35517951467ac32e421c06c1",
)

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")

http_archive(
name = "bazel_gazelle",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz",
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.16.0/bazel-gazelle-0.16.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.16.0/bazel-gazelle-0.16.0.tar.gz",
],
sha256 = "86c6d481b3f7aedc1d60c1c211c6f76da282ae197c3b3160f54bd3a8f847896f",
sha256 = "7949fc6cc17b5b191103e97481cf8889217263acf52e00b560683413af204fcb",
)

load("@bazel_gazelle//:deps.bzl", "go_repository")
Expand Down
37 changes: 37 additions & 0 deletions ml_metadata/metadata_store/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,40 @@ cc_test(
"@org_tensorflow//tensorflow/core:test",
],
)

ml_metadata_go_wrap_cc(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq, will you only depend on the proto targets? if so, shall we exclude these targets?

Some background, the go libs were excluded temporarily due to the go-rules had issues with py3.8 / py3.9 integration testing images. The grpc, proto dependencies currently were introduced by TF workspace. We had a todo to reintroduce them back once drop the TF's dependency in the WORKSPACE.

name = "metadata_store_go_wrap",
importpath = "ml_metadata/metadata_store/metadata_store_go_wrap",
libname = "metadata_store_cgo_wrap",
swigfile = "metadata_store_go",
deps = [
":metadata_store_factory",
"@org_tensorflow//tensorflow/core:lib",
],
)

ml_metadata_go_library(
name = "metadata_store_go",
srcs = ["metadata_store.go"],
cdeps = ["metadata_store_cgo_wrap"],
cgo = True,
importpath = "ml_metadata/metadata_store/mlmetadata",
deps = [
":metadata_store_go_wrap",
"//ml_metadata/proto:metadata_store_go_proto",
"//ml_metadata/proto:metadata_store_service_go_proto",
"@com_github_golang_protobuf//proto:go_default_library",
],
)

ml_metadata_go_test(
name = "metadata_store_go_test",
size = "small",
srcs = ["metadata_store_test.go"],
library = ":metadata_store_go",
deps = [
"//ml_metadata/proto:metadata_store_go_proto",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_google_go_cmp//cmp:go_default_library",
],
)
5 changes: 5 additions & 0 deletions ml_metadata/ml_metadata.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def ml_metadata_proto_library_go(
importpath = None,
cc_proto_deps = [],
go_proto_deps = [],
sub_proto_deps = [],
gen_oss_grpc = False):
"""Opensource go_proto_library."""
proto_library_name = deps[0][1:] + "_copy"
Expand All @@ -114,6 +115,10 @@ def ml_metadata_proto_library_go(
proto_library_deps = []
for dep in cc_proto_deps:
proto_library_deps.append(dep + "_copy")

for dep in sub_proto_deps:
proto_library_deps.append(dep)

native.proto_library(
name = proto_library_name,
srcs = srcs,
Expand Down
27 changes: 27 additions & 0 deletions ml_metadata/proto/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -57,6 +60,7 @@ ml_metadata_proto_library_py(
ml_metadata_proto_library_go(
name = "metadata_store_go_proto",
srcs = ["metadata_store.proto"],
sub_proto_deps = ["@com_google_protobuf//:struct_proto"],
importpath = "ml_metadata/proto/metadata_store_go_proto",
deps = [":metadata_store_proto"],
)
Expand All @@ -76,3 +80,26 @@ ml_metadata_proto_library(
srcs = ["metadata_source.proto"],
cc_api_version = 2,
)

proto_library(
name = "ml_metadata_proto",
srcs = [
"metadata_source.proto",
"metadata_store.proto",
"metadata_store_service.proto",
],
deps = ["@com_google_protobuf//:struct_proto"],
)

go_proto_library(
name = "ml_metadata_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/google/ml-metadata/ml_metadata/proto",
proto = ":ml_metadata_proto",
)

go_library(
name = "go_default_library",
embed = [":ml_metadata_go_proto"],
importpath = "github.com/google/ml-metadata/ml_metadata/proto",
)
22 changes: 22 additions & 0 deletions ml_metadata/tools/mlmd_bench/proto/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -28,3 +31,22 @@ ml_metadata_proto_library(
"//ml_metadata/proto:metadata_store_proto",
],
)

proto_library(
name = "ml_metadata_proto",
srcs = ["mlmd_bench.proto"],
deps = ["//ml_metadata/proto:ml_metadata_proto"],
)

go_proto_library(
name = "ml_metadata_go_proto",
importpath = "github.com/google/ml-metadata/ml_metadata/tools/mlmd_bench/proto",
proto = ":ml_metadata_proto",
deps = ["//ml_metadata/proto:go_default_library"],
)

go_library(
name = "go_default_library",
embed = [":ml_metadata_go_proto"],
importpath = "github.com/google/ml-metadata/ml_metadata/tools/mlmd_bench/proto",
)