load(), then
drives it one step at a time for as long as clients are connected.
ReactorModel and ReactorPipeline are the old names for this class. Both still import, with a
deprecation warning.
Declarations
InputState subclass
Annotate a subclass of
InputState to
give clients a set_<field> command per public field. The live instance is self.state, rebuilt
each session and None between sessions.MediaInput subclass
Annotate a subclass of
MediaInput to receive
tracks from clients. Found by its type, so the attribute name is yours; media is the
convention.float
default:"30.0"
Pin the playout rate. Leave it at the default and each chunk plays over the time its step took.
int | None
default:"None"
How many frames may sit between the model and each client.
None accepts the runtime’s own
bound. Never applied below one emitted batch.Runtime handles
Two attributes the runtime binds on your instance. Read them from anywhere: a step, a command handler, a lifecycle hook, or your ownrun().
OutputStream
The handle onto playout. Change the frame rate, or cut what is queued so nothing from the old
scene plays after a jump. See
OutputStream.asyncio.Event
Set while at least one client is connected, cleared when the last one leaves. Await it to hold
work back until a client is connected.
Methods you write
None
Runs once at startup, before any client connects. Load weights here.
config_path is the file
named by runtime.config in reactor.yaml, or None when none is configured.Any
Optional and
async. Returns whatever generate() should receive, or raises
ApplicationError to skip the step. Defaults to returning self.state.Any
One step of inference, synchronous. Returns the result, or raises when the step is invalid for
the model. The default
run() calls it, so you write either this or your own run().Output | None
Optional and
async. Receives a StepOutcome and returns the Output to
stream, or None. Defaults to re-raising an error and otherwise calling outcome.to_output().None
The loop that drives the three calls above. Override it to write your own; see
Controlling the loop.
Methods you call
None
Put an
Output on the tracks. Called for you by the default loop; call it yourself only from a
hand-written run().None
Send a
ModelMessage to every connected
client.