Skip to main content

rb_flat_buffers

rb_flat_buffers is a package of Python FlatBuffer code generated from schemas/*.fbs.

Summary

  • Source schemas: /schemas/**/*.fbs
  • Generated output 1: backend/packages/rb_flat_buffers/src/rb_flat_buffers/** (FlatBuffer Python generated code)
  • Generated output 2: backend/packages/rb_schemas/src/rb_schemas/fbs_models/** (Pydantic models)

In other words, running make backend.flatc:

  1. Generates the FlatBuffer Python code into rb_flat_buffers, and
  2. Generates Pydantic models based on the same schemas into rb_schemas.

How to Generate

From the project root:

make backend.flatc

The backend.flatc target in backend.mk internally runs the following in order.

  1. scripts/backend/generate_flatbuffers.py
  • Generates code using flatc --python --gen-object-api --gen-all
  • Output: backend/packages/rb_flat_buffers/src/rb_flat_buffers
  1. backend/packages/rb_flat_buffers/scripts/patch_imports.py
  • Fixes generated import paths and adds missing imports
  1. scripts/backend/fbs_to_pydantic.py
  • Converts .fbs files into Pydantic models
  • Output: backend/packages/rb_schemas/src/rb_schemas/fbs_models

When to Run It

You must re-run make backend.flatc in the following cases.

  • schemas/*.fbs is modified
  • New .fbs files are added or deleted
  • FlatBuffer types/fields change (table/struct/enum/union)

rb_flat_buffers Usage Example

Example: sending a request object + receiving a FlatBuffer response with populated values (returnValue)

# server/queryable side
from rb_flat_buffers.IPC.Request_Move_SmoothJogStop import Request_Move_SmoothJogStopT
from rb_flat_buffers.IPC.Response_Functions import Response_FunctionsT
from rb_zenoh.router import ZenohRouter

router = ZenohRouter()

@router.queryable(
    "C500920/call_smoothjog_stop",
    flatbuffer_req_t=Request_Move_SmoothJogStopT,
    flatbuffer_res_buf_size=64,
)
def on_call_pause(req, params=None):
    print(req.stoptime)  # values passed in the request are available
    res = Response_FunctionsT()
    res.returnValue = 123  # contains an actual value, not an empty payload
    return res
# client/query side
from rb_flat_buffers.IPC.Request_Move_SmoothJogStop import Request_Move_SmoothJogStopT
from rb_flat_buffers.IPC.Response_Functions import Response_FunctionsT
from rb_zenoh.client import ZenohClient

client = ZenohClient()
req = Request_Move_SmoothJogStopT()
req.stoptime = 0.7

res = client.query_one(
    "C500920/call_smoothjog_stop",
    flatbuffer_req_obj=req,
    flatbuffer_res_T_class=Response_FunctionsT,
    flatbuffer_buf_size=64,
)

obj = res.get("obj_payload")
print(obj.returnValue)  # 123

rb_schemas (Pydantic) Usage Example

After validating the obj_payload of a query_one response with Pydantic, you can choose the desired key case in model_dump.

from rb_flat_buffers.IPC.Response_Functions import Response_FunctionsT
from rb_schemas.fbs_models.nexus.v1.deploy_models import Response_Deploy_UploadPD
from rb_utils.parser import t_to_dict
from rb_zenoh.client import ZenohClient

client = ZenohClient()

res = client.query_one(
    "deploy/call_upload",
    flatbuffer_res_T_class=Response_FunctionsT,
    timeout=0.3,
)

obj_payload = res.get("obj_payload")

# 1) Convert FlatBuffer T object -> dict
raw_dict = t_to_dict(obj_payload) if obj_payload is not None else {}

# 2) Pydantic validate
pd_obj = Response_Deploy_UploadPD.model_validate(raw_dict)

# 3) Choose key case
snake_case = pd_obj.model_dump(by_alias=False)  # ex) return_value
camel_case = pd_obj.model_dump(by_alias=True)   # ex) returnValue

Notes

  • The package name is rb_flat_buffers (not rb_flat_buffer).
  • Manually editing generated files is not recommended.
  • make backend.flatc fails if flatc is not on the PATH.

Metadata

Release files for rainbow-rb-flat-buffers 0.10.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rainbow-rb-flat-buffers 0.10.4
File Size Uploaded Provenance Actions
rainbow_rb_flat_buffers-0.10.4.tar.gz 496.2 kB Without provenance Details for rainbow_rb_flat_buffers-0.10.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rainbow-rb-flat-buffers 0.10.4
File Interpreter ABI Platform Actions
rainbow_rb_flat_buffers-0.10.4-py3-none-any.whl Python 3 none any Details for rainbow_rb_flat_buffers-0.10.4-py3-none-any.whl

Total release size: 2.0 MB

Release files / rainbow_rb_flat_buffers-0.10.4.tar.gz

Download URL rainbow_rb_flat_buffers-0.10.4.tar.gz
Size 496.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3c4b4f83234fc8983669e7c91a9df1813b8fa0e2b353343b5d7d9c56d302a857
BLAKE2b-256 checksum
How to use checksums
b6c090a6a1332188322d3f8f8994aff3ab3886d8f220b06796cb13e14606cd75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / rainbow_rb_flat_buffers-0.10.4-py3-none-any.whl

Download URL rainbow_rb_flat_buffers-0.10.4-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
dbe9720ffe749e29f50d2f7a6aece8f520e96cbacc804de39f4120e646a00cf5
BLAKE2b-256 checksum
How to use checksums
be561134befbaceea282e45d5f4ae8cf5efb7915d83f49c4489c97548c0fdb27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for rainbow-rb-flat-buffers 0.10.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page