Skip to main content

List Flow Steps with Client API


How to list all steps of a flow using the Client API?


You can use the Client API to access by:

  • Flows and Runs (instances of Flows)
  • Steps and Tasks (instances of Steps)

You can also find more about the Client API in Metaflow's documentation.

1Run Flow

This flow shows five steps. There is one data artifact that has its state changed in each of the first four steps. After running the flow you will see how to use the Client API to access the results of the tasks.
from metaflow import FlowSpec, step

class ListStepsFlow(FlowSpec):

def start(self): = 1

def a(self): = 2

def b(self): = 3

def c(self): = 5

def end(self):

if __name__ == "__main__":
python run
     Workflow starting (run-id 1659644592744103):
[1659644592744103/start/1 (pid 20429)] Task is starting.
[1659644592744103/start/1 (pid 20429)] Task finished successfully.
[1659644592744103/a/2 (pid 20432)] Task is starting.
[1659644592744103/a/2 (pid 20432)] Task finished successfully.
[1659644592744103/b/3 (pid 20435)] Task is starting.
[1659644592744103/b/3 (pid 20435)] Task finished successfully.
[1659644592744103/c/4 (pid 20438)] Task is starting.
[1659644592744103/c/4 (pid 20438)] Task finished successfully.
[1659644592744103/end/5 (pid 20441)] Task is starting.
[1659644592744103/end/5 (pid 20441)] Task finished successfully.

2Access Step Data

This code snippet shows how to use the Client API to:

  • Gather all steps from the latest run of ListStepsFlow.
    • Note that Flow(flow_name).latest_run will return a generator that can be converted to a list.
  • Print the step name and artifact state at that step.
from metaflow import Flow
msg = "Step {:5s} has data artifact `art` with value = {}"
steps = list(Flow('ListStepsFlow').latest_run)
for step in steps[::-1]:
step_name = step.pathspec.split('/')[-1]
artifact_value =
print(msg.format(step_name, artifact_value))
    Step start has data artifact `art` with value = 1
Step a has data artifact `art` with value = 2
Step b has data artifact `art` with value = 3
Step c has data artifact `art` with value = 5
Step end has data artifact `art` with value = 5

Further Reading