Generated Bindings
What optixlog generate emits and how the typed client, project constants, and per-project node classes work together.
optixlog generate reads your organization's schema contract and emits a single typed Python module (default optixlog_gen.py, or a package directory). Every time your schema changes, you re-run the command and commit the updated file.
What the module contains
The generated module exposes three things:
-
OptixClient— a typed wrapper aroundSDKClientwhoseproject()method is overloaded per project id. You construct it with no arguments; credentials are filled from~/.optixlog/credentials.tomlor environment variables. -
Projects— a namespace class ofLiteral-typed project-id constants. Use these instead of raw strings so your editor provides autocompletion and type checkers can resolve the correct overload. -
Per-project typed node classes — one
@dataclass(frozen=True, kw_only=True)per node type defined in your schema. Each class has typed fields derived from the schema and ato_payload()method used internally byingest.
# AUTOGENERATED by `optixlog generate` — DO NOT EDIT BY HAND.
# Regenerate after a schema change with: optixlog generate
# ruff: noqa
@dataclass(frozen=True, kw_only=True)
class SimulationNode:
config: Mapping[str, JSONValue]
solver: Literal["fdtd", "eme", "varfdtd"]
wavelength_nm: float = 1550.0
other_param: str | None = None
def to_payload(self) -> dict[str, JSONValue]: ...
class Projects:
GRATING_COUPLER_LAB: Literal["proj_grating_7f3a"] = "proj_grating_7f3a"
MODULATOR_PROGRAM: Literal["proj_modulator_22b1"] = "proj_modulator_22b1"
class OptixClient:
def __init__(self, *, base_url: str | None = None, api_key: str | None = None, **kw) -> None: ...
def project(self, id: Literal["proj_grating_7f3a"]) -> _Project_proj_grating_7f3a: ...
def project(self, id: Literal["proj_modulator_22b1"]) -> _Project_proj_modulator_22b1: ...
@property
def sdk(self) -> SDKClient: ...
def close(self) -> None: ...How OptixClient wraps SDKClient
OptixClient is not a subclass of SDKClient — it wraps one. Internally it instantiates an SDKClient and a Pipeline, both driven by the same credentials. The sdk property exposes the underlying SDKClient when you need the Management API or other low-level access.
from optixlog_gen import OptixClient, Projects, SimulationNode
client = OptixClient() # fills base_url + api_key from saved login or env
grating = client.project(Projects.GRATING_COUPLER_LAB)
result = grating.ingest(
data=SimulationNode(config={"mesh": "fine"}, solver="fdtd"),
prompt="Simulated a grating coupler.",
)
client.close()Per-project union types
Each project has a union alias (private to the module) that lists exactly the node types its schema declares:
_GratingCouplerLabNodes = SimulationNode | MeasurementNode
_ModulatorProgramNodes = SimulationNode | LayoutNodeThe ingest overloads on each project's wrapper class accept only that union, making it a static type error to pass a node type not in the project's schema.
Pages in this section
Using the Typed Client
OptixClient constructor, project() overloads, .sdk escape hatch, and close().
Node Classes
How frozen dataclasses are generated from schema fields, with to_payload() and universal fields.
Type-Safety Guarantees
Why passing the wrong node type to a project is a static error in pyright and mypy.
Single File vs. Package
Choose between a single optixlog_gen.py and a package directory for larger schemas.