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

Fix co-existence with riemann-client under py3 #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

huguesb
Copy link

@huguesb huguesb commented Jan 2, 2020

bernhard==0.2.6 and riemann-client==6.5.0 are incompatible under python 3.7 when the protobuf package is using the C++ implementation (as opposed to pure python). This is easily reproduced:

# python3
Python 3.7.6 (default, Dec 19 2019, 23:49:42)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from python_metrics.metric_emitter import Metric, MetricClosedError
>>> import bernhard
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/virtualenv/ml-serving/lib/python3.7/site-packages/bernhard/__init__.py", line 18, in <module>
    from . import proto_pb2 as pb
  File "/opt/virtualenv/ml-serving/lib/python3.7/site-packages/bernhard/proto_pb2.py", line 22, in <module>
    serialized_pb=_b('\n\x0bproto.proto\"\x81\x01\n\x05State\x12\x0c\n\x04time\x18\x01 \x01(\x03\x12\r\n\x05state\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x0c\n\x04once\x18\x06 \x01(\x08\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0b\n\x03ttl\x18\x08 \x01(\x02\"\xce\x01\n\x05\x45vent\x12\x0c\n\x04time\x18\x01 \x01(\x03\x12\r\n\x05state\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0b\n\x03ttl\x18\x08 \x01(\x02\x12\x1e\n\nattributes\x18\t \x03(\x0b\x32\n.Attribute\x12\x15\n\rmetric_sint64\x18\r \x01(\x12\x12\x10\n\x08metric_d\x18\x0e \x01(\x01\x12\x10\n\x08metric_f\x18\x0f \x01(\x02\"\x17\n\x05Query\x12\x0e\n\x06string\x18\x01 \x01(\t\"g\n\x03Msg\x12\n\n\x02ok\x18\x02 \x01(\x08\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x16\n\x06states\x18\x04 \x03(\x0b\x32\x06.State\x12\x15\n\x05query\x18\x05 \x01(\x0b\x32\x06.Query\x12\x16\n\x06\x65vents\x18\x06 \x03(\x0b\x32\x06.Event\"\'\n\tAttribute\x12\x0b\n\x03key\x18\x01 \x02(\t\x12\r\n\x05value\x18\x02 \x01(\tB\x1a\n\x11\x63om.aphyr.riemannB\x05Proto')
  File "/opt/virtualenv/ml-serving/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 884, in __new__
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "proto.proto":
  State.time: "State.time" is already defined in file "riemann.proto".
  State.state: "State.state" is already defined in file "riemann.proto".
  State.service: "State.service" is already defined in file "riemann.proto".
  State.host: "State.host" is already defined in file "riemann.proto".
  State.description: "State.description" is already defined in file "riemann.proto".
  State.once: "State.once" is already defined in file "riemann.proto".
  State.tags: "State.tags" is already defined in file "riemann.proto".
  State.ttl: "State.ttl" is already defined in file "riemann.proto".
  State: "State" is already defined in file "riemann.proto".
  Event.time: "Event.time" is already defined in file "riemann.proto".
  Event.state: "Event.state" is already defined in file "riemann.proto".
  Event.service: "Event.service" is already defined in file "riemann.proto".
  Event.host: "Event.host" is already defined in file "riemann.proto".
  Event.description: "Event.description" is already defined in file "riemann.proto".
  Event.tags: "Event.tags" is already defined in file "riemann.proto".
  Event.ttl: "Event.ttl" is already defined in file "riemann.proto".
  Event.attributes: "Event.attributes" is already defined in file "riemann.proto".
  Event.metric_sint64: "Event.metric_sint64" is already defined in file "riemann.proto".
  Event.metric_d: "Event.metric_d" is already defined in file "riemann.proto".
  Event.metric_f: "Event.metric_f" is already defined in file "riemann.proto".
  Event: "Event" is already defined in file "riemann.proto".
  Query.string: "Query.string" is already defined in file "riemann.proto".
  Query: "Query" is already defined in file "riemann.proto".
  Msg.ok: "Msg.ok" is already defined in file "riemann.proto".
  Msg.error: "Msg.error" is already defined in file "riemann.proto".
  Msg.states: "Msg.states" is already defined in file "riemann.proto".
  Msg.query: "Msg.query" is already defined in file "riemann.proto".
  Msg.events: "Msg.events" is already defined in file "riemann.proto".
  Msg: "Msg" is already defined in file "riemann.proto".
  Attribute.key: "Attribute.key" is already defined in file "riemann.proto".
  Attribute.value: "Attribute.value" is already defined in file "riemann.proto".
  Attribute: "Attribute" is already defined in file "riemann.proto".
  Event.attributes: "Attribute" seems to be defined in "riemann.proto", which is not imported by "proto.proto".  To use it here, please add the necessary import.
  Msg.states: "State" seems to be defined in "riemann.proto", which is not imported by "proto.proto".  To use it here, please add the necessary import.
  Msg.query: "Query" seems to be defined in "riemann.proto", which is not imported by "proto.proto".  To use it here, please add the necessary import.
  Msg.events: "Event" seems to be defined in "riemann.proto", which is not imported by "proto.proto".  To use it here, please add the necessary import.

Updating bernhard's proto.proto to use a package stanza, and re-running protoc solves this issue.

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.

None yet

1 participant