Skip to main content

Utilities for working with Protobuf & gRPC in Python.

Project description

Protoplasm

Utilities for working with Protobuf & gRPC in Python, e.g; compiling Python 3 Dataclasses from compiled proto-message-python code and casting between the two, quickly initializing large/nested Protobuf object, simplifying gRPC service interfaces etc.

IMPORTANT

Update this README file after moving from CCP's internal code repo to Github.

Protoplasm 4

  • Unify the unary functionality of Protoplasm 2 with the streaming functionality of Protoplasm 3
    • The two turn out to be completely incompatible and API shattering
    • Protoplasm 4 must incorporate BOTH functionalities wile being backwards compatible enough for both Protoplasm 2 and 3 projects to be able to migrate to 4
    • The key here is detecting the stream keyword in protos that denote streaming input and/or output
  • Add piled up functionality/utility/QoL improvements/bugs that's been on The List™ for a while
    • Cast to/from base64 encoded strings
    • Utilize the __all__ directive to isolate import * side effects
    • Integrate the Neobuf Builder CLI (from various other projects) into Protoplasm and generalize it
    • Address the "None is default value" issue
    • Explore the pros/cons of making non-existing Message/Object attributes return Empty or EmptyDict to simplify nested attribute fetching...?
  • Refactor and restructure the package properly
    • Separate the 4 main roles of the package logically
      1. Cross-piling *.proto to *_pb2.py and *_pb2_grpc.py
      2. Cross-piling *_pb2.py to *_dc.py Neobuf Dataclasses
      3. Generating *_api.py interfaces
      4. Generating gRPC implementation of Services

Troubleshooting

  • I get TypeError: Plain typing.NoReturn is not valid as type argument

Clever bits to document...

  • Code Generation (e.g. foo.proto) + how to build
    • Dataclasses -> foo_dc.py + how to use (+ DataclassBase freebies)
      • Extending Dataclasses (a no-no for pb2 files apparently)
    • Service API -> foo_api.py + how to use and implement
      • Automatic parameter unpacking
      • Return value packing
      • Raising protoplasm.errors.api.* on errors or non-ok returns
      • Using protoplasm.decorators for param and type checking
      • The takes_context decorator and how to use it
    • GRPC DC Service Servicer -> foo_dc_grpc.py + how to use
  • Utilities
    • Proto <-> dict <-> Dataclass casters
    • The mkproto and mkdataclass helpers
    • The unpack_dataclass_request and pack_dataclass_response helpers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protoplasm-5.2.0.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

protoplasm-5.2.0-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file protoplasm-5.2.0.tar.gz.

File metadata

  • Download URL: protoplasm-5.2.0.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for protoplasm-5.2.0.tar.gz
Algorithm Hash digest
SHA256 9b741b5e1374274d6d7d3e84930d1d3e0cb9d14b2a748088823907a1d901779d
MD5 fecb42d84d7f316fab7eecca3540cb26
BLAKE2b-256 e69a2c80504e3ef42b40eab3645460a8c39a7a4f3bea1531c306f26ccd4274e7

See more details on using hashes here.

File details

Details for the file protoplasm-5.2.0-py3-none-any.whl.

File metadata

  • Download URL: protoplasm-5.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for protoplasm-5.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ace08612adc8d9451a23e11bf7cfe1687c027fd4c165664f10bc7d51e992431
MD5 f6d9257e6fe36e892e6530810cb55355
BLAKE2b-256 710988851475b0bf7666314ad2f90fa30d7d466c4aadbd85b050ff1c4ab0fa7c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page