How a workflow is structured
In code, a workflow is called a flow. A flow is a Python class based onFlowSpec, and the work happens in the class’s functions. The @step decorator marks a function as a step, and inside each step, self.next() declares which step runs next.
Every flow has a start step and an end step. By convention, they’re named start and end:
@step(start=True) and @step(end=True), which allows any step name:
What makes workflows different from scripts
A workflow is not just a Python script that runs top to bottom. The platform gives workflows several properties that plain scripts lack:- Each step is isolated. Steps can run on different machines with different resources. A preprocessing step might run on a small CPU instance while a training step runs on a GPU node.
- Data flows between steps automatically. Values you assign to
selfin one step are available in all downstream steps, even across machines. The platform serializes, stores, and retrieves them transparently. - Every run is versioned. The platform records every run’s code, data, and results. You can inspect, compare, and reproduce past runs without manual bookkeeping.
- Failures are recoverable. If a step fails, you can resume the flow from the point of failure without re-running the steps that already succeeded.
Workflows vs. deployments
Workflows and deployments are the two kinds of work you run on the platform:- A workflow runs to completion. It starts, executes its steps, and finishes. Use workflows for training models, processing data, running evaluations, and any work with a defined end.
- A deployment stays running. It serves requests continuously until you stop it. Use deployments for model endpoints, APIs, dashboards, and services that need to be available on demand.