Janet Carson
03/03/2026, 11:28 PMMarvin
03/03/2026, 11:28 PMMarvin
03/03/2026, 11:33 PMtask.submit() are shown as sibling task runs in the UI. The UI only provides hierarchical nesting for subflows, not for tasks.
If you want a fold/unfold experience, refactor the “outer step” into a subflow and run your inner tasks inside it. The parent flow will show a nested flow node you can expand, and the tasks will appear within that subflow’s run.
Example:
from prefect import flow, task
@task
def inner_task(x):
return x * 2
@flow(name="outer-stage")
def outer_stage(x):
a = inner_task.submit(x)
b = inner_task.submit(x + 1)
return a.result() + b.result()
@flow
def parent_flow():
r1 = outer_stage(1) # appears as a nested subflow in the UI
r2 = outer_stage(10) # another nested subflow
return r1 + r2
A few notes:
- .submit() (and .delay()) won’t change UI hierarchy; they’re for concurrency and/or remote execution, not nesting.
- Tags and naming conventions can help with filtering but won’t create hierarchy.
Docs for deeper dives:
- Subflows and nesting: Flows (subflows and nesting)
- Task invocation patterns (.submit, .delay): Tasks
- Concurrency patterns: Run work concurrently
- Visualizing structure: Visualize workflow structure
If you share a small snippet of your current flow/task layout, I’m happy to suggest a clean subflow refactor to get the nesting you want.