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

Update Protobuf to 3.12+ - Fields with default value not set in deltas #3589

Closed
dwsutherland opened this issue May 3, 2020 · 3 comments · Fixed by #3594
Closed

Update Protobuf to 3.12+ - Fields with default value not set in deltas #3589

dwsutherland opened this issue May 3, 2020 · 3 comments · Fixed by #3594
Assignees
Labels
Milestone

Comments

@dwsutherland
Copy link
Member

dwsutherland commented May 3, 2020

Problem:
(from Riot)

Scalar fields like bool, int, string (...etc) have default values (False, 0, “”), however , at the receiving end you cannot tell whether a field was intentionally set to the default...

For example:

>>> from cylc.flow.data_messages_pb2 import PbWorkflow
>>> var1 = PbWorkflow(id='foo', host='', port=0)
>>> var1.ListFields()
[(<google.protobuf.pyext._message.FieldDescriptor object at 0x7fa3ac80edd0>, 'foo')]
>>> var1
id: "foo"

I posted my frustrations in a long standing issue here:
protocolbuffers/protobuf#359
(This changed with proto2 => proto3)

This means things like latestMessage, isHeldTotal, port (etc..) have to either always send the data value from UIS data-store or only send the non-default... Unacceptable, as there’s no option in proto3 to have alternate defaults...

I/we don’t want clunky workarounds..

Solution(s):

  1. A developer from Protobuf responded (fairly quickly);
    default values and testing if a field is set in v3 protocolbuffers/protobuf#359 (comment)
    and referenced an upcoming release feature to fix this:
    https://github.com/protocolbuffers/protobuf/blob/master/docs/field_presence.md
    (which looks like it's in master)
syntax = "proto3";
package example;

message MyMessage {
  // No presence:
  int32 not_tracked = 1;

  // Explicit presence:
  optional int32 tracked = 2;
}

With the protoc run with option --experimental_allow_proto3_optional..
This is suppose to be available via release from 3.12 or later..

  1. I don’t think it’ll be hard to change (heck we could probably even pickle GraphQL ObjectTypes if we wanted or just use dict)..

This issue came to light when working with the delta subscription PRs:
#3500
cylc/cylc-uiserver#118
And can be addressed at any point with option 1) (and the availability of protobuf=3.12.*), however anything more drastic should wait until after they go in.

Pull requests welcome!
This is an Open Source project - please consider contributing a bug fix
yourself (please read CONTRIBUTING.md before starting any work though).

@dwsutherland dwsutherland added this to the cylc-8.0a3 milestone May 3, 2020
@dwsutherland dwsutherland self-assigned this May 3, 2020
@dwsutherland
Copy link
Member Author

I would vote for option 1), and wait for the relevant Protobuf "fix"..

Then if we come across any other major roadblocks/undesirables, investigate 2).

@dwsutherland
Copy link
Member Author

New release out:
https://github.com/protocolbuffers/protobuf/releases/tag/v3.12.0-rc1

Tested and solves this issue with fields as optional.. However I did report an issue:
protocolbuffers/protobuf#7463

@kinow
Copy link
Member

kinow commented May 4, 2020

Tested and solves this issue with fields as optional.. However I did report an issue:

I think they should be quite quick fixing this one too. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants