OptixLog Docs
Python SDKGenerated Bindings

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:

  1. OptixClient — a typed wrapper around SDKClient whose project() method is overloaded per project id. You construct it with no arguments; credentials are filled from ~/.optixlog/credentials.toml or environment variables.

  2. Projects — a namespace class of Literal-typed project-id constants. Use these instead of raw strings so your editor provides autocompletion and type checkers can resolve the correct overload.

  3. 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 a to_payload() method used internally by ingest.

optixlog_gen.py (abbreviated)
# 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 | LayoutNode

The 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

On this page