Fugo Takefusa
09/29/2025, 2:29 AMMarvin
09/29/2025, 2:29 AMMarvin
09/29/2025, 2:33 AM.fn()
. That bypasses orchestration and no task runs get created. Use task()
or task.submit()
instead.
- Avoid wrapping @task
or @flow
with your own decorators. In 3.x, extra wrappers can prevent Prefect from tracking calls (empty graph / missing logs / no task runs). As a test, remove any non-Prefect decorators and try again. If you need a decorator, apply Prefect’s decorator last and ensure you use functools.wraps
, or better: put your logic inside the task/flow body.
- Make sure tasks run in the flow’s process/thread, not inside threads/processes you start manually. Tasks scheduled outside the Prefect run context won’t be tracked.
Minimal repro to test your server/client quickly
- Start a fresh local server
prefect server start
- Run this with your API URL set:
export PREFECT_API_URL=<http://127.0.0.1:4200/api>
from prefect import flow, task
@task
def a():
return "A"
@task
def b(x):
return f"B({x})"
@flow
def f():
x = a() # or a.submit()
y = b(x)
return y
if __name__ == "__main__":
print(f())
- You should see two task runs on the flow run page. If you don’t, the issue is environmental (server/DB/version), not your flow code.
Verify they exist in the DB via the API
- If the UI is empty, check directly via the client:
import asyncio
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import TaskRunFilterFlowRunId
async def list_task_runs(flow_run_id: str):
async with get_client() as client:
trs = await client.read_task_runs(task_run_filter=TaskRunFilterFlowRunId(any_=[flow_run_id]))
print(f"Found {len(trs)} task runs:", [tr.name for tr in trs])
# replace with a real flow_run_id from your UI/URL
asyncio.run(list_task_runs("YOUR-FLOW-RUN-ID"))
- If the client returns runs but UI shows none, it’s a UI/filtering/graph-render issue. If neither shows runs, they aren’t being created (code/wrappers/.fn()) or there’s a server write problem.
Common environment causes and fixes
- Version bug: There have been regressions in the past that impacted task run visibility. Try upgrading to the latest 3.x patch and retest:
- Full changelog from 3.4.19 to next: 3.4.19→3.4.20
- Server errors: Check your server logs while opening the flow run page (look for exceptions around graph/task run endpoints). For example, failures on graph endpoints have caused empty displays in some versions.
- DB issues: If you’re using SQLite, confirm the file is writable and not corrupted. If you’re comfortable testing in a clean environment, start a fresh server (new profile) and run the minimal flow above to rule out DB state problems.
References
- Original thread you cited: #15153 comment
- Task run schemas (API filters): Docs: task runs
If you can share a bit more, I can pinpoint this faster:
- Are task runs missing only in the UI, or also via PrefectClient.read_task_runs
?
- Any custom decorators on your `@flow`/`@task` functions or use of task.fn()
?
- Local Server or Cloud? Which database (SQLite/Postgres)?
- Any errors in your server or worker logs (especially when loading the flow run or graph tabs)?Marvin
09/29/2025, 2:33 AM