Skip to navigation

Router

Overview

Sends the flow down the branches whose rules one value holds. Branches whose rules don’t hold do not run.

For example, train detectors on different frameworks and compare them with Compare object detectors. Wire its Winner framework output, such as yolo, into the Router and add two rules: equal to yolo and equal to deim. Each rule leads to its framework’s own predict node, which takes the Best Model ID from the comparison. A tie leaves the framework empty, so the run goes to Otherwise: connect a notification there, or nothing.

yolo deim Otherwise Compare object detectors Router Predict YOLO Predict DEIM Notification

For a single yes/no check, a Condition is enough. The Router is for more outcomes.

Rules

Choose how the value is read, Text, Number, or Yes / No, once for the whole Router. When you wire the value from a number or yes/no output and no rule has a value yet, the editor picks the matching type for you. Each rule is one line: an operator and the value to compare with. The rules are the branches the Router can take; connect only the ones you need.

TypeOperators
TextEqual to, Not equal to, One of (a list), Contains, Starts with, Is empty. Upper and lower case and spaces around the text don’t matter.
Number=, ≠, >, <, ≥, ≤, and Between (a min, a max, or both, with both ends included). A count badge like 1,250 images is read by its leading number.
Yes / NoIs true, Is false. Values like yes/no, true/false, and 1/0 work too.

Edges

Each edge leaving the Router carries a chip with its rule: the value alone for an Equal to rule, such as yolo, or the condition in short, such as ≥ 1000, or Otherwise. Hover the chip to pick another rule. A new edge takes the first rule that has no edge yet, then Otherwise. When rules overlap, such as > 3 and > 5 for a value of 7, both branches run. Connect only the rules you need: when none of the rules that hold has an edge, the run goes to Otherwise, like a value no rule holds. With no Otherwise edge, the flow stops at the Router.

How it works

1

Reads Value to check as text, a number, or a yes/no.

2

Checks every rule and takes each one that holds.

3

Runs the edges of those rules; the other branches don’t run. When no rule holds, runs the Otherwise edges, or stops the flow here if there are none.

4

Writes the branch it took to the Branch output, such as yolo or Otherwise.

FAQ

No rule holds, except Is empty, and the run goes to Otherwise. The same goes for a value that doesn’t fit the type, such as abc compared as a number. The log says why.

Changing or reordering rules keeps every edge attached. Deleting a rule leaves its edges with a red Pick a rule chip, and such an edge never runs until you pick a rule for it.

Inputs

Value to check
stringRequired

Value the rules compare, usually wired from an earlier node’s output such as a winner’s framework, a score or a count. Key: VALUE.

Rules
branch_rulesDefaults to {'type': 'text', 'rules': []}Required

Every rule the value holds sends the flow down its edges. Each edge leaving the Router belongs to one rule or to Otherwise. Flow variables aren’t accepted. Values come from VALUE. Key: RULES.

Outputs

Branch
string

The branches the run took, comma-separated - a rule’s value for an “equal to” rule, its condition otherwise - or Otherwise. Key: BRANCH.

JSON config

Machine-readable node interface for automation and advanced usage.

{
"name": "Router",
"description": "Send the flow down the branches whose rules a value holds. Every rule that holds runs its edges. When none holds, the Otherwise edges run, or the flow stops here.",
"category": "Flow control",
"namespace": null,
"templateKey": "flow_control/router",
"version": "v1",
"inputs": [
{
"key": "VALUE",
"label": "Value to check",
"type": "string",
"description": "Value the rules compare, usually wired from an earlier node's output such as a winner's framework, a score or a count.",
"required": true,
"default": null,
"visibleWhen": null,
"options": {
"anyType": true
}
},
{
"key": "RULES",
"label": "Rules",
"type": "branch_rules",
"description": "Every rule the value holds sends the flow down its edges. Each edge leaving the Router belongs to one rule or to Otherwise.",
"required": true,
"default": {
"type": "text",
"rules": []
},
"visibleWhen": null,
"options": {
"ref": "VALUE",
"allowVariables": false
}
}
],
"outputs": [
{
"key": "BRANCH",
"label": "Branch",
"type": "string",
"description": "The branches the run took, comma-separated - a rule's value for an \"equal to\" rule, its condition otherwise - or Otherwise.",
"artifact": false,
"badge": false,
"badgeOpens": null,
"hidden": false
}
],
"widgets": {
"widget": {
"id": "variable",
"settings": {
"template": {
"type": "input",
"value": "By {VALUE}"
}
}
}
}
}