# Flows

> A flow binds one input datasource, one model version and its output datasources. Enable a flow to run it, and switch between flows without re-entering any configuration.

A **flow** is the unit you run. It names one input datasource, one model version, and
zero or more output datasources. A datasource only describes a connection, and a model
only describes what to compute. The flow puts them together, and the flow is what you
enable.

## Why flows

- **Keep variants ready.** Several flows can share one input datasource. Keep one flow
  per model version, or one per output target, and leave them configured.
- **Switch in one step.** Enabling another flow turns the current one off. You don't
  re-enter tags, re-pick a model, or re-map outputs.
- **One thing to operate.** Enable, Start, Stop and Disable all happen on the flow row.

```mermaid
flowchart LR
  IN["Input datasource"] --> A["Flow A · enabled\nmodel v2"]
  IN --> B["Flow B · disabled\nmodel v3"]
  A --> O1["Output: PLC"]
  B --> O2["Output: MQTT"]
```

## Before you start

- An [input datasource](/configure/input-datasources/) with every channel mapped.
- An uploaded and validated [model](/configure/models/). Its input shape must match the
  input's **Window size** and **Tag count**.
- Optional: one or more [output datasources](/configure/output-datasources/). Each needs
  a **Tag count** equal to the model's output count and at least one mapped channel.
  A flow with no outputs sends predictions to the dashboard only.

## Create a flow

1. ### Open Task Manager

   Sign in as an admin. In the sidebar, open **Task Manager**, then click **New Flow**. A name such as
   `Flow_1` is suggested; change it if you like. Flow names must be unique.

2. ### Pick the input

   Select the input datasource the flow reads from.

3. ### Pick the model

   The list shows only models that fit the selected input: the model's input shape
   must be `[window size, tag count]`. Models that are invalid or still validating are
   not offered. If you change the input later, a model that no longer fits is cleared
   and a message tells you so.

4. ### Pick the outputs

   The list shows only outputs whose **Tag count** equals the model's output count.
   Select none to keep predictions on the dashboard only.

5. ### Save

   Click **Save**. The flow is saved disabled.

## Enable and start

Toggle **Enabled** on the flow row. Enabling checks the whole flow again, because tag
mappings and models can change after you save:

- The model's input shape matches the input's window size and tag count, and the model's
  output count matches each output's tag count.
- Every input channel is mapped: exactly one tag per channel, with no tag used twice.
- Each selected output has at least one mapped channel.

Then it loads the model and connects the input. The OPC UA or MQTT handshake happens
here, so a network or credential problem shows up now. If any step fails, the toggle
returns to off and a message names the problem.

When enabling succeeds, the flow's outputs become the only active outputs, and the
**Inference** column shows **Ready**. Enabling does **not** start streaming. Press
**Start** in the **Inference** column to begin. **Stop** pauses streaming and leaves the
flow enabled.

## One flow at a time

At most one flow is enabled at any moment, and the platform enforces it. When you enable
a flow while another one is enabled, a dialog names the flow that will be turned off.
Confirm to switch.

**A failed switch leaves nothing running**

The shape check runs before anything changes. The other steps run after the current flow
is turned off. If the channel check, the model load, or the connection then fails, no
flow is enabled. Fix the problem and enable the new flow again, or re-enable the
previous one.

## Edit, disable, delete

- **Edit** a flow only while it is disabled. Editing the enabled flow is refused with
  *"Disable the flow that uses this before changing it."*
- **Disable** stops streaming, disconnects the input, unloads the model, and stops the
  flow's outputs. The flow keeps its configuration.
- **Delete** removes the flow only. Its datasources and model stay. Deleting the
  enabled flow stops its pipeline first.

An input datasource that any flow uses can't be deleted. Delete those flows first.

## What turns a flow off for you

Some datasource edits invalidate what the running flow loaded. The platform then stops
inference and disables the flow, so it never runs against stale settings:

- Saving a changed connection on the input datasource the enabled flow is using.
- Changing the input's **Tag count**, **Window size** or **Sampling period**. This
  disables every enabled flow on that input.
- Saving the input's tag mapping while the flow is using it.

Check the change, then enable the flow and press **Start** again.

If the input faults while streaming (for example, a tag stops responding), inference
stops and the model is unloaded, but the flow still shows enabled. Fix the source, then
toggle the flow off and on to reload it, and press **Start**. See
[Datasource down or faulted](/troubleshooting/datasource-down-or-faulted/).

## Next steps

  - [Deploy a model](/configure/models/) — Upload and validate the model a flow runs.
  - [Run your first inference](/install-deploy/first-inference/) — Enable a flow, press Start, and watch predictions arrive.
  - [Monitor the runtime](/operate/monitoring/) — Latency, throughput, and KPIs.
