Execution Modes
A pipeline runs in one of two ways. In realtime, samples pass through as they are acquired, until you stop it. In batch, a recording passes through once, as one block, and the result comes back. The sources decide which, and a pipeline whose sources disagree is refused before anything runs.
Realtime
Every live source is realtime – the Generator, the amplifiers,
LslReceiver – and so is a recording reader unless you say otherwise:
it paces its samples out as if they were arriving now. p.start() returns at
once (0.12 s in a measured run), because the sources run on threads of their
own, and the pipeline keeps running until p.stop(). Data moves in frames of
a few samples, and a pipeline may have many sources, merged by a
Router or an Equation.
Batch
A recording reader created with mode="batch" makes the pipeline a batch
pipeline, and p.run() drives it instead of p.start():
p = gp.Pipeline()
reader = gp.CsvReader(file_name="rec.csv", mode="batch")
collector = gp.Collector()
p.connect(reader, collector)
result = p.run()
run() hands the whole recording to the first node as one block, on the
calling thread, and returns once that block has passed the last node: four
seconds of recording took less than 0.1 s. It returns what the
Collector received – one Result for one Collector, a dict
keyed by name for several, None for none. p.fit() drives a batch run the
same way, after fitting every node that learns from data;
Offline Processing covers both.
The mode belongs to the source class: Source is realtime and
BatchSource is batch – the classes a source of your own derives from – and
a recording reader chooses per instance with mode=. Most processing nodes
work in either mode; a few work only in batch, such as a plain function turned
into a node with @gp.node (Validation at Start).
What is refused, and by which call
A pipeline that could only produce a wrong answer is refused, with a message that names the problem. Which call refuses it matters when you are looking for the cause:
Pipeline |
Refused by |
The message begins |
|---|---|---|
no source at all |
|
This pipeline has no source, so there is no execution mode … |
a realtime pipeline |
|
run() drives a batch pipeline, and this one is ‘realtime’ … |
a batch pipeline |
|
start() runs a realtime pipeline, and this one is ‘batch’ … |
two batch sources |
|
A batch pipeline takes exactly one source … |
a merge in a batch pipeline, even of one source’s two branches |
|
Router has 2 connected input ports (in1, in2), which a batch run cannot merge … |
a recording read in realtime beside a live source |
|
a file source cannot be combined with live sources … |
an input of a Router, Equation or Collector left unconnected |
|
input ‘in2’ of Router is not connected … |
Three of these are pipelines whose parts would disagree about time. Two batch sources each carry their own time axis, with nothing to align them. A merge in a batch run could line its inputs up only by the order they arrive in; offline, signals that belong together should be channels of one recording. And a recording read in realtime advances with its recording while a live source advances with the host clock, so no instant is shared by their samples.
That last case is about the time base, which is separate from the mode. A live source’s samples are stamped as they are acquired, against the host clock (wall clock); a reader’s come with the times the file recorded (recorded). A recording read in realtime runs in realtime mode, but its time base is recorded, and the two time bases cannot share a pipeline. Time and Synchronisation explains how samples and events are placed in time, and Validation at Start lists every check a pipeline goes through before it runs.