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.11.12

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.11.12
File Size Uploaded Provenance Actions
rainbow_rb_flat_buffers-0.11.12.tar.gz 580.8 kB Without provenance Details for rainbow_rb_flat_buffers-0.11.12.tar.gz

Built distribution (wheel)

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

Total release size: 2.4 MB

Release files / rainbow_rb_flat_buffers-0.11.12.tar.gz

Download URL rainbow_rb_flat_buffers-0.11.12.tar.gz
Size 580.8 kB
Tags Source
SHA-256 checksum
How to use checksums
22824e025325035baa6f10b9db3235add4172411c90c8b38428614a5d80c8711
BLAKE2b-256 checksum
How to use checksums
9c783b2bd6f247313d7736a36af1e073985691b3f0ec71cbe8413f5992a2b2fb
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.11.12-py3-none-any.whl

Download URL rainbow_rb_flat_buffers-0.11.12-py3-none-any.whl
Size 1.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a98d429a38e53d0b3307b0e8f8d077d0b01a5b762306a9ebf74e8084e6ef0437
BLAKE2b-256 checksum
How to use checksums
3d0bf392009505fe96e061a9f94c96739e9f65e54f230462b8f0d46636c50d25
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.11.12

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.11.12 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