Skip to content

Upgrade to Protobuf v4.25.6 and Implement Custom Proto Build Rules#238

Open
czgdp1807 wants to merge 7 commits intogoogle:masterfrom
czgdp1807:proto_upgrade
Open

Upgrade to Protobuf v4.25.6 and Implement Custom Proto Build Rules#238
czgdp1807 wants to merge 7 commits intogoogle:masterfrom
czgdp1807:proto_upgrade

Conversation

@czgdp1807
Copy link
Collaborator

Summary

This PR upgrades ML Metadata to Protobuf v4.25.6 and gRPC v1.62.1, implementing custom Bazel proto library rules to replace deprecated protobuf.bzl macros. This modernizes the build system and ensures compatibility with the latest protobuf releases.

Changes Overview

1. Dependency Upgrades

  • Upgrade protobuf from v3.21.9 to v4.25.6
  • Upgrade gRPC from v1.46.3 to v1.62.1
  • Bump Bazel from 6.1.0 to 6.5.0 in Docker builds
  • Disable bzlmod to work around protobuf v4.25.6 compatibility issues

Files: WORKSPACE, .bazelrc, ml_metadata/tools/docker_server/Dockerfile

2. Custom Proto Library Implementation

  • Implement custom _py_proto_library_rule and cc_proto_library wrapper to replace deprecated @com_google_protobuf//:protobuf.bzl rules
  • Add ProtoDescriptorInfo provider for proto dependency management
  • Support gRPC Python stub generation with use_grpc_plugin parameter
  • Handle _virtual_imports paths and transitive proto dependencies
  • Update proto target references from _pb2.py suffix to _py_pb2 format

Files: ml_metadata/ml_metadata.bzl, ml_metadata/BUILD

3. Proto Dependency Updates

  • Replace deprecated cc_wkt_protos with explicit well-known type dependencies:
    • any_proto, struct_proto, descriptor_proto, field_mask_proto
  • Add missing @com_google_protobuf//:protobuf dependency to record_parsing_utils

Files: ml_metadata/proto/BUILD, ml_metadata/util/BUILD

4. Build Fixes

  • Add CMAKE_POLICY_VERSION_MINIMUM=3.5 to MySQL client build for CMake compatibility

Files: ml_metadata/libmysqlclient.BUILD

Backward Compatibility

All changes maintain API compatibility. Proto compilation outputs remain functionally identical, with only build system implementation differences.

Updates core dependencies to support newer features and bug fixes.
Adds --noenable_bzlmod flag to work around protobuf v4.25.6 bzlmod issues.
- Add ProtoDescriptorInfo provider for proto descriptor files
- Implement custom _py_proto_library_impl to handle proto compilation
- Add proto_descriptor helper rule
- Support gRPC plugin for service generation
- Handle _virtual_imports paths from dependencies

This replaces the deprecated protobuf.bzl rules with custom implementations
compatible with protobuf v4.
Changes proto library references from _pb2.py to _py_pb2 format
to align with protobuf v4 naming conventions.
Ensures CMake compatibility by explicitly setting minimum policy version.
- Replace cc_wkt_protos with explicit proto targets (any_proto, struct_proto, descriptor_proto, field_mask_proto)
- Add missing protobuf dependency to record_parsing_utils
- Bump Bazel version from 6.1.0 to 6.5.0 in Dockerfile

These changes ensure compatibility with protobuf v4.25.6's new dependency structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant