-
Notifications
You must be signed in to change notification settings - Fork 0
Protobuf wrappers guideline
-
As a general rule, files should be mapped like
x/y/z.proto
->x/y/_z.py
. -
A python package file should be added to export all symbols in individual files, for example: if there is
x/y/_z.py
with message/classZ
,x/y/_v.py
with enumV
, andx/y/_w.py
with messageW
, the filex/y/__init__.py
should re-exportZ
,V
andW
. -
If it is the only file in the
x/y/
directory (and thus is the only content of protobuf packagex.y
), then the file (for examplex/y/z.proto
) should be converted instead directly into one python module:x/y.py
. -
If a symbol in package
x.y.pkg
starts withpkg
, likePkgInfo
, then the python symbol should be named without the prefix (Info
), unless it is fundamental to the name. -
Wrappers in
frequenz-client-common-python
andfrequenz-client-base-python
target API client developers, not end users. In general the wrappers should be suitable for end user consumption, but there might be wrappers that clients should never export because they are just implementation details, likepagination
. -
Because of the above, client repos should re-export wrappers in the
frequenz-client-common-python
andfrequenz-client-base-python
repos when appropriate, they should never require the user to declare the dependency offrequenz-client-common-python
orfrequenz-client-base-python
manually, or to import stuff fromfrequenz.client.common
orfrequenz.client.base
directly. -
The functions to convert from/to protobuf to a wrapper should not be part of the wrapper classes, as we don't want to expose the protobuf internals to the users, instead they should be free functions in a separate module, following the pattern
<module>_proto.py