From 44b17bc59bd1fc8ebeee979e7e243105b720faca Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:34:08 -0700 Subject: [PATCH 01/31] Update WORKSPACE --- WORKSPACE | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 246515185..d519ba772 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -108,9 +108,9 @@ http_archive( http_archive( name = "com_google_protobuf", - sha256 = "1add10f9bd92775b91f326da259f243881e904dd509367d5031d4c782ba82810", - strip_prefix = "protobuf-3.21.9", - urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.9.tar.gz"], + sha256 = "4e6727bc5d23177edefa3ad86fd2f5a92cd324151636212fd1f7f13aef3fd2b7", + strip_prefix = "protobuf-4.25.6", + urls = ["https://github.com/protocolbuffers/protobuf/archive/v4.25.6.tar.gz"], ) load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") @@ -247,13 +247,14 @@ http_archive( url = "https://github.com/gflags/gflags/archive/a738fdf9338412f83ab3f26f31ac11ed3f3ec4bd.zip", ) -ZETASQL_COMMIT = "ac37cf5c0d80b5605176fc0f29e87b12f00be693" # 08/10/2022 +ZETASQL_COMMIT = "a516c6b26d183efc4f56293256bba92e243b7a61" # 11/01/2024 http_archive( name = "com_google_zetasql", + patch_args = ["-p1"], + patches = ["//ml_metadata/third_party:zetasql.patch"], urls = ["https://github.com/google/zetasql/archive/%s.zip" % ZETASQL_COMMIT], strip_prefix = "zetasql-%s" % ZETASQL_COMMIT, - #patches = ["//ml_metadata/third_party:zetasql.patch"], - sha256 = '651a768cd51627f58aa6de7039aba9ddab22f4b0450521169800555269447840' + sha256 = '8db98b93bd6bb7348ed6d374f8eb6b602f7012bd5d368b3ffdee0a56c6c8d85f' ) load("@com_google_zetasql//bazel:zetasql_deps_step_1.bzl", "zetasql_deps_step_1") @@ -282,4 +283,4 @@ ml_metadata_workspace() # Specify the minimum required bazel version. load("@bazel_skylib//lib:versions.bzl", "versions") -versions.check("6.1.0") +versions.check("6.5.0") From 737d2b43d8e148667b09b136df9afac4d9fd6f27 Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:36:48 -0700 Subject: [PATCH 02/31] Create zetasql.patch --- ml_metadata/third_party/zetasql.patch | 674 ++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 ml_metadata/third_party/zetasql.patch diff --git a/ml_metadata/third_party/zetasql.patch b/ml_metadata/third_party/zetasql.patch new file mode 100644 index 000000000..c90d3b212 --- /dev/null +++ b/ml_metadata/third_party/zetasql.patch @@ -0,0 +1,674 @@ +diff --git a/zetasql/analyzer/BUILD b/zetasql/analyzer/BUILD +index 590f1be1..3ca15df4 100644 +--- a/zetasql/analyzer/BUILD ++++ b/zetasql/analyzer/BUILD +@@ -18,7 +18,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + load(":builddefs.bzl", "gen_analyzer_test") + + package( +- default_visibility = ["//zetasql/base:zetasql_implementation"], ++ default_visibility = ["//visibility:public"], + ) + + filegroup( +diff --git a/zetasql/analyzer/expr_resolver_helper.cc b/zetasql/analyzer/expr_resolver_helper.cc +index 93c3654d..8fb2256e 100644 +--- a/zetasql/analyzer/expr_resolver_helper.cc ++++ b/zetasql/analyzer/expr_resolver_helper.cc +@@ -357,7 +357,8 @@ ExprResolutionInfo::ExprResolutionInfo( + : ExprResolutionInfo( + query_resolution_info_in, name_scope_in, aggregate_name_scope_in, + analytic_name_scope_in, +- {.allows_aggregation = allows_aggregation_in, ++ ExprResolutionInfoOptions{ ++ .allows_aggregation = allows_aggregation_in, + .allows_analytic = allows_analytic_in, + .use_post_grouping_columns = use_post_grouping_columns_in, + .clause_name = clause_name_in, +diff --git a/zetasql/analyzer/name_scope.cc b/zetasql/analyzer/name_scope.cc +index b9a3176f..c1cf274a 100644 +--- a/zetasql/analyzer/name_scope.cc ++++ b/zetasql/analyzer/name_scope.cc +@@ -1549,7 +1549,7 @@ NameList::AddRangeVariableInWrappingNameList( + // variables, including for value tables, so we use `flatten_to_table` + // which drops range variables. + ZETASQL_RETURN_IF_ERROR(range_variable_name_list->MergeFrom( +- *original_name_list, ast_location, {.flatten_to_table = true})); ++ *original_name_list, ast_location, MergeOptions{.flatten_to_table = true})); + + auto wrapper_name_list = std::make_shared(); + ZETASQL_RETURN_IF_ERROR( +# diff --git a/bazel/zetasql_deps_step_2.bzl b/bazel/zetasql_deps_step_2.bzl +# index 6873dbe9..872ffd5e 100644 +# --- a/bazel/zetasql_deps_step_2.bzl +# +++ b/bazel/zetasql_deps_step_2.bzl +# @@ -477,7 +477,6 @@ alias( +# flex_register_toolchains(version = "2.6.4") +# bison_register_toolchains(version = "3.3.2") +# go_rules_dependencies() +# - go_register_toolchains(version = "1.21.6") +# gazelle_dependencies() +# textmapper_dependencies() + +diff --git a/zetasql/analyzer/resolver_expr.cc b/zetasql/analyzer/resolver_expr.cc +index 6116b4f7..70e8c9fd 100644 +--- a/zetasql/analyzer/resolver_expr.cc ++++ b/zetasql/analyzer/resolver_expr.cc +@@ -5586,7 +5586,8 @@ absl::Status Resolver::ResolveAnalyticFunctionCall( + { + ExprResolutionInfo analytic_arg_resolution_info( + expr_resolution_info, +- {.name_scope = expr_resolution_info->analytic_name_scope, ++ ExprResolutionInfoOptions{ ++ .name_scope = expr_resolution_info->analytic_name_scope, + .allows_analytic = expr_resolution_info->allows_analytic, + .clause_name = expr_resolution_info->clause_name}); + ZETASQL_RETURN_IF_ERROR(ResolveExpressionArguments( + +diff --git a/zetasql/base/BUILD b/zetasql/base/BUILD +index aa1f00da..7d4c3b3a 100644 +--- a/zetasql/base/BUILD ++++ b/zetasql/base/BUILD +@@ -15,7 +15,7 @@ + + licenses(["notice"]) + +-package(default_visibility = [":zetasql_implementation"]) ++package(default_visibility = ["//visibility:public"]) + + package_group( + name = "zetasql_implementation", +diff --git a/zetasql/base/testing/BUILD b/zetasql/base/testing/BUILD +index 10596497..239c670f 100644 +--- a/zetasql/base/testing/BUILD ++++ b/zetasql/base/testing/BUILD +@@ -16,7 +16,7 @@ + + licenses(["notice"]) + +-package(default_visibility = ["//zetasql/base:zetasql_implementation"]) ++package(default_visibility = ["//visibility:public"]) + + # A drop in replacement for gtest_main that parsers absl flags + cc_library( +diff --git a/zetasql/common/BUILD b/zetasql/common/BUILD +index cdafb15e..761e13cd 100644 +--- a/zetasql/common/BUILD ++++ b/zetasql/common/BUILD +@@ -14,7 +14,7 @@ + # limitations under the License. + + package( +- default_visibility = ["//zetasql/base:zetasql_implementation"], ++ default_visibility = ["//visibility:public"], + features = ["parse_headers"], + ) + +diff --git a/zetasql/common/internal_value.h b/zetasql/common/internal_value.h +index 770333d2..617ef628 100644 +--- a/zetasql/common/internal_value.h ++++ b/zetasql/common/internal_value.h +@@ -116,7 +116,7 @@ class InternalValue { + static std::string FormatInternal(const Value& x, + bool include_array_ordereness + ) { +- return x.FormatInternal({ ++ return x.FormatInternal(Type::FormatValueContentOptions{ + .force_type_at_top_level = true, + .include_array_ordereness = include_array_ordereness, + .indent = 0, +diff --git a/zetasql/parser/BUILD b/zetasql/parser/BUILD +index 433cf157..4fa4417c 100644 +--- a/zetasql/parser/BUILD ++++ b/zetasql/parser/BUILD +@@ -26,7 +26,7 @@ load("//bazel:textmapper.bzl", "tm_syntax") + load(":builddefs.bzl", "gen_parser_test") + + package( +- default_visibility = ["//zetasql/base:zetasql_implementation"], ++ default_visibility = ["//visibility:public"], + ) + + genrule( +diff --git a/zetasql/public/types/BUILD b/zetasql/public/types/BUILD +index 2b42fdcb..19ff2a4e 100644 +--- a/zetasql/public/types/BUILD ++++ b/zetasql/public/types/BUILD +@@ -14,7 +14,7 @@ + # limitations under the License. + # + +-package(default_visibility = ["//zetasql/base:zetasql_implementation"]) ++package(default_visibility = ["//visibility:public"]) + + cc_library( + name = "types", + +diff --git a/zetasql/public/value.cc b/zetasql/public/value.cc +index 7aeffb01..c9f9f9dc 100644 +--- a/zetasql/public/value.cc ++++ b/zetasql/public/value.cc +@@ -1067,7 +1067,7 @@ std::string Value::DebugString(bool verbose) const { + + // Format will wrap arrays and structs. + std::string Value::Format(bool print_top_level_type) const { +- return FormatInternal( ++ return FormatInternal(Type::FormatValueContentOptions + {.force_type_at_top_level = print_top_level_type, .indent = 0}); + } + +@@ -1335,7 +1335,7 @@ std::string Value::FormatInternal( + std::vector element_strings(elements().size()); + for (int i = 0; i < elements().size(); ++i) { + element_strings[i] = +- elements()[i].FormatInternal(options.IncreaseIndent()); ++ elements()[i].FormatInternal(Type::FormatValueContentOptions{options.IncreaseIndent()}); + } + // Sanitize any '$' characters before creating substitution template. "$$" + // is replaced by "$" in the output from absl::Substitute. +@@ -1377,7 +1377,7 @@ std::string Value::FormatInternal( + const StructType* struct_type = type()->AsStruct(); + std::vector field_strings(struct_type->num_fields()); + for (int i = 0; i < struct_type->num_fields(); i++) { +- field_strings[i] = fields()[i].FormatInternal(options.IncreaseIndent()); ++ field_strings[i] = fields()[i].FormatInternal(Type::FormatValueContentOptions{options.IncreaseIndent()}); + } + // Sanitize any '$' characters before creating substitution template. "$$" + // is replaced by "$" in the output from absl::Substitute. +@@ -1423,9 +1423,9 @@ std::string Value::FormatInternal( + } + std::vector boundaries_strings; + boundaries_strings.push_back( +- start().FormatInternal(options.IncreaseIndent())); ++ start().FormatInternal(Type::FormatValueContentOptions{options.IncreaseIndent()})); + boundaries_strings.push_back( +- end().FormatInternal(options.IncreaseIndent())); ++ end().FormatInternal(Type::FormatValueContentOptions{options.IncreaseIndent()})); + // Sanitize any '$' characters before creating substitution template. "$$" + // is replaced by "$" in the output from absl::Substitute. + std::string templ = +diff --git a/zetasql/reference_impl/algebrizer.cc b/zetasql/reference_impl/algebrizer.cc +index 2e1258ab..48a3d7f4 100644 +--- a/zetasql/reference_impl/algebrizer.cc ++++ b/zetasql/reference_impl/algebrizer.cc +@@ -6738,7 +6738,7 @@ absl::StatusOr> Algebrizer::AlgebrizeTvfScan( + ZETASQL_RET_CHECK(tvf_scan->signature()->argument(i).is_scalar()); + ZETASQL_ASSIGN_OR_RETURN(auto expr_argument, + AlgebrizeExpression(argument->expr())); +- arguments.push_back({.value = std::move(expr_argument)}); ++ arguments.push_back(TVFOp::TVFOpArgument{.value = std::move(expr_argument)}); + continue; + } + +@@ -6767,14 +6767,14 @@ absl::StatusOr> Algebrizer::AlgebrizeTvfScan( + columns.push_back({relation_signature_column.name, + argument_column.type(), input_variable}); + } +- arguments.push_back({.relation = TVFOp::TvfInputRelation{ ++ arguments.push_back(TVFOp::TVFOpArgument{.relation = TVFOp::TvfInputRelation{ + std::move(relation), std::move(columns)}}); + continue; + } + + if (argument->model() != nullptr) { + ZETASQL_RET_CHECK(tvf_scan->signature()->argument(i).is_model()); +- arguments.push_back({.model = argument->model()->model()}); ++ arguments.push_back(TVFOp::TVFOpArgument{.model = argument->model()->model()}); + continue; + } + +diff --git a/zetasql/reference_impl/relational_op.cc b/zetasql/reference_impl/relational_op.cc +index 1619590a..a18a733f 100644 +--- a/zetasql/reference_impl/relational_op.cc ++++ b/zetasql/reference_impl/relational_op.cc +@@ -835,11 +835,11 @@ absl::StatusOr> TVFOp::CreateIterator( + } + ZETASQL_RET_CHECK_EQ(columns.size(), tuple_indexes.size()); + input_arguments.push_back( +- {.relation = {std::make_unique( ++ TableValuedFunction::TvfEvaluatorArg{.relation = {std::make_unique( + std::move(columns), std::move(tuple_indexes), context, + std::move(tuple_iterator))}}); + } else if (argument.model) { +- input_arguments.push_back({.model = argument.model}); ++ input_arguments.push_back(TableValuedFunction::TvfEvaluatorArg{.model = argument.model}); + } else { + ZETASQL_RET_CHECK_FAIL() << "Unexpected TVFOpArgument"; + } + +diff --git a/bazel/zetasql_deps_step_2.bzl b/bazel/zetasql_deps_step_2.bzl +index 6873dbe9..223f8dbd 100644 +--- a/bazel/zetasql_deps_step_2.bzl ++++ b/bazel/zetasql_deps_step_2.bzl +@@ -19,7 +19,6 @@ + load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +-load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") + load("@rules_bison//bison:bison.bzl", "bison_register_toolchains") + load("@rules_flex//flex:flex.bzl", "flex_register_toolchains") + load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +@@ -29,7 +28,6 @@ load("@rules_proto//proto:setup.bzl", "rules_proto_setup") + load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") + + def _load_deps_from_step_1(): +- llvm_register_toolchains() + rules_foreign_cc_dependencies() + + def textmapper_dependencies(): +@@ -49,21 +47,29 @@ def textmapper_dependencies(): + go_repository( + name = "dev_lsp_go_jsonrpc2", + importpath = "go.lsp.dev/jsonrpc2", ++ remote = "https://github.com/go-language-server/jsonrpc2", ++ vcs = "git", + commit = "8c68d4fd37cd4bd06b62b3243f0d2292c681d164", + ) + go_repository( + name = "dev_lsp_go_protocol", + importpath = "go.lsp.dev/protocol", ++ remote = "https://github.com/go-language-server/protocol", ++ vcs = "git", + commit = "da30f9ae0326cc45b76adc5cd8920ac1ffa14a15", + ) + go_repository( + name = "dev_lsp_go_uri", + importpath = "go.lsp.dev/uri", ++ remote = "https://github.com/go-language-server/uri", ++ vcs = "git", + commit = "63eaac75cc850f596be19073ff6d4ec198603779", + ) + go_repository( + name = "dev_lsp_go_pkg", + importpath = "go.lsp.dev/pkg", ++ remote = "https://github.com/go-language-server/pkg", ++ vcs = "git", + commit = "384b27a52fb2b5d74d78cfe89c7738e9a3e216a5", + ) + go_repository( +@@ -477,7 +483,6 @@ alias( + flex_register_toolchains(version = "2.6.4") + bison_register_toolchains(version = "3.3.2") + go_rules_dependencies() +- go_register_toolchains(version = "1.21.6") + gazelle_dependencies() + textmapper_dependencies() + + +diff --git a/bazel/zetasql_deps_step_1.bzl b/bazel/zetasql_deps_step_1.bzl +index 825bf8ea..7edd1352 100644 +--- a/bazel/zetasql_deps_step_1.bzl ++++ b/bazel/zetasql_deps_step_1.bzl +@@ -22,25 +22,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + # but depend on them being something different. So we have to override them both + # by defining the repo first. + load("@com_google_zetasql//bazel:zetasql_bazel_version.bzl", "zetasql_bazel_version") +-load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") +-load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") + + def zetasql_deps_step_1(add_bazel_version = True): + if add_bazel_version: + zetasql_bazel_version() + +- bazel_toolchain_dependencies() +- llvm_toolchain( +- name = "llvm_toolchain", +- llvm_versions = { +- "": "16.0.0", +- # The LLVM repo stops providing pre-built binaries for the MacOS x86_64 +- # architecture for versions >= 16.0.0: https://github.com/llvm/llvm-project/releases, +- # but our Kokoro MacOS tests are still using x86_64 (ventura). +- # TODO: Upgrade the MacOS version to sonoma-slcn. +- "darwin-x86_64": "15.0.7", +- }, +- ) + + http_archive( + name = "io_bazel_rules_go", + +diff --git a/bazel/grpc_extra_deps.patch b/bazel/grpc_extra_deps.patch +index 771761b3..9c1b1cee 100644 +--- a/bazel/grpc_extra_deps.patch ++++ b/bazel/grpc_extra_deps.patch +@@ -13,3 +13,41 @@ index 4d8afa3131..b42224501f 100644 + # Pull-in the go 3rd party dependencies for protoc_gen_validate, which is + # needed for building C++ xDS protos + go_third_party() ++ ++ diff --git a/BUILD b/BUILD ++ index 3b5d7e5e3c..c5d61e6e4c 100644 ++ --- a/BUILD ++ +++ b/BUILD ++ @@ -544,6 +544,7 @@ grpc_cc_library( ++ defines = ["GRPC_NO_XDS"], ++ external_deps = [ ++ "absl/base:core_headers", ++ + "absl/status", ++ + "absl/strings", ++ ], ++ language = "c++", ++ public_hdrs = GRPC_PUBLIC_HDRS, ++ ++ diff --git a/include/grpcpp/impl/status.h b/include/grpcpp/impl/status.h ++ index 95436ab8fb..fe9f44adf0 100644 ++ --- a/include/grpcpp/impl/status.h ++ +++ b/include/grpcpp/impl/status.h ++ @@ -23,6 +23,7 @@ ++ ++ #include ++ ++ +#include "absl/status/status.h" ++ #include ++ #include ++ #include ++ @@ -99,6 +100,10 @@ class GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING Status { ++ Status(StatusCode code, const std::string& error_message) ++ : code_(code), error_message_(error_message) {} ++ ++ + operator absl::Status() const& { ++ + return absl::Status(static_cast(code_), error_message_); ++ + } ++ + ++ /// Construct an instance with \a code, \a error_message and ++ /// \a error_details. It is an error to construct an OK status with non-empty ++ /// \a error_message and/or \a error_details. ++ + +diff --git a/bazel/icu4c-64_2.patch b/bazel/icu4c-64_2.patch +index 69d12b63..a23bdcaf 100644 +--- a/bazel/icu4c-64_2.patch ++++ b/bazel/icu4c-64_2.patch +@@ -5,7 +5,7 @@ + CXX = @CXX@ + AR = @AR@ + -ARFLAGS = @ARFLAGS@ r +-+ARFLAGS = @ARFLAGS@ -crs +++ARFLAGS = @ARFLAGS@ + RANLIB = @RANLIB@ + COMPILE_LINK_ENVVAR = @COMPILE_LINK_ENVVAR@ + UCLN_NO_AUTO_CLEANUP = @UCLN_NO_AUTO_CLEANUP@ + + diff --git a/bazel/icu.BUILD b/bazel/icu.BUILD +index be36d7de..f61d8f3c 100644 +--- a/bazel/icu.BUILD ++++ b/bazel/icu.BUILD +@@ -35,20 +35,17 @@ filegroup( + configure_make( + name = "icu", + configure_command = "source/configure", +- args = select({ +- # AR is overridden to be libtool by rules_foreign_cc. It does not support ar style arguments +- # like "r". We need to prevent the icu make rules from adding unsupported parameters by +- # forcing ARFLAGS to keep the rules_foreign_cc value in this parameter +- "@platforms//os:macos": [ +- "ARFLAGS=\"-static -o\"", +- "MAKE=gnumake", +- ], +- "//conditions:default": [], +- }), +- env = { +- "CXXFLAGS": "-fPIC", # For JNI +- "CFLAGS": "-fPIC", # For JNI +- }, ++ env = select({ ++ "@platforms//os:macos": { ++ "AR": "", ++ "CXXFLAGS": "-fPIC", # For JNI ++ "CFLAGS": "-fPIC", # For JNI ++ }, ++ "//conditions:default": { ++ "CXXFLAGS": "-fPIC", # For JNI ++ "CFLAGS": "-fPIC", # For JNI ++ }, ++ }), + configure_options = [ + "--enable-option-checking", + "--enable-static", + + +diff --git a/zetasql/public/constant.h b/zetasql/public/constant.h +index 946183b0..03ac17e0 100644 +--- a/zetasql/public/constant.h ++++ b/zetasql/public/constant.h +@@ -80,7 +80,7 @@ class Constant { + const std::vector& name_path() const { return name_path_; } + + // Returns the type of this Constant. +- virtual const Type* type() const = 0; ++ virtual const zetasql::Type* type() const = 0; + + // Returns whether or not this Constant is a specific constant interface or + // implementation. + +diff --git a/zetasql/public/property_graph.h b/zetasql/public/property_graph.h +index 53ccca23..0eefe780 100644 +--- a/zetasql/public/property_graph.h ++++ b/zetasql/public/property_graph.h +@@ -348,7 +348,7 @@ class GraphPropertyDeclaration { + return ::zetasql::FullName(PropertyGraphNamePath(), Name()); + } + +- virtual const Type* Type() const = 0; ++ virtual const zetasql::Type* Type() const = 0; + + // Returns whether or not this GraphPropertyDeclaration is a specific + // interface or implementation. + +diff --git a/zetasql/analyzer/resolver_expr.cc b/zetasql/analyzer/resolver_expr.cc +index 51d095ab..8ba1eefc 100644 +--- a/zetasql/analyzer/resolver_expr.cc ++++ b/zetasql/analyzer/resolver_expr.cc +@@ -2996,7 +2996,7 @@ class SystemVariableConstant final : public Constant { + const Type* type) + : Constant(name_path), type_(type) {} + +- const Type* type() const override { return type_; } ++ const zetasql::Type* type() const override { return type_; } + std::string DebugString() const override { return FullName(); } + std::string ConstantValueDebugString() const override { return ""; } + + +diff --git a/zetasql/public/coercer.cc b/zetasql/public/coercer.cc +index dc4961dd..80d26183 100644 +--- a/zetasql/public/coercer.cc ++++ b/zetasql/public/coercer.cc +@@ -154,7 +154,7 @@ class TypeSuperTypes { + return false; + } + +- const Type* type() const { return type_; } ++ const zetasql::Type* type() const { return type_; } + TypeListView supertypes() const { return supertypes_; } + + std::vector ToVector() const { + +diff --git a/zetasql/public/function_signature.h b/zetasql/public/function_signature.h +index 29886cc2..5436071c 100644 +--- a/zetasql/public/function_signature.h ++++ b/zetasql/public/function_signature.h +@@ -702,7 +702,7 @@ class FunctionArgumentType { + // Returns NULL if kind_ is not ARG_TYPE_FIXED or ARG_TYPE_LAMBDA. If kind_ is + // ARG_TYPE_LAMBDA, returns the type of lambda body type, which could be NULL + // if the body type is templated. +- const Type* type() const { return type_; } ++ const zetasql::Type* type() const { return type_; } + + SignatureArgumentKind kind() const { return kind_; } + +diff --git a/zetasql/public/input_argument_type.h b/zetasql/public/input_argument_type.h +index f2098787..55b416e3 100644 +--- a/zetasql/public/input_argument_type.h ++++ b/zetasql/public/input_argument_type.h +@@ -81,7 +81,7 @@ class InputArgumentType { + ~InputArgumentType() {} + + // This may return nullptr (such as for lambda). +- const Type* type() const { return type_; } ++ const zetasql::Type* type() const { return type_; } + + const std::vector& field_types() const { + return field_types_; + +diff --git a/zetasql/public/simple_catalog.h b/zetasql/public/simple_catalog.h +index 76a94d43..a0d81b9d 100644 +--- a/zetasql/public/simple_catalog.h ++++ b/zetasql/public/simple_catalog.h +@@ -1202,7 +1202,7 @@ class SimpleConstant : public Constant { + const SimpleConstantProto& simple_constant_proto, + const TypeDeserializer& type_deserializer); + +- const Type* type() const override { return value_.type(); } ++ const zetasql::Type* type() const override { return value_.type(); } + + const Value& value() const { return value_; } + + +diff --git a/zetasql/public/sql_constant.h b/zetasql/public/sql_constant.h +index fa88344f..69defd3b 100644 +--- a/zetasql/public/sql_constant.h ++++ b/zetasql/public/sql_constant.h +@@ -60,7 +60,7 @@ class SQLConstant : public Constant { + + // Returns the Type of the resolved Constant based on its resolved + // expression type. +- const Type* type() const override { ++ const zetasql::Type* type() const override { + return constant_expression()->type(); + } + + +diff --git a/zetasql/public/value.h b/zetasql/public/value.h +index 49b60aec..86688538 100644 +--- a/zetasql/public/value.h ++++ b/zetasql/public/value.h +@@ -122,7 +122,7 @@ class Value { + ~Value(); + + // Returns the type of the value. +- const Type* type() const; ++ const zetasql::Type* type() const; + + // Returns the type kind of the value. Same as type()->type_kind() but in some + // cases can be a bit more efficient. +@@ -1152,7 +1152,7 @@ class Value { + + // Returns a pointer to Value's Type. Requires is_valid(). If TypeKind is + // stored in the Metadata, Type pointer is obtained from static TypeFactory. +- const Type* type() const; ++ const zetasql::Type* type() const; + + // Returns true, if instance stores pointer to a Type and false if type's + // kind. + +diff --git a/zetasql/public/value_inl.h b/zetasql/public/value_inl.h +index e917a97a..f324276f 100644 +--- a/zetasql/public/value_inl.h ++++ b/zetasql/public/value_inl.h +@@ -1077,7 +1077,7 @@ class Value::Metadata::ContentLayout<4> { + has_type_(false), + value_extended_content_(value_extended_content) {} + +- const Type* type() const { return type_; } ++ const zetasql::Type* type() const { return type_; } + int32_t value_extended_content() const { return value_extended_content_; } + bool is_null() const { return is_null_; } + bool preserves_order() const { return preserves_order_; } +@@ -1157,7 +1157,7 @@ class Value::Metadata::ContentLayout<8> { + // TODO: wait for fixed clang-format + // clang-format on + +- const Type* type() const { ++ const zetasql::Type* type() const { + return reinterpret_cast(type_ & kTypeMask); + } + int32_t value_extended_content() const { return value_extended_content_; } + +diff --git a/zetasql/reference_impl/operator.h b/zetasql/reference_impl/operator.h +index 24f0ddac..7adb701d 100644 +--- a/zetasql/reference_impl/operator.h ++++ b/zetasql/reference_impl/operator.h +@@ -240,7 +240,7 @@ class ExprArg : public AlgebraArg { + + ~ExprArg() override = default; + +- const Type* type() const { return type_; } ++ const zetasql::Type* type() const { return type_; } + + private: + const Type* type_; + +diff --git a/zetasql/resolved_ast/resolved_column.h b/zetasql/resolved_ast/resolved_column.h +index 912b3ca4..2e613f2a 100644 +--- a/zetasql/resolved_ast/resolved_column.h ++++ b/zetasql/resolved_ast/resolved_column.h +@@ -119,7 +119,7 @@ class ResolvedColumn { + IdString table_name_id() const { return table_name_; } + IdString name_id() const { return name_; } + +- const Type* type() const { return annotated_type_.type; } ++ const zetasql::Type* type() const { return annotated_type_.type; } + + const AnnotationMap* type_annotation_map() const { + return annotated_type_.annotation_map; + +diff --git a/zetasql/testing/test_value.h b/zetasql/testing/test_value.h +index 0412873e..d2d8c3e8 100644 +--- a/zetasql/testing/test_value.h ++++ b/zetasql/testing/test_value.h +@@ -106,7 +106,7 @@ class ValueConstructor { + : v_(v) {} + + const Value& get() const { return v_; } +- const Type* type() const { return v_.type(); } ++ const zetasql::Type* type() const { return v_.type(); } + + static std::vector ToValues(absl::Span slice) { + std::vector values; + + +diff --git a/zetasql/base/logging.h b/zetasql/base/logging.h +index 730ccdcb..46fe06b0 100644 +--- a/zetasql/base/logging.h ++++ b/zetasql/base/logging.h +@@ -59,6 +59,17 @@ inline void ZetaSqlMakeCheckOpValueString(std::ostream *os, const T &v) { + (*os) << v; + } + ++// This overloading is implemented to address the compilation issue when trying to log unique_ptr types ++// At the moment, we are not providing any specific implementation for handling unique_ptr types. ++template ++inline void ZetaSqlMakeCheckOpValueString(std::ostream* os, const std::unique_ptr& v) { ++ if (v == nullptr) { ++ (*os) << "nullptr"; ++ } else { ++ (*os) << v.get(); ++ } ++} ++ + // Overrides for char types provide readable values for unprintable + // characters. + template <> + + + +diff --git a/zetasql/base/testing/BUILD b/zetasql/base/testing/BUILD +index 10596497..a9b69be7 100644 +--- a/zetasql/base/testing/BUILD ++++ b/zetasql/base/testing/BUILD +@@ -55,6 +55,7 @@ cc_library( + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_googletest//:gtest", ++ "@com_github_grpc_grpc//:grpc++", + ], + ) + +@@ -69,6 +70,7 @@ cc_test( + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_googletest//:gtest", ++ "@com_github_grpc_grpc//:grpc++", + ], + ) + + From 22c26b2774e5d9c510143400621573b4fc116403 Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:39:02 -0700 Subject: [PATCH 03/31] Update .bazelversion --- ml_metadata/.bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/.bazelversion b/ml_metadata/.bazelversion index 44f2af0f6..f92706dd9 100644 --- a/ml_metadata/.bazelversion +++ b/ml_metadata/.bazelversion @@ -11,4 +11,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -6.1.0 +6.5.0 From bd77112280be48d76ffdc2a0f0a202ab06e1307b Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:39:32 -0700 Subject: [PATCH 04/31] Update Dockerfile --- ml_metadata/tools/dev_debug/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/tools/dev_debug/Dockerfile b/ml_metadata/tools/dev_debug/Dockerfile index df06eaa75..e75fd3346 100644 --- a/ml_metadata/tools/dev_debug/Dockerfile +++ b/ml_metadata/tools/dev_debug/Dockerfile @@ -34,7 +34,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python-is-python3 \ python3-dev -# Set up Bazel 6.1.0 +# Set up Bazel 6.5.0 ENV BAZEL_VERSION 6.1.0 WORKDIR / RUN mkdir /bazel && \ From 80090777596fb9c3fd40e3645e11d069d38872bb Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:39:53 -0700 Subject: [PATCH 05/31] Update Dockerfile.manylinux2010 --- ml_metadata/tools/docker_build/Dockerfile.manylinux2010 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/tools/docker_build/Dockerfile.manylinux2010 b/ml_metadata/tools/docker_build/Dockerfile.manylinux2010 index 77a5174cb..5c2ca1673 100644 --- a/ml_metadata/tools/docker_build/Dockerfile.manylinux2010 +++ b/ml_metadata/tools/docker_build/Dockerfile.manylinux2010 @@ -15,6 +15,6 @@ # Dockerfile for building a manylinux2010 MLMD wheel. # This docker image is essentially pypa/manylinux2010 + bazel. -FROM gcr.io/tfx-oss-public/manylinux2014-bazel:bazel-6.1.0 +FROM gcr.io/tfx-oss-public/manylinux2014-bazel:bazel-6.5.0 WORKDIR /build CMD ["ml_metadata/tools/docker_build/build_manylinux.sh"] From 733cbad66edef60b3d803ca65451a6f319409748 Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:40:26 -0700 Subject: [PATCH 06/31] Update Dockerfile --- ml_metadata/tools/docker_server/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ml_metadata/tools/docker_server/Dockerfile b/ml_metadata/tools/docker_server/Dockerfile index 7fefdb74b..b90bb6157 100644 --- a/ml_metadata/tools/docker_server/Dockerfile +++ b/ml_metadata/tools/docker_server/Dockerfile @@ -35,8 +35,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python-is-python3 \ python3-dev -# Set up Bazel 6.1.0 -ENV BAZEL_VERSION 6.1.0 +# Set up Bazel 6.5.0 +ENV BAZEL_VERSION 6.5.0 WORKDIR / RUN mkdir /bazel && \ cd /bazel && \ From c21a60f6d018ab154b7521f5bafe28c167240fcb Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:47:36 -0700 Subject: [PATCH 07/31] Update Dockerfile --- ml_metadata/tools/dev_debug/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/tools/dev_debug/Dockerfile b/ml_metadata/tools/dev_debug/Dockerfile index e75fd3346..925779bc9 100644 --- a/ml_metadata/tools/dev_debug/Dockerfile +++ b/ml_metadata/tools/dev_debug/Dockerfile @@ -35,7 +35,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-dev # Set up Bazel 6.5.0 -ENV BAZEL_VERSION 6.1.0 +ENV BAZEL_VERSION 6.5.0 WORKDIR / RUN mkdir /bazel && \ cd /bazel && \ From 82209bd94a70dfb9b24461e14c74f43f2f3ccebb Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 09:48:15 -0700 Subject: [PATCH 08/31] Update Dockerfile --- ml_metadata/tools/docker_server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/tools/docker_server/Dockerfile b/ml_metadata/tools/docker_server/Dockerfile index b90bb6157..a65754cd3 100644 --- a/ml_metadata/tools/docker_server/Dockerfile +++ b/ml_metadata/tools/docker_server/Dockerfile @@ -14,7 +14,7 @@ # TODO(b/195701120) Introduces l.gcr.io/google/bazel:5.3.0 when it is available # and makes sure that it uses ubuntu 20.04 as base image. Currently the lastest -# version only supports bazel 6.1.0. +# version only supports bazel 6.5.0. FROM ubuntu:20.04 as builder RUN export DEBIAN_FRONTEND=noninteractive && \ From 4fb4648ae7be9e376d59791f581baa4816d56a4a Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:02:39 -0700 Subject: [PATCH 09/31] Update BUILD --- ml_metadata/third_party/BUILD | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ml_metadata/third_party/BUILD b/ml_metadata/third_party/BUILD index 5b01f6e3e..05440e823 100644 --- a/ml_metadata/third_party/BUILD +++ b/ml_metadata/third_party/BUILD @@ -1 +1,7 @@ licenses(["notice"]) + +filegroup( + name = "zetasql_patch", + srcs = ["zetasql.patch"], + visibility = ["//visibility:public"], +) From 50860de5d77d53c250731b12eda457b3c240333f Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:24:55 -0700 Subject: [PATCH 10/31] Update WORKSPACE --- WORKSPACE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index d519ba772..0f3776bc2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -48,6 +48,25 @@ http_archive( sha256 = "0e800799aa64d0b4d354f3ff317bbd5fbf42f3a522ab0456bb749fc8d3b67415", ) +http_archive( + name = "rules_proto", + sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295", + strip_prefix = "rules_proto-6.0.2", + url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz", +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") + +rules_proto_dependencies() + +load("@rules_proto//proto:setup.bzl", "rules_proto_setup") + +rules_proto_setup() + +load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") + +rules_proto_toolchains() + http_archive( name = "boringssl", sha256 = "1188e29000013ed6517168600fc35a010d58c5d321846d6a6dfee74e4c788b45", From abb069f0f02e1a908af8934a9aa6e160a30b5e64 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 1 Jul 2025 20:09:48 +0000 Subject: [PATCH 11/31] chnages --- BUILD.bazel | 7 + WORKSPACE | 42 +- ml_metadata/BUILD | 7 +- ml_metadata/metadata_store/BUILD | 25 +- ml_metadata/ml_metadata.bzl | 101 +--- ml_metadata/proto/BUILD | 13 +- ml_metadata/query/BUILD | 9 +- ml_metadata/simple_types/proto/BUILD | 5 +- .../third_party/local_python.BUILD.tpl | 65 +++ ml_metadata/third_party/pybind11.BUILD | 37 ++ ml_metadata/third_party/python_configure.bzl | 488 ++++++++++++++++++ 11 files changed, 672 insertions(+), 127 deletions(-) create mode 100644 BUILD.bazel create mode 100644 ml_metadata/third_party/local_python.BUILD.tpl create mode 100644 ml_metadata/third_party/pybind11.BUILD create mode 100644 ml_metadata/third_party/python_configure.bzl diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 000000000..77ba671bd --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,7 @@ +package( + default_visibility = ["//visibility:public"], +) + +licenses(["notice"]) + +exports_files(["LICENSE"]) diff --git a/WORKSPACE b/WORKSPACE index 0f3776bc2..d1db4ffcd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -43,9 +43,9 @@ rules_foreign_cc_dependencies() http_archive( name = "com_google_absl", - urls = ["https://github.com/abseil/abseil-cpp/archive/940c06c25d2953f44310b68eb8aab6114dba11fb.zip"], - strip_prefix = "abseil-cpp-940c06c25d2953f44310b68eb8aab6114dba11fb", - sha256 = "0e800799aa64d0b4d354f3ff317bbd5fbf42f3a522ab0456bb749fc8d3b67415", + sha256 = "df8b3e0da03567badd9440377810c39a38ab3346fa89df077bb52e68e4d61e74", + strip_prefix = "abseil-cpp-4447c7562e3bc702ade25105912dce503f0c4010", + url = "https://github.com/abseil/abseil-cpp/archive/4447c7562e3bc702ade25105912dce503f0c4010.tar.gz", ) http_archive( @@ -154,21 +154,15 @@ http_archive( http_archive( name = "pybind11", - urls = [ - "https://github.com/pybind/pybind11/archive/v2.10.1.tar.gz", - ], - strip_prefix = "pybind11-2.10.1", - build_file = "@pybind11_bazel//:pybind11.BUILD", + build_file = "//ml_metadata/third_party:pybind11.BUILD", + sha256 = "8f4b7f28d214e36301435c055076c36186388dc9617117802cba8a059347cb00", + strip_prefix = "pybind11-8a099e44b3d5f85b20f05828d919d2332a8de841", + urls = ["https://github.com/pybind/pybind11/archive/8a099e44b3d5f85b20f05828d919d2332a8de841.zip"], ) -load("@pybind11_bazel//:python_configure.bzl", "python_configure") -python_configure(name = "local_config_python") +load("//ml_metadata/third_party:python_configure.bzl", "local_python_configure") -# Needed by @com_google_protobuf. -bind( - name = "python_headers", - actual = "@local_config_python//:python_headers", -) +local_python_configure(name = "local_config_python") # Note - use @com_github_google_re2 instead of more canonical # @com_google_re2 for consistency with dependency grpc @@ -251,6 +245,24 @@ go_repository( tag = "v0.2.0", ) +go_repository( + name = "com_github_golang_protobuf", + importpath = "github.com/golang/protobuf", + tag = "v1.3.2", +) + +go_repository( + name = "org_golang_google_protobuf", + importpath = "google.golang.org/protobuf", + tag = "v1.25.0", +) + +go_repository( + name = "org_golang_x_net", + importpath = "golang.org/x/net", + commit = "b3afb19ee333d5231c1034d3ac2a5313cde533a3", +) + go_rules_dependencies() go_register_toolchains() diff --git a/ml_metadata/BUILD b/ml_metadata/BUILD index c3ede2f05..4406fb8b5 100644 --- a/ml_metadata/BUILD +++ b/ml_metadata/BUILD @@ -29,10 +29,9 @@ selects.config_setting_group( ) _public_protos = [ - "//ml_metadata/simple_types/proto:simple_types_pb2.py", - "//ml_metadata/proto:metadata_store_pb2.py", - "//ml_metadata/proto:metadata_store_service_pb2.py", - "//ml_metadata/proto:metadata_store_service_pb2_grpc.py", + "//ml_metadata/simple_types/proto:simple_types_py_pb2", + "//ml_metadata/proto:metadata_store_py_pb2", + "//ml_metadata/proto:metadata_store_service_py_pb2", ] _py_extension = select({ diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index 84fdef837..6f563abb8 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -14,7 +14,6 @@ load( "//ml_metadata:ml_metadata.bzl", - "ml_metadata_cc_test", "ml_metadata_go_library", "ml_metadata_go_test", "ml_metadata_go_wrap_cc", @@ -119,7 +118,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "sqlite_rdbms_metadata_access_object_test", size = "small", srcs = ["sqlite_rdbms_metadata_access_object_test.cc"], @@ -188,7 +187,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "sqlite_query_config_executor_test", srcs = [ "sqlite_query_config_executor_test.cc", @@ -310,7 +309,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "list_operation_query_helper_test", size = "small", srcs = ["list_operation_query_helper_test.cc"], @@ -370,7 +369,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "metadata_source_test", size = "small", srcs = ["metadata_source_test.cc"], @@ -395,7 +394,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "transaction_executor_test", srcs = ["transaction_executor_test.cc"], deps = [ @@ -470,7 +469,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "metadata_store_cc_test", srcs = ["metadata_store_test.cc"], env = { @@ -547,7 +546,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "metadata_store_factory_test", srcs = ["metadata_store_factory_test.cc"], env = { @@ -595,7 +594,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "sqlite_metadata_source_test", size = "small", srcs = ["sqlite_metadata_source_test.cc"], @@ -635,7 +634,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "simple_types_util_test", srcs = ["simple_types_util_test.cc"], deps = [ @@ -646,7 +645,7 @@ ml_metadata_cc_test( ], ) -ml_metadata_cc_test( +cc_test( name = "test_util_test", srcs = ["test_util_test.cc"], deps = [ @@ -828,7 +827,7 @@ cc_test( ], ) -ml_metadata_cc_test( +cc_test( name = "sqlite_metadata_access_object_test", srcs = ["sqlite_metadata_access_object_test.cc"], deps = [ @@ -1034,7 +1033,7 @@ cc_library( deps = [":postgresql_metadata_source"], ) -ml_metadata_cc_test( +cc_test( name = "metadata_access_object_factory_test", srcs = ["metadata_access_object_factory_test.cc"], deps = [ diff --git a/ml_metadata/ml_metadata.bzl b/ml_metadata/ml_metadata.bzl index 8a6e685a6..97b6391ea 100644 --- a/ml_metadata/ml_metadata.bzl +++ b/ml_metadata/ml_metadata.bzl @@ -17,87 +17,40 @@ This module contains build rules for ml_metadata in OSS. load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library") - -def ml_metadata_cc_test( - name, - srcs = [], - deps = [], - env = {}, - tags = [], - args = [], - size = None, - data = None): - _ignore = [data] - native.cc_test( - name = name, - srcs = srcs, - deps = deps, - env = env, - tags = tags, - args = args, - size = size, - # cc_tests with ".so"s in srcs incorrectly link on Darwin unless - # linkstatic=1 (https://github.com/bazelbuild/bazel/issues/3450). - linkstatic = select({ - "//ml_metadata/metadata_store:darwin": 1, - "//conditions:default": 0, - }), - ) - -def ml_metadata_proto_library( - name, - srcs = [], - has_services = False, - deps = [], - visibility = None, - testonly = 0, - cc_grpc_version = None): - """Opensource cc_proto_library.""" - _ignore = [has_services] - native.filegroup( - name = name + "_proto_srcs", - srcs = srcs, - testonly = testonly, - ) - - use_grpc_plugin = None - if cc_grpc_version: - use_grpc_plugin = True - cc_proto_library( +load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +load("@rules_cc//cc:defs.bzl", "cc_proto_library") + +def ml_metadata_proto_library(name, srcs = [], deps = [], visibility = None, testonly = 0): + well_known_protos = [ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:wrappers_proto", + ] + native.proto_library( name = name, srcs = srcs, - deps = deps, - cc_libs = ["@com_google_protobuf//:protobuf"], - protoc = "@com_google_protobuf//:protoc", - default_runtime = "@com_google_protobuf//:protobuf", - use_grpc_plugin = use_grpc_plugin, - testonly = testonly, + deps = deps + well_known_protos, visibility = visibility, + testonly = testonly, ) - -def ml_metadata_proto_library_py( - name, - proto_library = None, - api_version = None, - srcs = [], - deps = [], - visibility = None, - testonly = 0, - oss_deps = [], - use_grpc_plugin = False): - """Opensource py_proto_library.""" - _ignore = [proto_library, api_version, oss_deps] + cc_proto_kwargs = { + "deps": [":" + name], + } + if visibility: + cc_proto_kwargs["visibility"] = visibility + if testonly: + cc_proto_kwargs["testonly"] = testonly + cc_proto_library(name = name + "_cc_pb2", **cc_proto_kwargs) + +def ml_metadata_proto_library_py(name, deps, visibility = None, testonly = 0): py_proto_library( name = name, - srcs = srcs, - srcs_version = "PY2AND3", - deps = ["@com_google_protobuf//:well_known_types_py_pb2"] + deps + oss_deps, - default_runtime = "@com_google_protobuf//:protobuf_python", - protoc = "@com_google_protobuf//:protoc", + deps = deps, visibility = visibility, testonly = testonly, - use_grpc_plugin = use_grpc_plugin, ) def ml_metadata_proto_library_go( @@ -254,7 +207,7 @@ def ml_metadata_pybind_extension( ], }), linkopts = select({ - "//ml_metadata:macos": [ + "@platforms//os:macos": [ # TODO: the -w suppresses a wall of harmless warnings about hidden typeinfo symbols # not being exported. There should be a better way to deal with this. "-Wl,-w", diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 6fc019a41..200f88316 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -21,31 +21,22 @@ licenses(["notice"]) ml_metadata_proto_library( name = "metadata_store_proto", srcs = ["metadata_store.proto"], - deps = ["@com_google_protobuf//:cc_wkt_protos"], ) ml_metadata_proto_library( name = "metadata_store_service_proto", srcs = ["metadata_store_service.proto"], - has_services = 1, - cc_grpc_version = 1, deps = [":metadata_store_proto"], ) ml_metadata_proto_library_py( name = "metadata_store_py_pb2", - srcs = ["metadata_store.proto"], - api_version = 2, - proto_library = "metadata_store_proto", + deps = [":metadata_store_proto"], ) ml_metadata_proto_library_py( name = "metadata_store_service_py_pb2", - srcs = ["metadata_store_service.proto"], - api_version = 2, - oss_deps = [":metadata_store_py_pb2"], - proto_library = "metadata_store_service_proto", - use_grpc_plugin = True, + deps = [":metadata_store_service_proto"], ) ml_metadata_proto_library_go( diff --git a/ml_metadata/query/BUILD b/ml_metadata/query/BUILD index 6c2f42c4b..355eee5e2 100644 --- a/ml_metadata/query/BUILD +++ b/ml_metadata/query/BUILD @@ -12,10 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load( - "//ml_metadata:ml_metadata.bzl", - "ml_metadata_cc_test", -) + licenses(["notice"]) @@ -37,7 +34,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "filter_query_ast_resolver_test", size = "small", srcs = ["filter_query_ast_resolver_test.cc"], @@ -67,7 +64,7 @@ cc_library( ], ) -ml_metadata_cc_test( +cc_test( name = "filter_query_builder_test", size = "small", srcs = ["filter_query_builder_test.cc"], diff --git a/ml_metadata/simple_types/proto/BUILD b/ml_metadata/simple_types/proto/BUILD index 5b4513732..83d483656 100644 --- a/ml_metadata/simple_types/proto/BUILD +++ b/ml_metadata/simple_types/proto/BUILD @@ -27,8 +27,5 @@ ml_metadata_proto_library( ml_metadata_proto_library_py( name = "simple_types_py_pb2", - srcs = ["simple_types.proto"], - api_version = 2, - oss_deps = ["//ml_metadata/proto:metadata_store_py_pb2"], - proto_library = "simple_types_proto", + deps = [":simple_types_proto"], ) diff --git a/ml_metadata/third_party/local_python.BUILD.tpl b/ml_metadata/third_party/local_python.BUILD.tpl new file mode 100644 index 000000000..9249afd80 --- /dev/null +++ b/ml_metadata/third_party/local_python.BUILD.tpl @@ -0,0 +1,65 @@ +licenses(["restricted"])Add commentMore actions + +package(default_visibility = ["//visibility:public"]) + +# Point both runtimes to the same python binary to ensure we always +# use the python binary specified by ./configure.py script. +load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") + +py_runtime( + name = "py2_runtime", + interpreter_path = "%{PYTHON_BIN_PATH}", + python_version = "PY2", +) + +py_runtime( + name = "py3_runtime", + interpreter_path = "%{PYTHON_BIN_PATH}", + python_version = "PY3", +) + +py_runtime_pair( + name = "py_runtime_pair", + py2_runtime = ":py2_runtime", + py3_runtime = ":py3_runtime", +) + +toolchain( + name = "py_toolchain", + toolchain = ":py_runtime_pair", + toolchain_type = "@bazel_tools//tools/python:toolchain_type", + target_compatible_with = [%{PLATFORM_CONSTRAINT}], + exec_compatible_with = [%{PLATFORM_CONSTRAINT}], +) + +# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +# See https://docs.python.org/3/extending/windows.html +cc_import( + name = "python_lib", + interface_library = select({ + "@platforms//os:windows": ":python_import_lib", + # A placeholder for Unix platforms which makes --no_build happy. + "//conditions:default": "not-existing.lib", + }), + system_provided = 1, +) + +cc_library( + name = "python_headers", + hdrs = [":python_include"], + deps = select({ + "@platforms//os:windows": [":python_lib"], + "//conditions:default": [], + }), + includes = ["python_include"], +) + +cc_library( + name = "numpy_headers", + hdrs = [":numpy_include"], + includes = ["numpy_include"], +) + +%{PYTHON_INCLUDE_GENRULE} +%{NUMPY_INCLUDE_GENRULE} +%{PYTHON_IMPORT_LIB_GENRULE} \ No newline at end of file diff --git a/ml_metadata/third_party/pybind11.BUILD b/ml_metadata/third_party/pybind11.BUILD new file mode 100644 index 000000000..050c39b99 --- /dev/null +++ b/ml_metadata/third_party/pybind11.BUILD @@ -0,0 +1,37 @@ +# pybind11 - Seamless operability between C++11 and Python.Add commentMore actions +load("@rules_cc//cc:defs.bzl", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +exports_files(["LICENSE"]) + +OPTIONS = [ + "-fexceptions", + # Useless warnings + "-Xclang-only=-Wno-undefined-inline", + "-Xclang-only=-Wno-pragma-once-outside-header", + "-Xgcc-only=-Wno-error", # no way to just disable the pragma-once warning in gcc +] + +INCLUDES = [ + "include/pybind11/*.h", + "include/pybind11/detail/*.h", +] + +EXCLUDES = [ + # Deprecated file that just emits a warning + "include/pybind11/common.h", +] + +cc_library( + name = "pybind11", + hdrs = glob( + INCLUDES, + exclude = EXCLUDES, + ), + copts = OPTIONS, + includes = ["include"], + deps = ["@local_config_python//:python_headers"], +) \ No newline at end of file diff --git a/ml_metadata/third_party/python_configure.bzl b/ml_metadata/third_party/python_configure.bzl new file mode 100644 index 000000000..cc70d8e28 --- /dev/null +++ b/ml_metadata/third_party/python_configure.bzl @@ -0,0 +1,488 @@ +"""Repository rule for configuring a local Python repo.Add commentMore actions + +`local_python_configure` depends on the following environment variables: + + * `PYTHON_BIN_PATH`: location of python binary. + * `PYTHON_LIB_PATH`: Location of python libraries. + +Add the following to your WORKSPACE FILE: + +```python +local_python_configure(name = "local_config_python") +``` + +Args: + name: A unique name for this workspace rule. +""" + +BAZEL_SH = "BAZEL_SH" +PYTHON_BIN_PATH = "PYTHON_BIN_PATH" +PYTHON_LIB_PATH = "PYTHON_LIB_PATH" + +def _auto_config_fail(msg): + """Output failure message when auto configuration fails.""" + red = "\033[0;31m" + no_color = "\033[0m" + fail("%sConfiguration Error:%s %s\n" % (red, no_color, msg)) + +def _which(repository_ctx, program_name): + """Returns the full path to a program on the execution platform. + + Args: + repository_ctx: the repository_ctx + program_name: name of the program on the PATH + + Returns: + The full path to a program on the execution platform. + """ + if _is_windows(repository_ctx): + if not program_name.endswith(".exe"): + program_name = program_name + ".exe" + result = _execute(repository_ctx, ["C:\\Windows\\System32\\where.exe", program_name]) + else: + result = _execute(repository_ctx, ["which", program_name]) + return result.stdout.rstrip() + +def _get_environ(repository_ctx, name, default_value = None): + """Returns the value of an environment variable on the execution platform. + + Args: + repository_ctx: the repository_ctx + name: the name of environment variable + default_value: the value to return if not set + + Returns: + The value of the environment variable 'name' on the execution platform + or 'default_value' if it's not set. + """ + if _is_windows(repository_ctx): + result = _execute( + repository_ctx, + ["C:\\Windows\\System32\\cmd.exe", "/c", "echo", "%" + name + "%"], + empty_stdout_fine = True, + ) + else: + cmd = "echo -n \"$%s\"" % name + result = _execute( + repository_ctx, + [_get_bash_bin(repository_ctx), "-c", cmd], + empty_stdout_fine = True, + ) + if len(result.stdout) == 0: + return default_value + return result.stdout + +def _execute( + repository_ctx, + cmdline, + error_msg = None, + error_details = None, + empty_stdout_fine = False): + """Executes an arbitrary shell command. + + Args: + repository_ctx: the repository_ctx object + cmdline: list of strings, the command to execute + error_msg: string, a summary of the error if the command fails + error_details: string, details about the error or steps to fix it + empty_stdout_fine: bool, if True, an empty stdout result is fine, + otherwise it's an error + Returns: + The result of repository_ctx.execute(cmdline) + """ + result = _raw_exec(repository_ctx, cmdline) + if result.stderr or not (empty_stdout_fine or result.stdout): + fail( + "\n".join([ + error_msg.strip() if error_msg else "Repository command failed", + result.stderr.strip(), + error_details if error_details else "", + "Command: " + " ".join(cmdline), + ]), + ) + return result + +def _get_bash_bin(repository_ctx): + """Gets the bash bin path. + + Args: + repository_ctx: the repository_ctx + + Returns: + The bash bin path. + """ + bash_bin = _get_host_environ(repository_ctx, BAZEL_SH) + if bash_bin != None: + return bash_bin + bash_bin_path = _which(repository_ctx, "bash") + if bash_bin_path == None: + _auto_config_fail("Cannot find bash in PATH, please make sure " + + "bash is installed and add its directory in PATH, or --define " + + "%s='/path/to/bash'.\nPATH=%s" % ( + BAZEL_SH, + _get_environ("PATH", ""), + )) + return bash_bin_path + +def _get_host_environ(repository_ctx, name): + """Returns the value of an environment variable on the host platform. + + The host platform is the machine that Bazel runs on. + + Args: + repository_ctx: the repository_ctx + name: the name of environment variable + + Returns: + The value of the environment variable 'name' on the host platform. + """ + if name in repository_ctx.os.environ: + return repository_ctx.os.environ.get(name).strip() + + if hasattr(repository_ctx.attr, "environ") and name in repository_ctx.attr.environ: + return repository_ctx.attr.environ.get(name).strip() + + return None + +def _get_python_bin(repository_ctx): + """Gets the python bin path. + + Args: + repository_ctx: the repository_ctx + + Returns: + The python bin path. + """ + python_bin = _get_host_environ(repository_ctx, PYTHON_BIN_PATH) + if python_bin != None: + return python_bin + + # First check for an explicit "python3" + python_bin = _which(repository_ctx, "python3") + if python_bin != None: + return python_bin + + # Some systems just call pythone3 "python" + python_bin = _which(repository_ctx, "python") + if python_bin != None: + return python_bin + + _auto_config_fail("Cannot find python in PATH, please make sure " + + "python is installed and add its directory in PATH, or --define " + + "%s='/something/else'.\nPATH=%s" % ( + PYTHON_BIN_PATH, + _get_environ("PATH", ""), + )) + return python_bin # unreachable + +def _is_windows(repository_ctx): + """Returns true if the execution platform is Windows. + + Args: + repository_ctx: the repository_ctx + + Returns: + If the execution platform is Windows. + """ + os_name = "" + if hasattr(repository_ctx.attr, "exec_properties") and "OSFamily" in repository_ctx.attr.exec_properties: + os_name = repository_ctx.attr.exec_properties["OSFamily"] + else: + os_name = repository_ctx.os.name + + return os_name.lower().find("windows") != -1 + +def _raw_exec(repository_ctx, cmdline): + """Executes a command via repository_ctx.execute() and returns the result. + + This method is useful for debugging purposes. For example, to print all + commands executed as well as their return code. + + Args: + repository_ctx: the repository_ctx + cmdline: the list of args + + Returns: + The 'exec_result' of repository_ctx.execute(). + """ + return repository_ctx.execute(cmdline) + +def _read_dir(repository_ctx, src_dir): + """Returns a sorted list with all files in a directory. + + Finds all files inside a directory, traversing subfolders and following + symlinks. + + Args: + repository_ctx: the repository_ctx + src_dir: the directory to traverse + + Returns: + A sorted list with all files in a directory. + """ + if _is_windows(repository_ctx): + src_dir = src_dir.replace("/", "\\") + find_result = _execute( + repository_ctx, + ["C:\\Windows\\System32\\cmd.exe", "/c", "dir", src_dir, "/b", "/s", "/a-d"], + empty_stdout_fine = True, + ) + + # src_files will be used in genrule.outs where the paths must + # use forward slashes. + result = find_result.stdout.replace("\\", "/") + else: + find_result = _execute( + repository_ctx, + ["find", src_dir, "-follow", "-type", "f"], + empty_stdout_fine = True, + ) + result = find_result.stdout + return sorted(result.splitlines()) + +def _genrule(src_dir, genrule_name, command, outs): + """Returns a string with a genrule. + + Genrule executes the given command and produces the given outputs. + """ + return ( + "genrule(\n" + + ' name = "' + + genrule_name + '",\n' + + " outs = [\n" + + outs + + "\n ],\n" + + ' cmd = """\n' + + command + + '\n """,\n' + + ")\n" + ) + +def _norm_path(path): + """Returns a path with '/' and remove the trailing slash.""" + path = path.replace("\\", "/") + if path[-1] == "/": + path = path[:-1] + return path + +def _symlink_genrule_for_dir( + repository_ctx, + src_dir, + dest_dir, + genrule_name, + src_files = [], + dest_files = []): + """Returns a genrule to symlink(or copy if on Windows) a set of files. + + If src_dir is passed, files will be read from the given directory; otherwise + we assume files are in src_files and dest_files + """ + if src_dir != None: + src_dir = _norm_path(src_dir) + dest_dir = _norm_path(dest_dir) + files = "\n".join(_read_dir(repository_ctx, src_dir)) + + # Create a list with the src_dir stripped to use for outputs. + dest_files = files.replace(src_dir, "").splitlines() + src_files = files.splitlines() + command = [] + outs = [] + for i in range(len(dest_files)): + if dest_files[i] != "": + # If we have only one file to link we do not want to use the dest_dir, as + # $(@D) will include the full path to the file. + dest = "$(@D)/" + dest_dir + dest_files[i] if len(dest_files) != 1 else "$(@D)/" + dest_files[i] + + # Copy the headers to create a sandboxable setup. + cmd = "cp -f" + command.append(cmd + ' "%s" "%s"' % (src_files[i], dest)) + outs.append(' "' + dest_dir + dest_files[i] + '",') + genrule = _genrule( + src_dir, + genrule_name, + " && ".join(command), + "\n".join(outs), + ) + return genrule + +def _get_python_lib(repository_ctx, python_bin): + """Gets the python lib path.""" + python_lib = _get_host_environ(repository_ctx, PYTHON_LIB_PATH) + if python_lib != None: + return python_lib + + # The interesting program to execute. + print_lib = [ + "from __future__ import print_function", + "import site", + "import os", + "python_paths = []", + "if os.getenv('PYTHONPATH') is not None:", + " python_paths = os.getenv('PYTHONPATH').split(':')", + "try:", + " library_paths = site.getsitepackages()", + "except AttributeError:", + " from distutils.sysconfig import get_python_lib", + " library_paths = [get_python_lib()]", + "all_paths = set(python_paths + library_paths)", + "paths = []", + "for path in all_paths:", + " if os.path.isdir(path):", + " paths.append(path)", + "if len(paths) >=1:", + " print(paths[0])", + ] + + # The below script writes the above program to a file + # and executes it. This is to work around the limitation + # of not being able to upload files as part of execute. + cmd = "from os import linesep;" + cmd += "f = open('script.py', 'w');" + for line in print_lib: + cmd += "f.write(\"%s\" + linesep);" % line + cmd += "f.close();" + cmd += "from os import system;" + cmd += "system(\"%s script.py\");" % python_bin + + result = _execute(repository_ctx, [python_bin, "-c", cmd]) + return result.stdout.strip() + +def _check_python_lib(repository_ctx, python_lib): + """Checks the python lib path.""" + cmd = 'test -d "%s" -a -x "%s"' % (python_lib, python_lib) + result = _raw_exec(repository_ctx, [_get_bash_bin(repository_ctx), "-c", cmd]) + if result.return_code == 1: + _auto_config_fail("Invalid python library path: %s" % python_lib) + +def _check_python_bin(repository_ctx, python_bin): + """Checks the python bin path.""" + cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) + result = _raw_exec(repository_ctx, [_get_bash_bin(repository_ctx), "-c", cmd]) + if result.return_code == 1: + _auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % ( + PYTHON_BIN_PATH, + python_bin, + )) + +def _get_python_include(repository_ctx, python_bin): + """Gets the python include path.""" + result = _execute( + repository_ctx, + [ + python_bin, + "-Wignore", + "-c", + "import importlib; " + + "import importlib.util; " + + "print(importlib.import_module('distutils.sysconfig').get_python_inc() " + + "if importlib.util.find_spec('distutils.sysconfig') " + + "else importlib.import_module('sysconfig').get_path('include'))", + ], + error_msg = "Problem getting python include path.", + error_details = ("Is the Python binary path set up right? " + + "(See ./configure or " + PYTHON_BIN_PATH + ".)" + + " Is distutils installed?"), + ) + return result.stdout.splitlines()[0] + +def _get_python_import_lib_name(repository_ctx, python_bin): + """Get Python import library name (pythonXY.lib) on Windows.""" + result = _execute( + repository_ctx, + [ + python_bin, + "-c", + "import sys;" + + 'print("python" + str(sys.version_info[0]) + ' + + ' str(sys.version_info[1]) + ".lib")', + ], + error_msg = "Problem getting python import library.", + error_details = ("Is the Python binary path set up right? " + + "(See ./configure or " + PYTHON_BIN_PATH + ".)" ), + ) + return result.stdout.splitlines()[0] + +def _get_numpy_include(repository_ctx, python_bin): + """Gets the numpy include path.""" + return _execute( + repository_ctx, + [ + python_bin, + "-c", + "from __future__ import print_function;" + + "import numpy;" + + " print(numpy.get_include());", + ], + error_msg = "Problem getting numpy include path.", + error_details = "Is numpy installed?", + ).stdout.splitlines()[0] + +def _create_local_python_repository(repository_ctx): + """Creates the repository containing files set up to build with Python.""" + + # Resolve all labels before doing any real work. Resolving causes the + # function to be restarted with all previous state being lost. This + # can easily lead to a O(n^2) runtime in the number of labels. + build_tpl = repository_ctx.path(Label("//ml_metadata/third_party:local_python.BUILD.tpl")) + + python_bin = _get_python_bin(repository_ctx) + _check_python_bin(repository_ctx, python_bin) + python_lib = _get_python_lib(repository_ctx, python_bin) + _check_python_lib(repository_ctx, python_lib) + python_include = _get_python_include(repository_ctx, python_bin) + numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy" + python_include_rule = _symlink_genrule_for_dir( + repository_ctx, + python_include, + "python_include", + "python_include", + ) + python_import_lib_genrule = "" + + # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib + # See https://docs.python.org/3/extending/windows.html + if _is_windows(repository_ctx): + python_bin = python_bin.replace("\\", "/") + python_include = _norm_path(python_include) + python_import_lib_name = _get_python_import_lib_name(repository_ctx, python_bin) + python_import_lib_src = python_include.rsplit("/", 1)[0] + "/libs/" + python_import_lib_name + python_import_lib_genrule = _symlink_genrule_for_dir( + repository_ctx, + None, + "", + "python_import_lib", + [python_import_lib_src], + [python_import_lib_name], + ) + numpy_include_rule = _symlink_genrule_for_dir( + repository_ctx, + numpy_include, + "numpy_include/numpy", + "numpy_include", + ) + + platform_constraint = "" + if repository_ctx.attr.platform_constraint: + platform_constraint = "\"%s\"" % repository_ctx.attr.platform_constraint + repository_ctx.template("BUILD", build_tpl, { + "%{PYTHON_BIN_PATH}": python_bin, + "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, + "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, + "%{NUMPY_INCLUDE_GENRULE}": numpy_include_rule, + "%{PLATFORM_CONSTRAINT}": platform_constraint, + }) + +_ENVIRONS = [ + BAZEL_SH, + PYTHON_BIN_PATH, + PYTHON_LIB_PATH, +] + +local_python_configure = repository_rule( + implementation = _create_local_python_repository, + environ = _ENVIRONS, + attrs = { + "environ": attr.string_dict(), + "platform_constraint": attr.string(), + }, +) From 69e7050979a6dbe5a475c4369c7bb13c24215af9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 1 Jul 2025 22:44:55 +0000 Subject: [PATCH 12/31] workspace updated --- WORKSPACE | 24 +++++-------------- .../third_party/local_python.BUILD.tpl | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index d1db4ffcd..dbd759e11 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -164,25 +164,11 @@ load("//ml_metadata/third_party:python_configure.bzl", "local_python_configure") local_python_configure(name = "local_config_python") -# Note - use @com_github_google_re2 instead of more canonical -# @com_google_re2 for consistency with dependency grpc -# which uses @com_github_google_re2. -# (see https://github.com/google/xls/issues/234) -http_archive( - name = "com_googlesource_code_re2", - sha256 = "ef516fb84824a597c4d5d0d6d330daedb18363b5a99eda87d027e6bdd9cba299", - strip_prefix = "re2-03da4fc0857c285e3a26782f6bc8931c4c950df4", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.tar.gz", - "https://github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.tar.gz", - ], -) - http_archive( name = "com_github_grpc_grpc", - urls = ["https://github.com/grpc/grpc/archive/v1.46.3.tar.gz"], - sha256 = "d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964", - strip_prefix = "grpc-1.46.3", + urls = ["https://github.com/grpc/grpc/archive/v1.50.0.tar.gz"], + sha256 = "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a", + strip_prefix = "grpc-1.50.0", ) load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") @@ -211,6 +197,8 @@ http_archive( urls = ["https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz"], ) + + http_archive( name = "io_bazel_rules_go", urls = [ @@ -314,4 +302,4 @@ ml_metadata_workspace() # Specify the minimum required bazel version. load("@bazel_skylib//lib:versions.bzl", "versions") -versions.check("6.5.0") +versions.check("6.5.0") \ No newline at end of file diff --git a/ml_metadata/third_party/local_python.BUILD.tpl b/ml_metadata/third_party/local_python.BUILD.tpl index 9249afd80..00bc82164 100644 --- a/ml_metadata/third_party/local_python.BUILD.tpl +++ b/ml_metadata/third_party/local_python.BUILD.tpl @@ -1,4 +1,4 @@ -licenses(["restricted"])Add commentMore actions +licenses(["restricted"]) package(default_visibility = ["//visibility:public"]) From b91dea2a36e017756ca52e38f7b4dbe2de8ad0ad Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 16:38:58 -0600 Subject: [PATCH 13/31] change proto to cc proto --- ml_metadata/metadata_store/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index 6f563abb8..f2ff77241 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -305,7 +305,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_cc_proto", ], ) From 15b78275b64adfd1621d4d991d581d41dfa7a934 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 16:53:24 -0600 Subject: [PATCH 14/31] fix --- ml_metadata/metadata_store/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index f2ff77241..6f563abb8 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -305,7 +305,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_cc_proto", + "//ml_metadata/proto:metadata_store_proto", ], ) From fdabf39f458e87763cdbc8cf171185968dbf21b2 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:05:06 -0600 Subject: [PATCH 15/31] remove deprecated source proto --- ml_metadata/proto/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 200f88316..85f22d28e 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -23,7 +23,7 @@ ml_metadata_proto_library( srcs = ["metadata_store.proto"], ) -ml_metadata_proto_library( +ml_metadata_proto_library ( name = "metadata_store_service_proto", srcs = ["metadata_store_service.proto"], deps = [":metadata_store_proto"], @@ -60,6 +60,6 @@ ml_metadata_proto_library( name = "metadata_source_proto", srcs = ["metadata_source.proto"], deps = [ - "@com_google_protobuf//:cc_wkt_protos", + # "@com_google_protobuf//:cc_wkt_protos", ], ) From 9815e8d98b3ff3888335725de5f351c4cd28261f Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:10:21 -0600 Subject: [PATCH 16/31] for well known types --- ml_metadata/metadata_store/BUILD | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index 6f563abb8..b72237a72 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -89,7 +89,19 @@ cc_library( "//ml_metadata/util:return_utils", "//ml_metadata/util:struct_utils", "@com_google_glog//:glog", - "@com_google_protobuf//:cc_wkt_protos", + # For well-known proto types like protobuf.Any. + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_proto", + "@com_google_protobuf//:compiler_plugin_proto", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:source_context_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:type_proto", + "@com_google_protobuf//:wrappers_proto", ], ) From 134a15250c5e41a1aff60bf4be6a50d9ed7c03c4 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:19:53 -0600 Subject: [PATCH 17/31] add any proto --- ml_metadata/proto/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 85f22d28e..232663836 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -60,6 +60,7 @@ ml_metadata_proto_library( name = "metadata_source_proto", srcs = ["metadata_source.proto"], deps = [ + "@com_google_protobuf//:any_proto" # "@com_google_protobuf//:cc_wkt_protos", ], ) From 5021ff187760d886cc83016657b8f422b9dff4f6 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:24:56 -0600 Subject: [PATCH 18/31] remove cc_wkt_protos --- ml_metadata/proto/BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 232663836..4ab3057b3 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -61,6 +61,5 @@ ml_metadata_proto_library( srcs = ["metadata_source.proto"], deps = [ "@com_google_protobuf//:any_proto" - # "@com_google_protobuf//:cc_wkt_protos", ], ) From 8c464b002c630354acdd00d87725485b759bca8a Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:30:28 -0600 Subject: [PATCH 19/31] no deps --- ml_metadata/proto/BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 4ab3057b3..6359b92d6 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -60,6 +60,5 @@ ml_metadata_proto_library( name = "metadata_source_proto", srcs = ["metadata_source.proto"], deps = [ - "@com_google_protobuf//:any_proto" ], ) From e0d9f46d2165149e49d71ee26ed73a64f67015e0 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:34:40 -0600 Subject: [PATCH 20/31] remove deps stuff --- ml_metadata/proto/BUILD | 2 -- 1 file changed, 2 deletions(-) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 6359b92d6..163cbdcf1 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -59,6 +59,4 @@ ml_metadata_proto_library_go( ml_metadata_proto_library( name = "metadata_source_proto", srcs = ["metadata_source.proto"], - deps = [ - ], ) From 2b3edca5fbf5235bb990265058eaa72ef1a69f1c Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:41:43 -0600 Subject: [PATCH 21/31] make them cc proto libraries --- ml_metadata/proto/BUILD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 163cbdcf1..495e4b1d7 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -18,12 +18,12 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) -ml_metadata_proto_library( +cc_proto_library( name = "metadata_store_proto", srcs = ["metadata_store.proto"], ) -ml_metadata_proto_library ( +cc_proto_library ( name = "metadata_store_service_proto", srcs = ["metadata_store_service.proto"], deps = [":metadata_store_proto"], @@ -56,7 +56,7 @@ ml_metadata_proto_library_go( deps = [":metadata_store_service_proto"], ) -ml_metadata_proto_library( +cc_proto_library( name = "metadata_source_proto", srcs = ["metadata_source.proto"], ) From 4ec5e7b5f8e7a4524de7369b1c4d1314482e08f9 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Tue, 8 Jul 2025 17:50:05 -0600 Subject: [PATCH 22/31] test --- ml_metadata/proto/BUILD | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 495e4b1d7..7bc03e2db 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -18,11 +18,16 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) -cc_proto_library( +proto_library( name = "metadata_store_proto", srcs = ["metadata_store.proto"], ) +cc_proto_library( + name = "metadata_store_proto_cc" + deps = [":metadata_store_proto"], +) + cc_proto_library ( name = "metadata_store_service_proto", srcs = ["metadata_store_service.proto"], From 7436e6434549037fc093b225462cd51d10c6f970 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Fri, 8 Aug 2025 20:02:23 +0000 Subject: [PATCH 23/31] checkpoint --- WORKSPACE | 277 +++++++++++++++------------ ml_metadata/metadata_store/BUILD | 119 +++++------- ml_metadata/ml_metadata.bzl | 46 +++-- ml_metadata/proto/BUILD | 17 +- ml_metadata/simple_types/proto/BUILD | 5 +- 5 files changed, 248 insertions(+), 216 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index dbd759e11..e4d6c4838 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,6 +3,36 @@ workspace(name = "ml_metadata") load("//ml_metadata:repo.bzl", "clean_dep") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name = "google_bazel_common", + sha256 = "82a49fb27c01ad184db948747733159022f9464fc2e62da996fa700594d9ea42", + strip_prefix = "bazel-common-2a6b6406e12208e02b2060df0631fb30919080f3", + urls = ["https://github.com/google/bazel-common/archive/2a6b6406e12208e02b2060df0631fb30919080f3.zip"], +) + +################################################################################ +# Generic Bazel Support # +################################################################################ + +http_archive( + name = "rules_proto", + sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295", + strip_prefix = "rules_proto-6.0.2", + url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz", +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") + +rules_proto_dependencies() + +load("@rules_proto//proto:setup.bzl", "rules_proto_setup") + +rules_proto_setup() + +load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") + +rules_proto_toolchains() + http_archive( name = "postgresql", build_file = "//ml_metadata:postgresql.BUILD", @@ -48,25 +78,6 @@ http_archive( url = "https://github.com/abseil/abseil-cpp/archive/4447c7562e3bc702ade25105912dce503f0c4010.tar.gz", ) -http_archive( - name = "rules_proto", - sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295", - strip_prefix = "rules_proto-6.0.2", - url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz", -) - -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") - -rules_proto_dependencies() - -load("@rules_proto//proto:setup.bzl", "rules_proto_setup") - -rules_proto_setup() - -load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") - -rules_proto_toolchains() - http_archive( name = "boringssl", sha256 = "1188e29000013ed6517168600fc35a010d58c5d321846d6a6dfee74e4c788b45", @@ -104,15 +115,33 @@ http_archive( ) # 1.5.0 +# http_archive( +# name = "bazel_skylib", +# sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", +# urls = [ +# "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", +# "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", +# ], +# ) + + http_archive( + name = "bazel_skylib", - sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + + sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", + urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", + + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + ], + ) + # Needed by abseil-py by zetasql. http_archive( name = "six_archive", @@ -137,20 +166,20 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() # Needed by Protobuf. -http_archive( - name = "zlib", - build_file = "@com_google_protobuf//:third_party/zlib.BUILD", - sha256 = "d8688496ea40fb61787500e863cc63c9afcbc524468cedeb478068924eb54932", - strip_prefix = "zlib-1.2.12", - urls = ["https://github.com/madler/zlib/archive/v1.2.12.tar.gz"], -) - -http_archive( - name = "pybind11_bazel", - strip_prefix = "pybind11_bazel-faf56fb3df11287f26dbc66fdedf60a2fc2c6631", - urls = ["https://github.com/pybind/pybind11_bazel/archive/faf56fb3df11287f26dbc66fdedf60a2fc2c6631.tar.gz"], - sha256 = "a2b107b06ffe1049696e132d39987d80e24d73b131d87f1af581c2cb271232f8", -) +# http_archive( +# name = "zlib", +# build_file = "@com_google_protobuf//:third_party/zlib.BUILD", +# sha256 = "d8688496ea40fb61787500e863cc63c9afcbc524468cedeb478068924eb54932", +# strip_prefix = "zlib-1.2.12", +# urls = ["https://github.com/madler/zlib/archive/v1.2.12.tar.gz"], +# ) + +# http_archive( +# name = "pybind11_bazel", +# strip_prefix = "pybind11_bazel-faf56fb3df11287f26dbc66fdedf60a2fc2c6631", +# urls = ["https://github.com/pybind/pybind11_bazel/archive/faf56fb3df11287f26dbc66fdedf60a2fc2c6631.tar.gz"], +# sha256 = "a2b107b06ffe1049696e132d39987d80e24d73b131d87f1af581c2cb271232f8", +# ) http_archive( name = "pybind11", @@ -164,135 +193,137 @@ load("//ml_metadata/third_party:python_configure.bzl", "local_python_configure") local_python_configure(name = "local_config_python") +# http_archive( +# name = "com_github_grpc_grpc", +# urls = ["https://github.com/grpc/grpc/archive/v1.50.0.tar.gz"], +# sha256 = "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a", +# strip_prefix = "grpc-1.50.0", +# ) +# +# load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") +# grpc_deps() +# +# load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") +# grpc_extra_deps() +# +# # Needed by Protobuf. +# bind( +# name = "grpc_python_plugin", +# actual = "@com_github_grpc_grpc//src/compiler:grpc_python_plugin", +# ) +# +# # Needed by Protobuf. +# bind( +# name = "grpc_lib", +# actual = "@com_github_grpc_grpc//:grpc++", +# ) +# +# # Needed by gRPC. +# http_archive( +# name = "build_bazel_rules_swift", +# sha256 = "d0833bc6dad817a367936a5f902a0c11318160b5e80a20ece35fb85a5675c886", +# strip_prefix = "rules_swift-3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8", +# urls = ["https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz"], +# ) + + +################################################################################ +# Google APIs protos # +################################################################################ http_archive( - name = "com_github_grpc_grpc", - urls = ["https://github.com/grpc/grpc/archive/v1.50.0.tar.gz"], - sha256 = "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a", - strip_prefix = "grpc-1.50.0", + name = "com_google_googleapis", + #patch_args = ["-p1"], + #patches = ["//ml_metadata/third_party:googleapis.patch"], + sha256 = "28e7fe3a640dd1f47622a4c263c40d5509c008cc20f97bd366076d5546cccb64", + strip_prefix = "googleapis-4ce00b00904a7ce1df8c157e54fcbf96fda0dc49", + url = "https://github.com/googleapis/googleapis/archive/4ce00b00904a7ce1df8c157e54fcbf96fda0dc49.tar.gz", ) -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") -grpc_deps() - -load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") -grpc_extra_deps() - -# Needed by Protobuf. -bind( - name = "grpc_python_plugin", - actual = "@com_github_grpc_grpc//src/compiler:grpc_python_plugin", -) +load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") -# Needed by Protobuf. -bind( - name = "grpc_lib", - actual = "@com_github_grpc_grpc//:grpc++", +switched_rules_by_language( + name = "com_google_googleapis_imports", + cc = True, + go = True ) -# Needed by gRPC. -http_archive( - name = "build_bazel_rules_swift", - sha256 = "d0833bc6dad817a367936a5f902a0c11318160b5e80a20ece35fb85a5675c886", - strip_prefix = "rules_swift-3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8", - urls = ["https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz"], -) +############################################################################### +# Gazelle Support # +############################################################################### +_rules_go_version = "v0.48.1" http_archive( name = "io_bazel_rules_go", + sha256 = "b2038e2de2cace18f032249cb4bb0048abf583a36369fa98f687af1b3f880b26", 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://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip".format(_rules_go_version), + "https://github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip.format(_rules_go_version)", ], - sha256 = "e88471aea3a3a4f19ec1310a55ba94772d087e9ce46e41ae38ecebe17935de7b", ) -load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.21.11") + +_bazel_gazelle_version = "0.36.0" http_archive( name = "bazel_gazelle", + sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", 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://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v{0}/bazel-gazelle-v{0}.tar.gz".format(_bazel_gazelle_version), + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v{0}/bazel-gazelle-v{0}.tar.gz".format(_bazel_gazelle_version), ], - sha256 = "86c6d481b3f7aedc1d60c1c211c6f76da282ae197c3b3160f54bd3a8f847896f", ) -load("@bazel_gazelle//:deps.bzl", "go_repository", "gazelle_dependencies") - -go_repository( - name = "org_golang_x_sys", - commit = "57f5ac02873b2752783ca8c3c763a20f911e4d89", - importpath = "golang.org/x/sys", -) - -go_repository( - name = "com_github_google_go_cmp", - importpath = "github.com/google/go-cmp", - tag = "v0.2.0", -) - -go_repository( - name = "com_github_golang_protobuf", - importpath = "github.com/golang/protobuf", - tag = "v1.3.2", -) - -go_repository( - name = "org_golang_google_protobuf", - importpath = "google.golang.org/protobuf", - tag = "v1.25.0", -) - -go_repository( - name = "org_golang_x_net", - importpath = "golang.org/x/net", - commit = "b3afb19ee333d5231c1034d3ac2a5313cde533a3", -) - -go_rules_dependencies() - -go_register_toolchains() +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") gazelle_dependencies() -# For commandline flags used in gRPC server -# gflags needed by glog -http_archive( - name = "com_github_gflags_gflags", - strip_prefix = "gflags-a738fdf9338412f83ab3f26f31ac11ed3f3ec4bd", - sha256 = "017e0a91531bfc45be9eaf07e4d8fed33c488b90b58509dbd2e33a33b2648ae6", - url = "https://github.com/gflags/gflags/archive/a738fdf9338412f83ab3f26f31ac11ed3f3ec4bd.zip", -) +################################################################################ +# ZetaSQL # +################################################################################ + +ZETASQL_COMMIT = "a516c6b26d183efc4f56293256bba92e243b7a61" # 11/01/2024 -ZETASQL_COMMIT = "a516c6b26d183efc4f56293256bba92e243b7a61" # 11/01/2024 http_archive( name = "com_google_zetasql", patch_args = ["-p1"], patches = ["//ml_metadata/third_party:zetasql.patch"], - urls = ["https://github.com/google/zetasql/archive/%s.zip" % ZETASQL_COMMIT], + sha256 = "1afc2210d4aad371eff0a6bfdd8417ba99e02183a35dff167af2fa6097643f26", strip_prefix = "zetasql-%s" % ZETASQL_COMMIT, - sha256 = '8db98b93bd6bb7348ed6d374f8eb6b602f7012bd5d368b3ffdee0a56c6c8d85f' + urls = ["https://github.com/google/zetasql/archive/%s.tar.gz" % ZETASQL_COMMIT], ) load("@com_google_zetasql//bazel:zetasql_deps_step_1.bzl", "zetasql_deps_step_1") + zetasql_deps_step_1() + load("@com_google_zetasql//bazel:zetasql_deps_step_2.bzl", "zetasql_deps_step_2") + zetasql_deps_step_2( analyzer_deps = True, evaluator_deps = True, - tools_deps = False, java_deps = False, - testing_deps = False) - -# This is part of what zetasql_deps_step_3() does. -load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") -switched_rules_by_language( - name = "com_google_googleapis_imports", - cc = True, + testing_deps = False, + tools_deps = False, ) +# No need to run zetasql_deps_step_3 and zetasql_deps_step_4 since all necessary dependencies are +# already installed. + +# load("@com_google_zetasql//bazel:zetasql_deps_step_3.bzl", "zetasql_deps_step_3") + +# zetasql_deps_step_3() + +# load("@com_google_zetasql//bazel:zetasql_deps_step_4.bzl", "zetasql_deps_step_4") + +# zetasql_deps_step_4() + # Please add all new ML Metadata dependencies in workspace.bzl. diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index b72237a72..8fe753788 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -43,7 +43,7 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_google_protobuf//:protobuf", ], ) @@ -70,7 +70,6 @@ cc_library( ":metadata_access_object_base", ":query_executor", "@com_google_protobuf//:protobuf", - "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", @@ -81,27 +80,14 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/simple_types:simple_types_constants", "//ml_metadata/util:field_mask_utils", "//ml_metadata/util:record_parsing_utils", "//ml_metadata/util:return_utils", "//ml_metadata/util:struct_utils", - "@com_google_glog//:glog", - # For well-known proto types like protobuf.Any. - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:api_proto", - "@com_google_protobuf//:compiler_plugin_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:source_context_proto", - "@com_google_protobuf//:struct_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:type_proto", - "@com_google_protobuf//:wrappers_proto", + "@com_google_glog//:glog" ], ) @@ -123,8 +109,8 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", ], @@ -143,7 +129,7 @@ cc_test( "@com_google_googletest//:gtest_main", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "@com_google_glog//:glog", ], @@ -165,8 +151,8 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", ], @@ -192,8 +178,8 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", ], @@ -212,7 +198,7 @@ cc_test( ":sqlite_metadata_source", "@com_google_googletest//:gtest_main", "@com_google_absl//absl/memory", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "@com_google_glog//:glog", ], @@ -233,7 +219,7 @@ cc_library( ":test_mysql_metadata_source_initializer", "@com_google_googletest//:gtest_main", "@com_google_absl//absl/memory", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "@com_google_glog//:glog", ], @@ -280,8 +266,8 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/query:filter_query_ast_resolver", "//ml_metadata/query:filter_query_builder", "//ml_metadata/util:return_utils", @@ -360,8 +346,8 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_protobuf//:protobuf", ], @@ -376,7 +362,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "//ml_metadata/util:return_utils", ], ) @@ -390,7 +376,7 @@ cc_test( "@com_google_googletest//:gtest_main", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", ], ) @@ -401,7 +387,7 @@ cc_library( deps = [ ":metadata_source", "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", ], ) @@ -424,6 +410,7 @@ cc_library( hdrs = ["metadata_store_service_interface.h"], deps = [ "@com_google_absl//absl/status", + "//ml_metadata/proto:metadata_store_proto", "//ml_metadata/proto:metadata_store_service_proto", ], ) @@ -450,8 +437,8 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/proto:metadata_store_service_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", "//ml_metadata/simple_types:simple_types_constants", "//ml_metadata/simple_types/proto:simple_types_proto", "//ml_metadata/util:return_utils", @@ -475,8 +462,8 @@ cc_library( "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/proto:metadata_store_service_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", "//ml_metadata/simple_types/proto:simple_types_proto", ], ) @@ -502,9 +489,9 @@ cc_test( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/proto:metadata_store_service_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", @@ -533,9 +520,9 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/proto:metadata_store_service_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", "@com_google_protobuf//:protobuf", ], ) @@ -552,7 +539,7 @@ cc_library( ":transaction_executor", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "//ml_metadata/util:return_utils", ], @@ -570,8 +557,8 @@ cc_test( ":metadata_store_factory", ":test_util", "@com_google_googletest//:gtest_main", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_google_glog//:glog", ], ) @@ -584,7 +571,7 @@ cc_library( ":constants", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "@org_sqlite", ], ) @@ -600,7 +587,7 @@ cc_library( "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_google_glog//:glog", "@org_sqlite", ], @@ -640,7 +627,7 @@ cc_library( "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/simple_types:simple_types_constants", "//ml_metadata/simple_types/proto:simple_types_proto", ], @@ -653,7 +640,7 @@ cc_test( ":simple_types_util", "@com_google_googletest//:gtest_main", "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", ], ) @@ -663,7 +650,7 @@ cc_test( deps = [ ":test_util", "@com_google_googletest//:gtest_main", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", ], ) @@ -684,8 +671,8 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", "@libmysqlclient", @@ -746,9 +733,9 @@ cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/proto/testing:mock_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/proto/testing:mock_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_github_gflags_gflags//:gflags_nothreads", "@com_google_glog//:glog", @@ -770,7 +757,7 @@ cc_library( "@com_google_googletest//:gtest", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", ], ) @@ -850,7 +837,7 @@ cc_test( "@com_google_googletest//:gtest_main", "@com_google_absl//absl/memory", "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "@com_google_glog//:glog", ], @@ -870,7 +857,7 @@ cc_library( "@com_google_absl//absl/memory", "@com_google_absl//absl/status", "@com_google_absl//absl/types:optional", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", "//ml_metadata/util:metadata_source_query_config", "@com_google_glog//:glog", ], @@ -986,8 +973,8 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", "@postgresql", @@ -1008,8 +995,8 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/query:filter_query_ast_resolver", "//ml_metadata/query:filter_query_builder", "//ml_metadata/util:return_utils", @@ -1054,8 +1041,8 @@ cc_test( ":sqlite_metadata_source", "@com_google_googletest//:gtest_main", "@com_google_absl//absl/memory", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/util:metadata_source_query_config", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_google_glog//:glog", ], ) diff --git a/ml_metadata/ml_metadata.bzl b/ml_metadata/ml_metadata.bzl index 97b6391ea..e8b3adf3d 100644 --- a/ml_metadata/ml_metadata.bzl +++ b/ml_metadata/ml_metadata.bzl @@ -17,10 +17,16 @@ This module contains build rules for ml_metadata in OSS. load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") +#load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_cc//cc:defs.bzl", "cc_proto_library") -def ml_metadata_proto_library(name, srcs = [], deps = [], visibility = None, testonly = 0): +def ml_metadata_proto_library(name, **kwargs): + """Google proto_library and cc_proto_library. + + Args: + name: Name of the cc proto library. + **kwargs: Keyword arguments to pass to the proto libraries.""" well_known_protos = [ "@com_google_protobuf//:any_proto", "@com_google_protobuf//:duration_proto", @@ -29,30 +35,40 @@ def ml_metadata_proto_library(name, srcs = [], deps = [], visibility = None, tes "@com_google_protobuf//:empty_proto", "@com_google_protobuf//:wrappers_proto", ] - native.proto_library( - name = name, - srcs = srcs, - deps = deps + well_known_protos, - visibility = visibility, - testonly = testonly, - ) + kwargs["deps"] = kwargs.get("deps", []) + well_known_protos + native.proto_library(name = name, **kwargs) # buildifier: disable=native-proto cc_proto_kwargs = { "deps": [":" + name], } - if visibility: - cc_proto_kwargs["visibility"] = visibility - if testonly: - cc_proto_kwargs["testonly"] = testonly + if "visibility" in kwargs: + cc_proto_kwargs["visibility"] = kwargs["visibility"] + if "testonly" in kwargs: + cc_proto_kwargs["testonly"] = kwargs["testonly"] + if "compatible_with" in kwargs: + cc_proto_kwargs["compatible_with"] = kwargs["compatible_with"] cc_proto_library(name = name + "_cc_pb2", **cc_proto_kwargs) -def ml_metadata_proto_library_py(name, deps, visibility = None, testonly = 0): +def ml_metadata_proto_library_py( + name, + proto_library, + srcs = [], + deps = [], + visibility = None, + testonly = 0): + """Opensource py_proto_library.""" + _ignore = [proto_library] # buildifier: disable=unused-variable py_proto_library( name = name, - deps = deps, + srcs = srcs, + srcs_version = "PY3", + deps = deps, # ["@com_google_protobuf//:well_known_types_py_pb2"] + + default_runtime = "@com_google_protobuf//:protobuf_python", + protoc = "@com_google_protobuf//:protoc", visibility = visibility, testonly = testonly, ) + def ml_metadata_proto_library_go( name, deps = [], diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 7bc03e2db..bb71c6196 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -18,17 +18,12 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) -proto_library( +ml_metadata_proto_library( name = "metadata_store_proto", srcs = ["metadata_store.proto"], ) -cc_proto_library( - name = "metadata_store_proto_cc" - deps = [":metadata_store_proto"], -) - -cc_proto_library ( +ml_metadata_proto_library( name = "metadata_store_service_proto", srcs = ["metadata_store_service.proto"], deps = [":metadata_store_proto"], @@ -36,12 +31,14 @@ cc_proto_library ( ml_metadata_proto_library_py( name = "metadata_store_py_pb2", - deps = [":metadata_store_proto"], + srcs = ["metadata_store.proto"], + proto_library="metadata_store_proto", ) ml_metadata_proto_library_py( name = "metadata_store_service_py_pb2", - deps = [":metadata_store_service_proto"], + srcs = ["metadata_store_service.proto"], + proto_library="metadata_store_service_proto", ) ml_metadata_proto_library_go( @@ -61,7 +58,7 @@ ml_metadata_proto_library_go( deps = [":metadata_store_service_proto"], ) -cc_proto_library( +ml_metadata_proto_library( name = "metadata_source_proto", srcs = ["metadata_source.proto"], ) diff --git a/ml_metadata/simple_types/proto/BUILD b/ml_metadata/simple_types/proto/BUILD index 83d483656..b50a04d50 100644 --- a/ml_metadata/simple_types/proto/BUILD +++ b/ml_metadata/simple_types/proto/BUILD @@ -19,7 +19,7 @@ licenses(["notice"]) ml_metadata_proto_library( name = "simple_types_proto", - srcs = ["simple_types.proto"], + srcs = ["simple_types.proto"], deps = [ "//ml_metadata/proto:metadata_store_proto", ], @@ -27,5 +27,6 @@ ml_metadata_proto_library( ml_metadata_proto_library_py( name = "simple_types_py_pb2", - deps = [":simple_types_proto"], + proto_library = "simple_types_proto", + srcs = ["simple_types.proto"], ) From 4886583c324907acb8c56c6533ee049f713092e2 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Fri, 8 Aug 2025 20:11:25 +0000 Subject: [PATCH 24/31] update cc protobuff names --- ml_metadata/util/BUILD | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ml_metadata/util/BUILD b/ml_metadata/util/BUILD index d03c42631..e8a4f7802 100644 --- a/ml_metadata/util/BUILD +++ b/ml_metadata/util/BUILD @@ -11,7 +11,7 @@ cc_library( deps = [ "@com_google_protobuf//:protobuf", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_source_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", # switched to cc proto library "@com_google_glog//:glog", ], ) @@ -66,7 +66,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", # switched "@com_google_protobuf//:protobuf", ], ) @@ -81,7 +81,7 @@ cc_test( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", # switched "@com_google_protobuf//:protobuf", ], ) @@ -97,8 +97,8 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "//ml_metadata/metadata_store:constants", - "//ml_metadata/proto:metadata_source_proto", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_source_proto_cc_pb2", # switched + "//ml_metadata/proto:metadata_store_proto_cc_pb2", # switched "@com_google_glog//:glog", ], ) @@ -111,6 +111,6 @@ cc_test( "@com_google_googletest//:gtest_main", "@com_google_absl//absl/status", "//ml_metadata/metadata_store:test_util", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", # switched ], ) From c71409847d20cd0a951b5d3e6c91a7f8bfaa9e41 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Fri, 8 Aug 2025 20:22:13 +0000 Subject: [PATCH 25/31] update more cc protos to the proper name --- ml_metadata/metadata_store/BUILD | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ml_metadata/metadata_store/BUILD b/ml_metadata/metadata_store/BUILD index 8fe753788..33d7a8227 100644 --- a/ml_metadata/metadata_store/BUILD +++ b/ml_metadata/metadata_store/BUILD @@ -289,7 +289,7 @@ cc_library( "@com_google_absl//absl/strings", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", ], ) @@ -303,7 +303,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", ], ) @@ -317,7 +317,7 @@ cc_test( "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_google_glog//:glog", ], ) @@ -410,8 +410,8 @@ cc_library( hdrs = ["metadata_store_service_interface.h"], deps = [ "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/proto:metadata_store_service_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", ], ) @@ -440,7 +440,7 @@ cc_library( "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", "//ml_metadata/simple_types:simple_types_constants", - "//ml_metadata/simple_types/proto:simple_types_proto", + "//ml_metadata/simple_types/proto:simple_types_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_google_glog//:glog", ], @@ -464,7 +464,7 @@ cc_library( "@com_google_absl//absl/types:span", "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/proto:metadata_store_service_proto_cc_pb2", - "//ml_metadata/simple_types/proto:simple_types_proto", + "//ml_metadata/simple_types/proto:simple_types_proto_cc_pb2", ], ) @@ -629,7 +629,7 @@ cc_library( "@com_google_absl//absl/strings", "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/simple_types:simple_types_constants", - "//ml_metadata/simple_types/proto:simple_types_proto", + "//ml_metadata/simple_types/proto:simple_types_proto_cc_pb2", ], ) @@ -687,7 +687,7 @@ cc_library( ":metadata_store", ":metadata_store_factory", "@com_google_absl//absl/status", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_github_grpc_grpc//:grpc++", "@com_google_glog//:glog", ], @@ -704,7 +704,7 @@ cc_binary( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_github_gflags_gflags//:gflags_nothreads", "@com_github_grpc_grpc//:grpc++", "@com_google_glog//:glog", @@ -778,7 +778,7 @@ cc_library( ":mysql_metadata_source", ":test_mysql_metadata_source_initializer", "@com_google_absl//absl/memory", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_github_gflags_gflags//:gflags_nothreads", "@com_google_glog//:glog", ], @@ -953,7 +953,7 @@ cc_library( ":postgresql_metadata_source", ":test_postgresql_metadata_source_initializer", "@com_google_absl//absl/memory", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_github_gflags_gflags//:gflags_nothreads", "@com_google_glog//:glog", "@postgresql", From b9bfd2e702d1d4782af336b5bf1361b5a6e43664 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Fri, 8 Aug 2025 21:06:19 +0000 Subject: [PATCH 26/31] more cc files --- ml_metadata/metadata_store/pywrap/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ml_metadata/metadata_store/pywrap/BUILD b/ml_metadata/metadata_store/pywrap/BUILD index 5927e93fe..aa43a51c4 100644 --- a/ml_metadata/metadata_store/pywrap/BUILD +++ b/ml_metadata/metadata_store/pywrap/BUILD @@ -34,8 +34,8 @@ ml_metadata_pybind_extension( "@com_google_absl//absl/status", "//ml_metadata/metadata_store:metadata_store_factory", "//ml_metadata/metadata_store:simple_types_util", - "//ml_metadata/proto:metadata_store_proto", - "//ml_metadata/simple_types/proto:simple_types_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", + "//ml_metadata/simple_types/proto:simple_types_proto_cc_pb2", "@pybind11", ], ) From 612c311f860043dd7a87495705e76ad526469b6b Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Fri, 8 Aug 2025 21:07:21 +0000 Subject: [PATCH 27/31] more cc changes --- ml_metadata/query/BUILD | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ml_metadata/query/BUILD b/ml_metadata/query/BUILD index 355eee5e2..59c688ca5 100644 --- a/ml_metadata/query/BUILD +++ b/ml_metadata/query/BUILD @@ -26,7 +26,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "//ml_metadata/util:return_utils", "@com_googlesource_code_re2//:re2", "@com_google_zetasql//zetasql/public:analyzer", @@ -43,7 +43,7 @@ cc_test( "@com_google_googletest//:gtest_main", "@com_google_absl//absl/status", "//ml_metadata/metadata_store:test_util", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", ], ) @@ -57,7 +57,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "//ml_metadata/metadata_store:constants", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", "@com_google_glog//:glog", "@com_google_zetasql//zetasql/public:strings", "@com_google_zetasql//zetasql/resolved_ast:sql_builder", @@ -74,6 +74,6 @@ cc_test( "@com_google_googletest//:gtest_main", "@com_google_absl//absl/status", "//ml_metadata/metadata_store:test_util", - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto_cc_pb2", ], ) From f35e1978d1889b3186025b9aca3de665fe525f40 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Sat, 9 Aug 2025 00:35:56 +0000 Subject: [PATCH 28/31] more updates, building until running into a header file import error "google/protobuff/util/json_util.h" --- WORKSPACE | 16 +++++++++++----- ml_metadata/ml_metadata.bzl | 25 ++++++++++++------------- ml_metadata/proto/BUILD | 9 +++++---- ml_metadata/simple_types/proto/BUILD | 8 +++++--- ml_metadata/util/BUILD | 2 ++ 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index e4d6c4838..ec1e28988 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -161,6 +161,13 @@ http_archive( urls = ["https://github.com/protocolbuffers/protobuf/archive/v4.25.6.tar.gz"], ) + +# Needed by com_google_protobuf. +bind( + name = "six", + actual = "@six_archive//:six", +) + load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() @@ -325,12 +332,11 @@ zetasql_deps_step_2( # zetasql_deps_step_4() +# Specify the minimum required bazel version. +load("@bazel_skylib//lib:versions.bzl", "versions") +versions.check("6.5.0") # Please add all new ML Metadata dependencies in workspace.bzl. load("//ml_metadata:workspace.bzl", "ml_metadata_workspace") -ml_metadata_workspace() - -# Specify the minimum required bazel version. -load("@bazel_skylib//lib:versions.bzl", "versions") -versions.check("6.5.0") \ No newline at end of file +ml_metadata_workspace() \ No newline at end of file diff --git a/ml_metadata/ml_metadata.bzl b/ml_metadata/ml_metadata.bzl index e8b3adf3d..2e68f280e 100644 --- a/ml_metadata/ml_metadata.bzl +++ b/ml_metadata/ml_metadata.bzl @@ -17,8 +17,7 @@ This module contains build rules for ml_metadata in OSS. load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") -#load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_cc//cc:defs.bzl", "cc_proto_library") def ml_metadata_proto_library(name, **kwargs): @@ -28,11 +27,18 @@ def ml_metadata_proto_library(name, **kwargs): name: Name of the cc proto library. **kwargs: Keyword arguments to pass to the proto libraries.""" well_known_protos = [ + # For well-known proto types like protobuf.Any. "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_proto", + "@com_google_protobuf//:compiler_plugin_proto", + "@com_google_protobuf//:descriptor_proto", "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:struct_proto", "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:source_context_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:type_proto", "@com_google_protobuf//:wrappers_proto", ] kwargs["deps"] = kwargs.get("deps", []) + well_known_protos @@ -50,20 +56,13 @@ def ml_metadata_proto_library(name, **kwargs): def ml_metadata_proto_library_py( name, - proto_library, - srcs = [], - deps = [], + deps, visibility = None, testonly = 0): """Opensource py_proto_library.""" - _ignore = [proto_library] # buildifier: disable=unused-variable py_proto_library( name = name, - srcs = srcs, - srcs_version = "PY3", - deps = deps, # ["@com_google_protobuf//:well_known_types_py_pb2"] + - default_runtime = "@com_google_protobuf//:protobuf_python", - protoc = "@com_google_protobuf//:protoc", + deps = deps, visibility = visibility, testonly = testonly, ) diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index bb71c6196..429b1a69f 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -31,14 +31,15 @@ ml_metadata_proto_library( ml_metadata_proto_library_py( name = "metadata_store_py_pb2", - srcs = ["metadata_store.proto"], - proto_library="metadata_store_proto", + deps = [":metadata_store_proto"], ) ml_metadata_proto_library_py( name = "metadata_store_service_py_pb2", - srcs = ["metadata_store_service.proto"], - proto_library="metadata_store_service_proto", + deps = [ + ":metadata_store_service_proto", + ":metadata_store_proto", + ], ) ml_metadata_proto_library_go( diff --git a/ml_metadata/simple_types/proto/BUILD b/ml_metadata/simple_types/proto/BUILD index b50a04d50..271737de1 100644 --- a/ml_metadata/simple_types/proto/BUILD +++ b/ml_metadata/simple_types/proto/BUILD @@ -21,12 +21,14 @@ ml_metadata_proto_library( name = "simple_types_proto", srcs = ["simple_types.proto"], deps = [ - "//ml_metadata/proto:metadata_store_proto", + "//ml_metadata/proto:metadata_store_proto" ], ) ml_metadata_proto_library_py( name = "simple_types_py_pb2", - proto_library = "simple_types_proto", - srcs = ["simple_types.proto"], + deps = [ + ":simple_types_proto", + "//ml_metadata/proto:metadata_store_proto", + ], ) diff --git a/ml_metadata/util/BUILD b/ml_metadata/util/BUILD index e8a4f7802..fab7f503b 100644 --- a/ml_metadata/util/BUILD +++ b/ml_metadata/util/BUILD @@ -100,6 +100,8 @@ cc_library( "//ml_metadata/proto:metadata_source_proto_cc_pb2", # switched "//ml_metadata/proto:metadata_store_proto_cc_pb2", # switched "@com_google_glog//:glog", + "@com_google_protobuf//:protobuf", # Add this if not already present + "@com_google_protobuf//src/google/protobuf/util:json_util", # Add this ], ) From 76474e7b5ab40911be1b7d82e031c5eac39e1aa5 Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Mon, 11 Aug 2025 09:12:08 -0600 Subject: [PATCH 29/31] update protobuf json imports --- ml_metadata/util/BUILD | 3 +-- ml_metadata/util/record_parsing_utils.cc | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ml_metadata/util/BUILD b/ml_metadata/util/BUILD index fab7f503b..e46e00b0d 100644 --- a/ml_metadata/util/BUILD +++ b/ml_metadata/util/BUILD @@ -100,8 +100,7 @@ cc_library( "//ml_metadata/proto:metadata_source_proto_cc_pb2", # switched "//ml_metadata/proto:metadata_store_proto_cc_pb2", # switched "@com_google_glog//:glog", - "@com_google_protobuf//:protobuf", # Add this if not already present - "@com_google_protobuf//src/google/protobuf/util:json_util", # Add this + "@com_google_protobuf//:protobuf", ], ) diff --git a/ml_metadata/util/record_parsing_utils.cc b/ml_metadata/util/record_parsing_utils.cc index a283e4861..41161db68 100644 --- a/ml_metadata/util/record_parsing_utils.cc +++ b/ml_metadata/util/record_parsing_utils.cc @@ -18,7 +18,7 @@ limitations under the License. #include #include -#include "google/protobuf/util/json_util.h" +#include "google/protobuf/json/json.h" #include "absl/container/flat_hash_set.h" #include "absl/status/status.h" #include "absl/strings/match.h" @@ -206,7 +206,7 @@ absl::Status ParseValueToField(const google::protobuf::FieldDescriptor* field_de if (!value.empty()) { google::protobuf::Message* sub_message = reflection->MutableMessage(&output_message, field_descriptor); - if (!google::protobuf::util::JsonStringToMessage( + if (!google::protobuf::json::JsonStringToMessage( std::string(value.begin(), value.size()), sub_message) .ok()) { return absl::InternalError( From 29a7ce075679feefe24dfbfa8ad63c78b93b5b2f Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Mon, 11 Aug 2025 09:18:41 -0600 Subject: [PATCH 30/31] cleanup --- WORKSPACE | 63 ------------------------------------------------------- 1 file changed, 63 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index ec1e28988..be61e7a01 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -114,17 +114,6 @@ http_archive( sha256 = "6281aa4eeecb9e932d7091f99872e7b26fa6aacece49c15ce5b14af2b7ec050f", ) -# 1.5.0 -# http_archive( -# name = "bazel_skylib", -# sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", -# urls = [ -# "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", -# "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", -# ], -# ) - - http_archive( name = "bazel_skylib", @@ -172,22 +161,6 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() -# Needed by Protobuf. -# http_archive( -# name = "zlib", -# build_file = "@com_google_protobuf//:third_party/zlib.BUILD", -# sha256 = "d8688496ea40fb61787500e863cc63c9afcbc524468cedeb478068924eb54932", -# strip_prefix = "zlib-1.2.12", -# urls = ["https://github.com/madler/zlib/archive/v1.2.12.tar.gz"], -# ) - -# http_archive( -# name = "pybind11_bazel", -# strip_prefix = "pybind11_bazel-faf56fb3df11287f26dbc66fdedf60a2fc2c6631", -# urls = ["https://github.com/pybind/pybind11_bazel/archive/faf56fb3df11287f26dbc66fdedf60a2fc2c6631.tar.gz"], -# sha256 = "a2b107b06ffe1049696e132d39987d80e24d73b131d87f1af581c2cb271232f8", -# ) - http_archive( name = "pybind11", build_file = "//ml_metadata/third_party:pybind11.BUILD", @@ -200,47 +173,11 @@ load("//ml_metadata/third_party:python_configure.bzl", "local_python_configure") local_python_configure(name = "local_config_python") -# http_archive( -# name = "com_github_grpc_grpc", -# urls = ["https://github.com/grpc/grpc/archive/v1.50.0.tar.gz"], -# sha256 = "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a", -# strip_prefix = "grpc-1.50.0", -# ) -# -# load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") -# grpc_deps() -# -# load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") -# grpc_extra_deps() -# -# # Needed by Protobuf. -# bind( -# name = "grpc_python_plugin", -# actual = "@com_github_grpc_grpc//src/compiler:grpc_python_plugin", -# ) -# -# # Needed by Protobuf. -# bind( -# name = "grpc_lib", -# actual = "@com_github_grpc_grpc//:grpc++", -# ) -# -# # Needed by gRPC. -# http_archive( -# name = "build_bazel_rules_swift", -# sha256 = "d0833bc6dad817a367936a5f902a0c11318160b5e80a20ece35fb85a5675c886", -# strip_prefix = "rules_swift-3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8", -# urls = ["https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz"], -# ) - - ################################################################################ # Google APIs protos # ################################################################################ http_archive( name = "com_google_googleapis", - #patch_args = ["-p1"], - #patches = ["//ml_metadata/third_party:googleapis.patch"], sha256 = "28e7fe3a640dd1f47622a4c263c40d5509c008cc20f97bd366076d5546cccb64", strip_prefix = "googleapis-4ce00b00904a7ce1df8c157e54fcbf96fda0dc49", url = "https://github.com/googleapis/googleapis/archive/4ce00b00904a7ce1df8c157e54fcbf96fda0dc49.tar.gz", From 560b48aa1401197704cfa366c3116b3a6f505c8f Mon Sep 17 00:00:00 2001 From: andrewfulton9 Date: Mon, 11 Aug 2025 09:20:42 -0600 Subject: [PATCH 31/31] pre-commit run --- WORKSPACE | 2 +- ml_metadata/simple_types/proto/BUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index be61e7a01..ca8a0ecfc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -276,4 +276,4 @@ versions.check("6.5.0") # Please add all new ML Metadata dependencies in workspace.bzl. load("//ml_metadata:workspace.bzl", "ml_metadata_workspace") -ml_metadata_workspace() \ No newline at end of file +ml_metadata_workspace() diff --git a/ml_metadata/simple_types/proto/BUILD b/ml_metadata/simple_types/proto/BUILD index 271737de1..ead929f92 100644 --- a/ml_metadata/simple_types/proto/BUILD +++ b/ml_metadata/simple_types/proto/BUILD @@ -19,7 +19,7 @@ licenses(["notice"]) ml_metadata_proto_library( name = "simple_types_proto", - srcs = ["simple_types.proto"], + srcs = ["simple_types.proto"], deps = [ "//ml_metadata/proto:metadata_store_proto" ],