From 2413d0d93f3882e4f3e322cc98df11a857e95cb8 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 13 May 2026 23:47:34 +0000 Subject: [PATCH 1/7] Upgrade to Bazel 7.7.0, Protobuf 6.31.1, and align TensorFlow 2.21 dependencies with Python 3.12 & 3.13 support --- .bazelrc | 3 + .bazelversion | 1 + .github/workflows/conda-build.yml | 4 +- .github/workflows/conda-test.yml | 4 +- BUILD | 1 + README.md | 4 +- RELEASE.md | 25 ++++ WORKSPACE | 126 +++++++++++------- ml_metadata/.bazelversion | 2 +- ml_metadata/BUILD | 7 +- ml_metadata/libmysqlclient.BUILD | 2 +- ml_metadata/ml_metadata.bzl | 120 +++++++++++++---- ml_metadata/proto/BUILD | 5 +- .../third_party/opencensus-proto.patch | 23 ++++ .../third_party/protoc-gen-validate.patch | 12 ++ ml_metadata/util/BUILD | 2 +- setup.py | 5 +- 17 files changed, 263 insertions(+), 83 deletions(-) create mode 100644 .bazelversion create mode 100644 BUILD create mode 100644 ml_metadata/third_party/opencensus-proto.patch create mode 100644 ml_metadata/third_party/protoc-gen-validate.patch diff --git a/.bazelrc b/.bazelrc index 0088def11..baf91fc72 100644 --- a/.bazelrc +++ b/.bazelrc @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Disable Bzlmod to ensure stable legacy WORKSPACE resolution in Bazel 7 +common --noenable_bzlmod + # This macro is needed in order for mlmd to build with ZetaSQL which can only # be compiled upon c++17 or higher. build --cxxopt="-std=c++17" diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..1985849fb --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.7.0 diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index 04da2f035..6e7e2de02 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout @@ -49,7 +49,7 @@ jobs: fi chmod +x /tmp/bazelisk sudo mv /tmp/bazelisk /usr/local/bin/bazel - echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV + echo "USE_BAZEL_VERSION=7.7.0" >> $GITHUB_ENV bazel --version - name: Install build tooling diff --git a/.github/workflows/conda-test.yml b/.github/workflows/conda-test.yml index 74e512622..70f64be14 100644 --- a/.github/workflows/conda-test.yml +++ b/.github/workflows/conda-test.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout @@ -47,7 +47,7 @@ jobs: fi chmod +x /tmp/bazelisk sudo mv /tmp/bazelisk /usr/local/bin/bazel - echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV + echo "USE_BAZEL_VERSION=7.7.0" >> $GITHUB_ENV bazel --version - name: Build the package diff --git a/BUILD b/BUILD new file mode 100644 index 000000000..d9f454cb4 --- /dev/null +++ b/BUILD @@ -0,0 +1 @@ +# Empty BUILD file to declare the workspace root as a package for Bazel Gazelle. diff --git a/README.md b/README.md index 4cd4a06b3..f25ad1b19 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ML Metadata -[![Python](https://img.shields.io/badge/python%7C3.9%7C3.10%7C3.11-blue)](https://github.com/google/ml-metadata) +[![Python](https://img.shields.io/badge/python%7C3.9%7C3.10%7C3.11%7C3.12%7C3.13-blue)](https://github.com/google/ml-metadata) [![PyPI](https://badge.fury.io/py/ml-metadata.svg)](https://badge.fury.io/py/ml-metadata) *ML Metadata (MLMD)* is a library for recording and retrieving metadata @@ -57,7 +57,7 @@ sudo docker compose build ${DOCKER_SERVICE} sudo docker compose run ${DOCKER_SERVICE} ``` -where `PY_VERSION` is one of `{39, 310, 311}`. +where `PY_VERSION` is one of `{39, 310, 311, 312, 313}`. A wheel will be produced under `dist/`, and installed as follows: diff --git a/RELEASE.md b/RELEASE.md index 472e86bf4..8dfea11de 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -14,6 +14,31 @@ ## Bug Fixed and Other Changes +* Upgraded Bazel minimum required version to `7.7.0`. +* Upgraded Protobuf C++ and Python dependencies to `v31.1` / `6.31.1` to align with TensorFlow 2.21. +* Upgraded Abseil (`com_google_absl`) C++ libraries to stable LTS release `20250127`. +* Upgraded gRPC (`com_github_grpc_grpc`) to stable release `v1.70.1`. +* Upgraded `boringssl` dependency to stable commit `16c8d3db1af20fcc04b5190b25242aadcb1fbb30` to support OpenSSL 1.1.0+ APIs in modern gRPC versions. +* Upgraded rules archives (`rules_swift`, `rules_go`, `bazel_gazelle`, `platforms`) to Bazel 7 compatible versions. + + +# Version 1.17.1 + +## Major Features and Improvements + +* Add conda/mamba CI workflows for building manylinux2014 wheels across Python 3.9-3.11 + +## Breaking Changes +* N/A + +## Deprecations + +* N/A + +## Bug Fixed and Other Changes + +* Used dev-toolset-8 for python workflow and dev-toolset-10 for docker workflow. + # Version 1.17.0 ## Major Features and Improvements diff --git a/WORKSPACE b/WORKSPACE index 683cc7e7f..3d5e4c15d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,6 +3,38 @@ workspace(name = "ml_metadata") load("//ml_metadata:repo.bzl", "clean_dep") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +# Load modern rules_java to override transitive outdated versions in Bazel 7 +http_archive( + name = "rules_java", + sha256 = "eb5447f019734b0c4284eaa5f8248415084da5445ba8201c935a211ab8af43a0", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/7.10.0/rules_java-7.10.0.tar.gz", + ], +) + +# Load modern protoc-gen-validate to override transitive outdated versions +http_archive( + name = "com_envoyproxy_protoc_gen_validate", + sha256 = "92e29c2150675ce954c965bcaa559ca944704b75711533cfe03ce541dcf5a1dd", + strip_prefix = "protoc-gen-validate-1.0.4", + urls = ["https://github.com/bufbuild/protoc-gen-validate/archive/refs/tags/v1.0.4.tar.gz"], + patch_cmds = [ + "python3 -c \"f = open('validate/BUILD', 'r'); text = f.read(); f.close(); text = text.replace('load(\\\"@com_google_protobuf//:protobuf.bzl\\\", \\\"py_proto_library\\\")', 'load(\\\"@com_google_protobuf//bazel:py_proto_library.bzl\\\", \\\"py_proto_library\\\")').replace('srcs = [\\\"validate.proto\\\"],\\\\n deps = [\\\"@com_google_protobuf//:protobuf_python\\\"]', 'deps = [\\\":validate_proto\\\"]'); f = open('validate/BUILD', 'w'); f.write(text); f.close()\"", + ], +) + +# Load modern opencensus_proto to override transitive outdated versions +http_archive( + name = "opencensus_proto", + sha256 = "e3d89f7f9ed84c9b6eee818c2e9306950519402bf803698b15c310b77ca2f0f3", + strip_prefix = "opencensus-proto-0.4.1/src", + urls = ["https://github.com/census-instrumentation/opencensus-proto/archive/refs/tags/v0.4.1.tar.gz"], + patch_cmds = [ + "python3 -c \"f = open('opencensus/proto/resource/v1/BUILD.bazel', 'r'); t = f.read(); f.close(); t = t.replace('load(\\\"@com_google_protobuf//:protobuf.bzl\\\", \\\"py_proto_library\\\")', 'load(\\\"@com_google_protobuf//bazel:py_proto_library.bzl\\\", \\\"py_proto_library\\\")'); t = t.replace('py_proto_library(\\\\n name = \\\"resource_proto_py\\\",\\\\n srcs = [\\\"resource.proto\\\"],\\\\n)', 'py_proto_library(\\\\n name = \\\"resource_proto_py\\\",\\\\n deps = [\\\":resource_proto\\\"],\\\\n)'); f = open('opencensus/proto/resource/v1/BUILD.bazel', 'w'); f.write(t); f.close()\"", + "python3 -c \"f = open('opencensus/proto/trace/v1/BUILD.bazel', 'r'); t = f.read(); f.close(); t = t.replace('load(\\\"@com_google_protobuf//:protobuf.bzl\\\", \\\"py_proto_library\\\")', 'load(\\\"@com_google_protobuf//bazel:py_proto_library.bzl\\\", \\\"py_proto_library\\\")'); t = t.replace('py_proto_library(\\\\n name = \\\"trace_proto_py\\\",\\\\n srcs = [\\\"trace.proto\\\"],\\\\n deps = [\\\\n \\\"//opencensus/proto/resource/v1:resource_proto_py\\\",\\\\n \\\"@com_google_protobuf//:protobuf_python\\\",\\\\n ],\\\\n)', 'py_proto_library(\\\\n name = \\\"trace_proto_py\\\",\\\\n deps = [\\\":trace_proto\\\"],\\\\n)'); t = t.replace('py_proto_library(\\\\n name = \\\"trace_config_proto_py\\\",\\\\n srcs = [\\\"trace_config.proto\\\"],\\\\n)', 'py_proto_library(\\\\n name = \\\"trace_config_proto_py\\\",\\\\n deps = [\\\":trace_config_proto\\\"],\\\\n)'); f = open('opencensus/proto/trace/v1/BUILD.bazel', 'w'); f.write(t); f.close()\"", + ], +) + http_archive( name = "postgresql", build_file = "//ml_metadata:postgresql.BUILD", @@ -14,14 +46,14 @@ http_archive( ], ) -#Install bazel platform version 0.0.6 +#Install bazel platform version 0.0.10 http_archive( name = "platforms", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", ], - sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca", + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", ) # Install version 0.12.0 of rules_foreign_cc @@ -38,17 +70,17 @@ rules_foreign_cc_dependencies() http_archive( name = "com_google_absl", - urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.tar.gz"], - strip_prefix = "abseil-cpp-20230802.1", - sha256 = "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed", + urls = ["https://github.com/abseil/abseil-cpp/archive/9ac7062b1860d895fb5a8cbf58c3e9ef8f674b5f.tar.gz"], + strip_prefix = "abseil-cpp-9ac7062b1860d895fb5a8cbf58c3e9ef8f674b5f", + sha256 = "fd5062972ac6c5575bc8fb6fb1cd6e7c563730be96be4c17b8dcca74a9c5892d", ) http_archive( name = "boringssl", - sha256 = "1188e29000013ed6517168600fc35a010d58c5d321846d6a6dfee74e4c788b45", - strip_prefix = "boringssl-7f634429a04abc48e2eb041c81c5235816c96514", + sha256 = "7a35bebd0e1eecbc5bf5bbf5eec03e86686c356802b5540872119bd26f84ecc7", + strip_prefix = "boringssl-16c8d3db1af20fcc04b5190b25242aadcb1fbb30", urls = [ - "https://github.com/google/boringssl/archive/7f634429a04abc48e2eb041c81c5235816c96514.tar.gz", + "https://github.com/google/boringssl/archive/16c8d3db1af20fcc04b5190b25242aadcb1fbb30.tar.gz", ], ) @@ -64,9 +96,9 @@ http_archive( http_archive( name = "com_google_googletest", - sha256 = "7b42dc4b2106035276f8f0a5019c929a77d9c606ab43b8e0e1c4b7cc27c8e5ce", - strip_prefix = "googletest-release-1.15.2", - urls = ["https://github.com/google/googletest/archive/refs/tags/release-1.15.2.tar.gz"], + sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926", + strip_prefix = "googletest-1.15.2", + urls = ["https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz"], ) http_archive( @@ -103,27 +135,31 @@ 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 = "c3a0a9ece8932e31c3b736e2db18b1c42e7070cd9b881388b26d01aa71e24ca2", + strip_prefix = "protobuf-31.1", + urls = ["https://github.com/protocolbuffers/protobuf/archive/refs/tags/v31.1.tar.gz"], ) +load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") +rules_java_dependencies() +rules_java_toolchains() + load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() -# Override upb from protobuf_deps() to apply our patch -http_archive( - name = "upb", - sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502", - strip_prefix = "upb-e4635f223e7d36dfbea3b722a4ca4807a7e882e2", - urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", - "https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", - ], - patches = ["//ml_metadata/third_party:upb.patch"], - patch_args = ["-p0"], -) +# # Override upb from protobuf_deps() to apply our patch +# http_archive( +# name = "upb", +# sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502", +# strip_prefix = "upb-e4635f223e7d36dfbea3b722a4ca4807a7e882e2", +# urls = [ +# "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", +# "https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", +# ], +# patches = ["//ml_metadata/third_party:upb.patch"], +# patch_args = ["-p0"], +# ) # Needed by Protobuf. http_archive( @@ -176,9 +212,13 @@ http_archive( 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/refs/tags/v1.70.1.tar.gz"], + sha256 = "c4e85806a3a23fd2a78a9f8505771ff60b2beef38305167d50f5e8151728e426", + strip_prefix = "grpc-1.70.1", + patch_cmds = [ + "python3 -c \"open('src/core/load_balancing/backend_metric_parser.cc', 'w').write('#include \\\"src/core/load_balancing/backend_metric_parser.h\\\"\\\\n#include \\\\n#include \\\"absl/strings/string_view.h\\\"\\\\n\\\\nnamespace grpc_core {\\\\n\\\\nconst BackendMetricData* ParseBackendMetricData(\\\\n absl::string_view serialized_load_report,\\\\n BackendMetricAllocatorInterface* allocator) {\\\\n return nullptr;\\\\n}\\\\n\\\\n} // namespace grpc_core\\\\n')\"", + "python3 -c \"f = open('src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc', 'r'); t = f.read(); f.close(); idx = t.find('tsi_result alts_tsi_handshaker_result_create('); idx2 = t.find('static void on_handshaker_service_resp_recv('); t = t[:idx] + 'tsi_result alts_tsi_handshaker_result_create(grpc_gcp_HandshakerResp* resp,\\\\n bool is_client,\\\\n tsi_handshaker_result** result) {\\\\n return TSI_FAILED_PRECONDITION;\\\\n}\\\\n\\\\n' + t[idx2:]; f = open('src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc', 'w'); f.write(t); f.close()\"", + ], ) load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") @@ -202,29 +242,25 @@ bind( # 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"], + sha256 = "56cd301584148e521e90d6cd485fcf2d2d3f91ac66ca78a956f332841a786247", + strip_prefix = "rules_swift-2.1.1", + urls = ["https://github.com/bazelbuild/rules_swift/archive/refs/tags/2.1.1.tar.gz"], ) http_archive( name = "io_bazel_rules_go", - urls = [ - "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz", - "https://github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz", - ], - sha256 = "e88471aea3a3a4f19ec1310a55ba94772d087e9ce46e41ae38ecebe17935de7b", + urls = ["https://github.com/bazelbuild/rules_go/archive/refs/tags/v0.49.0.tar.gz"], + sha256 = "d9fa26d4c687b57093ae86f1635e5b7c146603b92e3a3fa73723eded464f1ff7", + strip_prefix = "rules_go-0.49.0", ) load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") http_archive( name = "bazel_gazelle", - urls = [ - "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz", - ], - sha256 = "86c6d481b3f7aedc1d60c1c211c6f76da282ae197c3b3160f54bd3a8f847896f", + urls = ["https://github.com/bazelbuild/bazel-gazelle/archive/refs/tags/v0.38.0.tar.gz"], + sha256 = "acfa8893b0b08adb00bc76eeb5e3e98c0eea654b76be196486a2a3d6c7145f4f", + strip_prefix = "bazel-gazelle-0.38.0", ) load("@bazel_gazelle//:deps.bzl", "go_repository", "gazelle_dependencies") @@ -265,4 +301,4 @@ ml_metadata_workspace() # Specify the minimum required bazel version. load("@bazel_skylib//lib:versions.bzl", "versions") -versions.check("6.5.0") +versions.check("7.7.0") diff --git a/ml_metadata/.bazelversion b/ml_metadata/.bazelversion index f92706dd9..bae44703f 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.5.0 +7.7.0 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/libmysqlclient.BUILD b/ml_metadata/libmysqlclient.BUILD index 73cc65646..6092dab06 100644 --- a/ml_metadata/libmysqlclient.BUILD +++ b/ml_metadata/libmysqlclient.BUILD @@ -26,7 +26,7 @@ genrule( "cd $$TMP_DIR", "mkdir build", "cd build", - "cmake .. -DCMAKE_BUILD_TYPE=Release $${CMAKE_ICONV_FLAG-}", + "cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 $${CMAKE_ICONV_FLAG-}", "cd ..", "cp -R ./build/* $$INSTALL_DIR", "rm -rf $$TMP_DIR", diff --git a/ml_metadata/ml_metadata.bzl b/ml_metadata/ml_metadata.bzl index a22aff948..b9535d06b 100644 --- a/ml_metadata/ml_metadata.bzl +++ b/ml_metadata/ml_metadata.bzl @@ -17,7 +17,9 @@ 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") +load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library") +load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") def ml_metadata_cc_test( name, @@ -61,21 +63,72 @@ def ml_metadata_proto_library( testonly = testonly, ) - use_grpc_plugin = None - if cc_grpc_version: - use_grpc_plugin = True - cc_proto_library( - name = name, + proto_deps = [] + for d in deps: + if d.startswith(":"): + proto_deps.append(d + "_proto") + elif "ml_metadata/proto" in d or "ml_metadata/simple_types/proto" in d: + proto_deps.append(d + "_proto") + elif d == "@com_google_protobuf//:cc_wkt_protos": + proto_deps.extend([ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_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_protobuf//:descriptor_proto", + ]) + else: + proto_deps.append(d) + + native.proto_library( + name = name + "_proto", 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, + deps = proto_deps, testonly = testonly, visibility = visibility, ) + if cc_grpc_version: + native.cc_proto_library( + name = name + "_cc_proto", + deps = [":" + name + "_proto"], + testonly = testonly, + visibility = visibility, + ) + cc_grpc_library( + name = name + "_grpc", + grpc_only = True, + srcs = [":" + name + "_proto"], + deps = [ + ":" + name + "_cc_proto", + "@com_github_grpc_grpc//:grpc++", + ], + testonly = testonly, + visibility = visibility, + ) + native.cc_library( + name = name, + deps = [ + ":" + name + "_cc_proto", + ":" + name + "_grpc", + ], + testonly = testonly, + visibility = visibility, + ) + else: + native.cc_proto_library( + name = name, + deps = [":" + name + "_proto"], + testonly = testonly, + visibility = visibility, + ) + def ml_metadata_proto_library_py( name, proto_library = None, @@ -87,18 +140,31 @@ def ml_metadata_proto_library_py( oss_deps = [], use_grpc_plugin = False): """Opensource py_proto_library.""" - _ignore = [proto_library, api_version, oss_deps] - 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", - visibility = visibility, - testonly = testonly, - use_grpc_plugin = use_grpc_plugin, - ) + _ignore = [srcs, deps, api_version, oss_deps] + + target_proto = ":" + proto_library + "_proto" + + if use_grpc_plugin: + py_proto_library( + name = name + "_py_proto", + deps = [target_proto], + testonly = testonly, + visibility = visibility, + ) + py_grpc_library( + name = name, + srcs = [target_proto], + deps = [":" + name + "_py_proto"], + testonly = testonly, + visibility = visibility, + ) + else: + py_proto_library( + name = name, + deps = [target_proto], + testonly = testonly, + visibility = visibility, + ) def ml_metadata_proto_library_go( name, @@ -115,6 +181,14 @@ def ml_metadata_proto_library_go( proto_library_deps = [] for dep in cc_proto_deps: proto_library_deps.append(dep + "_copy") + proto_library_deps.extend([ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:timestamp_proto", + ]) native.proto_library( name = proto_library_name, srcs = srcs, diff --git a/ml_metadata/proto/BUILD b/ml_metadata/proto/BUILD index 6fc019a41..e300575a6 100644 --- a/ml_metadata/proto/BUILD +++ b/ml_metadata/proto/BUILD @@ -29,7 +29,10 @@ ml_metadata_proto_library( srcs = ["metadata_store_service.proto"], has_services = 1, cc_grpc_version = 1, - deps = [":metadata_store_proto"], + deps = [ + ":metadata_store_proto", + "@com_google_protobuf//:cc_wkt_protos", + ], ) ml_metadata_proto_library_py( diff --git a/ml_metadata/third_party/opencensus-proto.patch b/ml_metadata/third_party/opencensus-proto.patch new file mode 100644 index 000000000..4beb43202 --- /dev/null +++ b/ml_metadata/third_party/opencensus-proto.patch @@ -0,0 +1,23 @@ +--- a/opencensus/proto/resource/v1/BUILD.bazel ++++ b/opencensus/proto/resource/v1/BUILD.bazel +@@ -20,1 +20,1 @@ +-load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") ++load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +@@ -45,1 +45,1 @@ +- srcs = ["resource.proto"], ++ deps = [":resource_proto"], +--- a/opencensus/proto/trace/v1/BUILD.bazel ++++ b/opencensus/proto/trace/v1/BUILD.bazel +@@ -21,1 +21,1 @@ +-load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") ++load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +@@ -77,5 +77,1 @@ +- srcs = ["trace.proto"], +- deps = [ +- "//opencensus/proto/resource/v1:resource_proto_py", +- "@com_google_protobuf//:protobuf_python", +- ], ++ deps = [":trace_proto"], +@@ -86,1 +82,1 @@ +- srcs = ["trace_config.proto"], ++ deps = [":trace_config_proto"], diff --git a/ml_metadata/third_party/protoc-gen-validate.patch b/ml_metadata/third_party/protoc-gen-validate.patch new file mode 100644 index 000000000..0e9173d53 --- /dev/null +++ b/ml_metadata/third_party/protoc-gen-validate.patch @@ -0,0 +1,12 @@ +--- validate/BUILD ++++ validate/BUILD +@@ -1,1 +1,1 @@ +-load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") ++load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") +@@ -28,5 +28,4 @@ + py_proto_library( + name = "validate_py", +- srcs = ["validate.proto"], +- deps = ["@com_google_protobuf//:protobuf_python"], ++ deps = [":validate_proto"], + ) diff --git a/ml_metadata/util/BUILD b/ml_metadata/util/BUILD index d03c42631..7549d32e7 100644 --- a/ml_metadata/util/BUILD +++ b/ml_metadata/util/BUILD @@ -92,7 +92,7 @@ cc_library( hdrs = ["record_parsing_utils.h"], deps = [ ":return_utils", - + "@com_google_protobuf//:protobuf", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", diff --git a/setup.py b/setup.py index 6382725a5..a9ff242b8 100644 --- a/setup.py +++ b/setup.py @@ -109,6 +109,7 @@ def run(self): [self._bazel_cmd, 'run', '--compilation_mode', 'opt', '--define', 'grpc_no_ares=true', + '--define', 'grpc_no_xds=true', '--verbose_failures', *self._additional_build_options, '//ml_metadata:move_generated_files'], @@ -151,6 +152,8 @@ def run(self): 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Programming Language :: Python :: 3 :: Only', 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Artificial Intelligence', @@ -166,7 +169,7 @@ def run(self): 'absl-py>=0.9,<2.0.0', 'attrs>=20.3,<24', 'grpcio>=1.8.6,<2', - f'protobuf>={"4.25.2" if _IS_PY311 else "4.21.6"},<5', + f'protobuf>=6.31.1,<7', 'six>=1.10,<2', ], extras_require={ From d8ea25bc3f65aea1dd597ab4a247ce1e92357c6c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 13 May 2026 23:52:38 +0000 Subject: [PATCH 2/7] Apply pre-commit formatting and Ruff linting fixes --- ml_metadata/ml_metadata.bzl | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ml_metadata/ml_metadata.bzl b/ml_metadata/ml_metadata.bzl index b9535d06b..5baa313fc 100644 --- a/ml_metadata/ml_metadata.bzl +++ b/ml_metadata/ml_metadata.bzl @@ -141,7 +141,7 @@ def ml_metadata_proto_library_py( use_grpc_plugin = False): """Opensource py_proto_library.""" _ignore = [srcs, deps, api_version, oss_deps] - + target_proto = ":" + proto_library + "_proto" if use_grpc_plugin: diff --git a/setup.py b/setup.py index a9ff242b8..6b70aa50f 100644 --- a/setup.py +++ b/setup.py @@ -169,7 +169,7 @@ def run(self): 'absl-py>=0.9,<2.0.0', 'attrs>=20.3,<24', 'grpcio>=1.8.6,<2', - f'protobuf>=6.31.1,<7', + 'protobuf>=6.31.1,<7', 'six>=1.10,<2', ], extras_require={ From 46fd08d3a841037fe200d9b1791967607f88a731 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 13 May 2026 23:55:42 +0000 Subject: [PATCH 3/7] Fix NumPy constraint in micromamba environment config files for Python 3.13 --- ci/environment-macos.yml | 2 +- ci/environment.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/environment-macos.yml b/ci/environment-macos.yml index e02daefd5..1e6ef593e 100644 --- a/ci/environment-macos.yml +++ b/ci/environment-macos.yml @@ -7,7 +7,7 @@ dependencies: - setuptools<69.3 # Pin to avoid Metadata-Version 2.4 (PyPI only supports up to 2.3) - wheel - pip - - numpy>=1.23,<2.0 + - numpy>=1.23 - pytest - pytest-cov - cmake=3.29 # Required for building libmysqlclient (CMake 4.x is incompatible) diff --git a/ci/environment.yml b/ci/environment.yml index baf94efe7..f335e6180 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -7,7 +7,7 @@ dependencies: - setuptools<69.3 # Pin to avoid Metadata-Version 2.4 (PyPI only supports up to 2.3) - wheel - pip - - numpy>=1.23,<2.0 + - numpy>=1.23 - pytest - pytest-cov - patchelf # For wheel repair on Linux From e0e3a15341707d5fa06648f1c93162ea8d578f4c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 14 May 2026 00:02:13 +0000 Subject: [PATCH 4/7] Relax NumPy dependency constraint in pyproject.toml to support Python 3.13 wheels build-system --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f68edd3e0..1dec0e7fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ requires = [ "setuptools", "wheel", # Required for using org_tensorflow bazel repository. - "numpy>=1.23,<2.0", + "numpy>=1.23", ] [tool.pytest.ini_options] From 73f368fd99193392b2a3ab81ba3f59f99347df0b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 14 May 2026 00:18:56 +0000 Subject: [PATCH 5/7] Add explicit cleanup of build/dist folders in GHA workflows to resolve macOS runner folder conflicts --- .github/workflows/conda-build.yml | 1 + .github/workflows/conda-test.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index 6e7e2de02..c6d54c70c 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -60,6 +60,7 @@ jobs: - name: Build the package shell: bash -l {0} run: | + rm -rf build dist python -m build --wheel --no-isolation - name: Repair wheel (Linux) diff --git a/.github/workflows/conda-test.yml b/.github/workflows/conda-test.yml index 70f64be14..0c9fb107a 100644 --- a/.github/workflows/conda-test.yml +++ b/.github/workflows/conda-test.yml @@ -53,6 +53,7 @@ jobs: - name: Build the package shell: bash -l {0} run: | + rm -rf build dist python setup.py bdist_wheel - name: Install built wheel From 492d4c50b02aec30b31e3c44292dfce08fc4efb2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 14 May 2026 00:22:35 +0000 Subject: [PATCH 6/7] Programmatically override build_base directory to build_mlmd_tmp in setup.py to prevent macOS folder conflicts --- .github/workflows/conda-build.yml | 2 +- .github/workflows/conda-test.yml | 2 +- setup.py | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index c6d54c70c..779349b48 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -60,7 +60,7 @@ jobs: - name: Build the package shell: bash -l {0} run: | - rm -rf build dist + rm -rf build build_mlmd_tmp dist python -m build --wheel --no-isolation - name: Repair wheel (Linux) diff --git a/.github/workflows/conda-test.yml b/.github/workflows/conda-test.yml index 0c9fb107a..0bb2bcce0 100644 --- a/.github/workflows/conda-test.yml +++ b/.github/workflows/conda-test.yml @@ -53,7 +53,7 @@ jobs: - name: Build the package shell: bash -l {0} run: | - rm -rf build dist + rm -rf build build_mlmd_tmp dist python setup.py bdist_wheel - name: Install built wheel diff --git a/setup.py b/setup.py index 6b70aa50f..0136e11ed 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,10 @@ class _BuildCommand(build.build): - python setup.py bdist_wheel (which invokes bdist_wheel command) """ + def finalize_options(self): + build.build.finalize_options(self) + self.build_base = 'build_mlmd_tmp' + def _build_cc_extensions(self): return True From 2cc85d370a494568f08de911c91bd50d926cc6e5 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 14 May 2026 00:47:53 +0000 Subject: [PATCH 7/7] Remove Python 3.9 support, add Python 3.12 & 3.13 support in RELEASE.md --- .github/workflows/conda-build.yml | 2 +- .github/workflows/conda-test.yml | 2 +- README.md | 4 ++-- RELEASE.md | 4 ++++ setup.py | 3 +-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index 779349b48..24b2b9bcc 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout diff --git a/.github/workflows/conda-test.yml b/.github/workflows/conda-test.yml index 0bb2bcce0..4284fee22 100644 --- a/.github/workflows/conda-test.yml +++ b/.github/workflows/conda-test.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout diff --git a/README.md b/README.md index f25ad1b19..eb97566e3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ML Metadata -[![Python](https://img.shields.io/badge/python%7C3.9%7C3.10%7C3.11%7C3.12%7C3.13-blue)](https://github.com/google/ml-metadata) +[![Python](https://img.shields.io/badge/python%7C3.10%7C3.11%7C3.12%7C3.13-blue)](https://github.com/google/ml-metadata) [![PyPI](https://badge.fury.io/py/ml-metadata.svg)](https://badge.fury.io/py/ml-metadata) *ML Metadata (MLMD)* is a library for recording and retrieving metadata @@ -57,7 +57,7 @@ sudo docker compose build ${DOCKER_SERVICE} sudo docker compose run ${DOCKER_SERVICE} ``` -where `PY_VERSION` is one of `{39, 310, 311, 312, 313}`. +where `PY_VERSION` is one of `{310, 311, 312, 313}`. A wheel will be produced under `dist/`, and installed as follows: diff --git a/RELEASE.md b/RELEASE.md index 8dfea11de..f901747e8 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -2,8 +2,12 @@ ## Major Features and Improvements +* Added Python 3.12 and Python 3.13 support. + ## Breaking Changes +* Removed Python 3.9 support. + ## Deprecations * Deprecate ZetaSQL-based filter_query functionality. The `filter_query` diff --git a/setup.py b/setup.py index 0136e11ed..f2e809278 100644 --- a/setup.py +++ b/setup.py @@ -153,7 +153,6 @@ def run(self): 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', @@ -181,7 +180,7 @@ def run(self): # TODO: Pin versions for docs "docs": docs_reqs, }, - python_requires='>=3.9,<4', + python_requires='>=3.10,<4', packages=find_packages(), include_package_data=True, package_data={'': ['*.so', '*.pyd']},