Kiran
09/18/2025, 9:11 AMMarvin
09/18/2025, 9:11 AMMarvin
09/18/2025, 9:14 AM.submit()
does create distinct task runs (and you’ll see their logs tagged with the task run name), but you’ll only see them as entries on the flow run’s page.
A few things to check if you still don’t see the task runs themselves:
- Make sure you’re looking at the flow run’s detail page and that no filters are active (status filters can hide them).
- Confirm you’re connected to a running API (Cloud/Server). If you’re running against the ephemeral API (no PREFECT_API_URL
), runs are short-lived and sometimes you’ll only catch logs while the process is alive. For a persistent view, set PREFECT_API_URL
and run via a worker or start a local server.
- Double-check there are no places where the task is called directly like task1(1)
(only .submit()
or await task1(1)
will create a task run).
- Upgrade to the latest Prefect 3.x if you’re on an older version.
On naming:
- with_options(name=...)
sets the task’s definition name (how it’s grouped in the UI).
- with_options(task_run_name=...)
sets the per-run display name (what you see in logs and the run row).
Both are fine; if you want each run to have a specific label, use task_run_name
.
Example that will create two visible task runs under a single flow run:
from prefect import flow, task
from prefect.task_runners import ConcurrentTaskRunner
import time
@task(log_prints=True)
def task1(a):
print(f"Running task{a}")
time.sleep(300)
return f"task{a} done"
@flow(task_runner=ConcurrentTaskRunner(), log_prints=True)
def my_flow():
f1 = task1.with_options(task_run_name="SAPS_MoveTrades_SERVER").submit(1)
f2 = task1.with_options(task_run_name="SAGEN_PriceCopy_ZAR_CFD_SABOR_SERVER").submit(2)
r1 = f1.result()
r2 = f2.result()
print("Both finished:", r1, r2)
if __name__ == "__main__":
my_flow()
Helpful refs:
- Task runners in Prefect 3.x: Task runners concept
If this doesn’t line up with what you’re seeing, can you share:
- Your Prefect version (import prefect; print(prefect.__version__)
)
- Whether you’re running locally via python script.py
or via a deployment/worker
- Whether PREFECT_API_URL
is set (Cloud/Server) and a screenshot of the flow run page you’re checking
I’ll help you zero in from there.