Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

rb_flat_buffers

rb_flat_buffers는 schemas/*.fbs로부터 생성된 Python FlatBuffer 코드 패키지입니다.

핵심 요약

  • 소스 스키마: /schemas/**/*.fbs
  • 생성 결과 1: backend/packages/rb_flat_buffers/src/rb_flat_buffers/** (FlatBuffer Python generated code)
  • 생성 결과 2: backend/packages/rb_schemas/src/rb_schemas/fbs_models/** (Pydantic 모델)

즉, make backend.flatc를 실행하면:

  1. FlatBuffer Python 코드가 rb_flat_buffers에 생성되고
  2. 동일 스키마 기반 Pydantic 모델이 rb_schemas에 생성됩니다.

생성 방법

프로젝트 루트에서:

make backend.flatc

backend.mk의 backend.flatc 타깃은 내부적으로 아래를 순서대로 실행합니다.

  1. scripts/backend/generate_flatbuffers.py
  • flatc --python --gen-object-api --gen-all 기반 생성
  • 출력: backend/packages/rb_flat_buffers/src/rb_flat_buffers
  1. backend/packages/rb_flat_buffers/scripts/patch_imports.py
  • generated import 경로/누락 import 보정
  1. scripts/backend/fbs_to_pydantic.py
  • .fbs를 Pydantic 모델로 변환
  • 출력: backend/packages/rb_schemas/src/rb_schemas/fbs_models

언제 실행해야 하나

아래 케이스에서는 make backend.flatc를 다시 실행해야 합니다.

  • schemas/*.fbs 수정
  • 신규 .fbs 파일 추가/삭제
  • FlatBuffer 타입/필드 변경(table/struct/enum/union)

rb_flat_buffers 사용 예시

예: 요청 객체 전송 + 값이 채워진 FlatBuffer 응답(returnValue) 수신

# server/queryable 쪽
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)  # 요청으로 전달된 값 사용 가능
    res = Response_FunctionsT()
    res.returnValue = 123  # 빈 payload가 아니라 실제 값 포함
    return res
# client/query 쪽
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) 사용 예시

query_one 응답의 obj_payload를 Pydantic으로 validate한 뒤, model_dump에서 원하는 key case를 선택할 수 있습니다.

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) FlatBuffer T 객체 -> 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) 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

주의사항

  • 패키지명은 rb_flat_buffers입니다. (rb_flat_buffer 아님)
  • generated 파일은 수동 수정하지 않는 것을 권장합니다.
  • flatc가 PATH에 없으면 make backend.flatc가 실패합니다.

Metadata

Release files for rainbow-rb-flat-buffers 0.1.2.dev4

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.1.2.dev4
File Size Uploaded Provenance Actions
rainbow_rb_flat_buffers-0.1.2.dev4.tar.gz 465.5 kB Without provenance Details for rainbow_rb_flat_buffers-0.1.2.dev4.tar.gz

Built distribution (wheel)

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

Total release size: 1.9 MB

Release files / rainbow_rb_flat_buffers-0.1.2.dev4.tar.gz

Download URL rainbow_rb_flat_buffers-0.1.2.dev4.tar.gz
Size 465.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f22fea93012d5a2e567254ceb1350742ff5f1bca9d53b5f2f2222406daad01ee
BLAKE2b-256 checksum
How to use checksums
6a5c07493c0db6534efa113e2b72ba010749179f210c0135c6eec3ec4aab74da
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.1.2.dev4-py3-none-any.whl

Download URL rainbow_rb_flat_buffers-0.1.2.dev4-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
31d792dc5210a68e155f5e77c5515b045727579393df5e5000c311b237b19573
BLAKE2b-256 checksum
How to use checksums
c68577b3dd9d834768f3165975befca2314efdcbc48a88d9812ad5ccc6f4aad5
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.1.2.dev4

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