diff --git a/WORKSPACE b/WORKSPACE index ea14f107b..d5556d34a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -52,10 +52,10 @@ 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", + "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") @@ -63,10 +63,10 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_to 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") diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index 2ab46051b..3c3d1ff48 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -647,3 +647,40 @@ cc_test( "@org_tensorflow//tensorflow/core:test", ], ) + +ml_metadata_go_wrap_cc( + 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", + ], +) diff --git a/ml_metadata/ml_metadata.bzl b/ml_metadata/ml_metadata.bzl index 1b73eec48..4ea3b42ba 100644 --- a/ml_metadata/ml_metadata.bzl +++ b/ml_metadata/ml_metadata.bzl @@ -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" @@ -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, diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index a1fc57b1f..d93ea714f 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -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"); @@ -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"], ) @@ -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", +) diff --git a/ml_metadata/tools/mlmd_bench/proto/BUILD b/ml_metadata/tools/mlmd_bench/proto/BUILD index fa9cf12d8..642435ef8 100644 --- a/ml_metadata/tools/mlmd_bench/proto/BUILD +++ b/ml_metadata/tools/mlmd_bench/proto/BUILD @@ -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"); @@ -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", +)