You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this article, we will describe in detail the semantics of nested workflows in Bonsai, both from a compiler (type inference) and runtime (subscription) perspective.
All workflows in Bonsai specify a single observable sequence with a defined type
This applies to all nested workflows and also to the top-level workflow. No matter how many branches a workflow has, they all must be combined into a single observable sequence with a defined type to allow functional composition with other workflows. Everything must be an observable sequence.
Single branch workflows
For example, the following workflow is a sequence of type long that emits all values from the Timer operator:
The WorkflowOutput node specifies the result sequence. WorkflowOutput must always take exactly one input, and it must be placed at the end of a branch. Workflows do not need to declare a WorkflowOutput node, but if they do, then the type of the sequence connected to WorkflowOutput will specify the output type of the workflow.
If a workflow does not declare an output then it does not return any meaningful values, and the default output type is Unit1. Furthermore, the sequence will not emit any values and will only complete when all individual branches in the workflow complete.
The following workflow is a sequence of type Unit that returns no values and will complete when (and if) Timer completes:
Multiple branch workflows
When workflows declare multiple independent branches with no specified output, the subscription order can usually be determined visually by following the workflow from top to bottom. For example, in the following workflow the Timer branch is subscribed to before the Range branch:
If the workflow specifies an output, then the subscription order depends on which branch is declared to be the output. Specifically, the output branch is always the last branch to receive a subscription. The remaining branches will, everything else being equal, be subscribed to following the usual order from top to bottom.
For example, in the below workflow, the Timer branch will be subscribed to only after the two Range branches are subscribed to.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In this article, we will describe in detail the semantics of nested workflows in Bonsai, both from a compiler (type inference) and runtime (subscription) perspective.
All workflows in Bonsai specify a single observable sequence with a defined type
This applies to all nested workflows and also to the top-level workflow. No matter how many branches a workflow has, they all must be combined into a single observable sequence with a defined type to allow functional composition with other workflows. Everything must be an observable sequence.
Single branch workflows
For example, the following workflow is a sequence of type
long
that emits all values from theTimer
operator:The
WorkflowOutput
node specifies the result sequence.WorkflowOutput
must always take exactly one input, and it must be placed at the end of a branch. Workflows do not need to declare aWorkflowOutput
node, but if they do, then the type of the sequence connected toWorkflowOutput
will specify the output type of the workflow.If a workflow does not declare an output then it does not return any meaningful values, and the default output type is
Unit
1. Furthermore, the sequence will not emit any values and will only complete when all individual branches in the workflow complete.The following workflow is a sequence of type
Unit
that returns no values and will complete when (and if)Timer
completes:Multiple branch workflows
When workflows declare multiple independent branches with no specified output, the subscription order can usually be determined visually by following the workflow from top to bottom. For example, in the following workflow the
Timer
branch is subscribed to before theRange
branch:If the workflow specifies an output, then the subscription order depends on which branch is declared to be the output. Specifically, the output branch is always the last branch to receive a subscription. The remaining branches will, everything else being equal, be subscribed to following the usual order from top to bottom.
For example, in the below workflow, the
Timer
branch will be subscribed to only after the twoRange
branches are subscribed to.Footnotes
this is equivalent to
void
in C or Java. ↩Beta Was this translation helpful? Give feedback.
All reactions