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

Relax protobuf<5.0.0 restriction #6888

Merged
merged 1 commit into from
Aug 9, 2024
Merged

Conversation

groszewn
Copy link
Contributor

@groszewn groszewn commented Aug 7, 2024

Instead of restricting protobuf<5.0.0 due to the removal to including_default_value_fields kwarg in json_format.MessageToJson (replaced by always_print_fields_with_nopresence), we can instead detect the currently installed protobuf version and use the appropriate kwarg.

Contributes to #6808 and should resolve #6887.

@groszewn groszewn force-pushed the protobuf5 branch 3 times, most recently from de0d9c9 to 39460eb Compare August 7, 2024 14:37
@groszewn groszewn marked this pull request as ready for review August 7, 2024 15:04
@groszewn groszewn requested a review from arcra August 7, 2024 15:04
experiment_id,
request_proto,
).run()
current_protobuf_version = importlib_version("protobuf")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a util that we can use as a one-line call in all of these places, and abstract this detail away.

It's annoying that we'd need a separate file and all the overhead of the build file and all, but I think it's a more maintainable solution and results in cleaner code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a plugin_util module, so I added it there (and added some tests).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not being clear. I was thinking more like a "proto_to_json" method, so the package checking is abstracted away from the code that just needs to convert the proto to a string, and the code elsewhere can be just a one-line method call. Sorry for the churn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to just have a proto_to_json method, but I've only used it for these two specific instances that use a deprecated field conditionally. There are probably other calls to MessageToJson throughout the codebase that don't need the conditional handling, but avoiding touching those as part of this PR.

# NOTE: this version must be >= the protoc version in our WORKSPACE file.
# At the same time, any constraints we specify here must allow at least some
# version to be installed that is also compatible with TensorFlow's constraints:
# https://github.com/tensorflow/tensorflow/blob/25adc4fccb4b0bb5a933eba1d246380e7b87d7f7/tensorflow/tools/pip_package/setup.py#L101
# 4.24.0 had an issue that broke our tests, so we should avoid that release:
# https://github.com/protocolbuffers/protobuf/issues/13485
# 5.26.0 introduced a breaking change, so we restricted it for now. See issue #6808 for details.
protobuf >= 3.19.6, != 4.24.0, < 5.0.0
protobuf >= 3.19.6, != 4.24.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should add a TODO or a comment somewhere, to remove the packaging dependency and restrict this to >= 5.0.0 after it's been available for a while or something?

I worry that if at some point we remove this logic to check for protobuf version, we won't realize that we also could remove the packaging dependency, as it was only used there. Maybe there is some tooling that would let us know this... maybe we can add a small comment right next to that package. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, added a comment specifying that if we bump protobuf >= 5.0.0, we can also remove the packaging dependency.

@groszewn groszewn force-pushed the protobuf5 branch 4 times, most recently from de4c2b1 to 5245f9b Compare August 9, 2024 18:20
Instead of restricting `protobuf<5.0.0` due to the removal to
`including_default_value_fields` kwarg in `json_format.MessageToJson`
(replaced by `always_print_fields_with_nopresence`), we can instead
detect the currently installed protobuf version and use the appropriate
kwarg.

Contributes to tensorflow#6808 and should resolve tensorflow#6887.
@groszewn groszewn merged commit 0627ad5 into tensorflow:master Aug 9, 2024
13 checks passed
@groszewn groszewn deleted the protobuf5 branch August 9, 2024 19:07
groszewn added a commit to groszewn/tensorboard that referenced this pull request Aug 13, 2024
Instead of restricting `protobuf<5.0.0` due to the removal to
`including_default_value_fields` kwarg in `json_format.MessageToJson`
(replaced by `always_print_fields_with_nopresence`), we can instead
detect the currently installed protobuf version and use the appropriate
kwarg.

Contributes to tensorflow#6808 and should resolve tensorflow#6887.
groszewn added a commit that referenced this pull request Aug 13, 2024
Instead of restricting `protobuf<5.0.0` due to the removal to
`including_default_value_fields` kwarg in `json_format.MessageToJson`
(replaced by `always_print_fields_with_nopresence`), we can instead
detect the currently installed protobuf version and use the appropriate
kwarg.

Contributes to #6808 and should resolve #6887.
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.

Bump Tensorboard to protobuf 5
2 participants