Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add to_proto to descriptor classes #19971

Closed
wants to merge 12 commits into from

Conversation

y-yagi
Copy link
Contributor

@y-yagi y-yagi commented Jan 12, 2025

Some APIs (e.g. BigQuery Storage) use DescriptorProto for schema descriptions. But, in Ruby, there are no methods for that so far.

This PR implements the method for that(to_proto) to descriptor classes.

Fixes #12044.

@y-yagi y-yagi requested review from a team as code owners January 12, 2025 06:20
@y-yagi y-yagi requested review from JasonLunn and bshaffer and removed request for a team January 12, 2025 06:20
@mkruskal-google mkruskal-google added ruby jruby Issues unique to the JRuby interpreter 🅰️ safe for tests Mark a commit as safe to run presubmits over labels Jan 23, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 23, 2025
@mkruskal-google mkruskal-google removed the request for review from bshaffer January 23, 2025 20:15
@y-yagi y-yagi force-pushed the add_to_proto_to_descriptors branch from 9f2cd99 to 964ec01 Compare January 24, 2025 02:00
@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 24, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 24, 2025
@JasonLunn
Copy link
Contributor

Thanks for contributing this PR, @y-yagi!

The tests are really close to passing, but there seems to be an issue on macOS. Both the Ruby 3.0 and Ruby 3.4 tests are failing on macOS with a failure like this:

Error: test_enum_descriptor_to_proto(BasicTest::MessageContainerTest): Google::Protobuf::ParseError: Error occurred during parsing
/private/var/tmp/_bazel_runner/88067fd1245450c0f2a417255e46b72b/sandbox/darwin-sandbox/1336/execroot/com_google_protobuf/bazel-out/darwin_x86_64-fastbuild/bin/ruby/tests/basic.runfiles/com_google_protobuf/ruby/tests/basic.rb:701:in 'Google::Protobuf::EnumDescriptor#to_proto'
/private/var/tmp/_bazel_runner/88067fd1245450c0f2a417255e46b72b/sandbox/darwin-sandbox/1336/execroot/com_google_protobuf/bazel-out/darwin_x86_64-fastbuild/bin/ruby/tests/basic.runfiles/com_google_protobuf/ruby/tests/basic.rb:701:in 'BasicTest::MessageContainerTest#test_enum_descriptor_to_proto'
     698:     def test_enum_descriptor_to_proto
     699:       enum_descriptor = TestDeprecatedEnum.descriptor
     700: 
  => 701:       assert_instance_of Google::Protobuf::EnumDescriptorProto, enum_descriptor.to_proto
     702:     end
     703: 

The same tests are passing on Linux and under FFI on the macOS, and the other descriptor tests are working as expected - it is just enum descriptor test without FFI that is having an issue. I'm going to re-run the tests now to see if the test failures are stable or if the tests are flaky.

Do you have a macOS machine available to troubleshoot this on in the meantime?

@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 24, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 24, 2025
ruby/ext/google/protobuf_c/defs.c Outdated Show resolved Hide resolved
ruby/ext/google/protobuf_c/defs.c Show resolved Hide resolved
@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 26, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 26, 2025
@y-yagi y-yagi force-pushed the add_to_proto_to_descriptors branch from 51e54e3 to 1afd9e8 Compare January 27, 2025 07:40
@y-yagi
Copy link
Contributor Author

y-yagi commented Jan 27, 2025

I'm doubting I released an arena too early. So I fixed the timing of it. 1afd9e8

@acozzette acozzette added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 30, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 30, 2025
@y-yagi

This comment was marked as resolved.

There is the same name function in `upb/util/def_to_proto.c`.
https://github.com/protocolbuffers/protobuf/blob/c8ad77475634f77468cd237dd10bcff978a2372a/upb/util/def_to_proto.c#L57

The amalgamation merges `upb` files into one file. So, it causes
a compile error when the functions have the same name.
@y-yagi y-yagi force-pushed the add_to_proto_to_descriptors branch from 1afd9e8 to 8d50ae2 Compare January 31, 2025 08:58
@y-yagi
Copy link
Contributor Author

y-yagi commented Jan 31, 2025

I've rebased with the latest code.

@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 31, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 31, 2025
@JasonLunn JasonLunn self-requested a review February 4, 2025 16:07
@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Feb 4, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Feb 4, 2025
copybara-service bot pushed a commit that referenced this pull request Feb 4, 2025
Some APIs (e.g. [BigQuery Storage](https://github.com/googleapis/googleapis/blob/ab61c52324b39d1c8619a96ab19cc6c173b13f2c/google/cloud/bigquery/storage/v1/protobuf.proto#L39)) use DescriptorProto for schema descriptions. But,  in Ruby, there are no methods for that so far.

This PR implements the method for that(`to_proto`) to descriptor classes.

Fixes #12044.

Closes #19971

FUTURE_COPYBARA_INTEGRATE_REVIEW=#19971 from y-yagi:add_to_proto_to_descriptors 8d50ae2
PiperOrigin-RevId: 723099882
copybara-service bot pushed a commit that referenced this pull request Feb 4, 2025
Some APIs (e.g. [BigQuery Storage](https://github.com/googleapis/googleapis/blob/ab61c52324b39d1c8619a96ab19cc6c173b13f2c/google/cloud/bigquery/storage/v1/protobuf.proto#L39)) use DescriptorProto for schema descriptions. But,  in Ruby, there are no methods for that so far.

This PR implements the method for that(`to_proto`) to descriptor classes.

Fixes #12044.

Closes #19971

FUTURE_COPYBARA_INTEGRATE_REVIEW=#19971 from y-yagi:add_to_proto_to_descriptors 8d50ae2
PiperOrigin-RevId: 723117256
copybara-service bot pushed a commit that referenced this pull request Feb 4, 2025
Some APIs (e.g. [BigQuery Storage](https://github.com/googleapis/googleapis/blob/ab61c52324b39d1c8619a96ab19cc6c173b13f2c/google/cloud/bigquery/storage/v1/protobuf.proto#L39)) use DescriptorProto for schema descriptions. But,  in Ruby, there are no methods for that so far.

This PR implements the method for that(`to_proto`) to descriptor classes.

Fixes #12044.

Closes #19971

FUTURE_COPYBARA_INTEGRATE_REVIEW=#19971 from y-yagi:add_to_proto_to_descriptors 8d50ae2
PiperOrigin-RevId: 723117256
copybara-service bot pushed a commit that referenced this pull request Feb 4, 2025
Some APIs (e.g. [BigQuery Storage](https://github.com/googleapis/googleapis/blob/ab61c52324b39d1c8619a96ab19cc6c173b13f2c/google/cloud/bigquery/storage/v1/protobuf.proto#L39)) use DescriptorProto for schema descriptions. But,  in Ruby, there are no methods for that so far.

This PR implements the method for that(`to_proto`) to descriptor classes.

Fixes #12044.

Closes #19971

FUTURE_COPYBARA_INTEGRATE_REVIEW=#19971 from y-yagi:add_to_proto_to_descriptors 8d50ae2
PiperOrigin-RevId: 723117256
@copybara-service copybara-service bot closed this in 74122eb Feb 4, 2025
@y-yagi y-yagi deleted the add_to_proto_to_descriptors branch February 5, 2025 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jruby Issues unique to the JRuby interpreter ruby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ruby: Convert Descriptor to DescriptorProto
4 participants