-
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.pywith message/classZ,x/y/_v.pywith enumV, andx/y/_w.pywith messageW, the filex/y/__init__.pyshould re-exportZ,VandW. -
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.pkgstarts 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-pythonandfrequenz-client-base-pythontarget 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-pythonandfrequenz-client-base-pythonrepos when appropriate, they should never require the user to declare the dependency offrequenz-client-common-pythonorfrequenz-client-base-pythonmanually, or to import stuff fromfrequenz.client.commonorfrequenz.client.basedirectly. -
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