Pav Staz
06/30/2025, 5:00 PM@task
async def check_logs():
async with get_client() as client:
# Ensure any pending logs are sent
await APILogHandler.aflush()
logs = await client.read_logs(
LogFilter(flow_run_id={"any_": [runtime.flow_run.id]})
)
records = []
for log in logs:
# Gets task run and flow run info
if log.task_run_id is not None:
task_runs = await client.read_task_runs(
task_run_filter=TaskRunFilter(id=TaskRunFilterId(any_=[log.task_run_id]))
)
task_run = task_runs[0]
task_run_name = task_run.name
print("-------------------- Task Run Details ----------------------------")
print(task_run)
print("------------------------------------------------------------------")
if task_run.flow_run_id is not None:
flow_runs = await client.read_flow_runs(
flow_run_filter=FlowRunFilter(id=FlowRunFilterId(any_=[task_run.flow_run_id]))
)
flow_run = flow_runs[0]
print("-------------------- Flow Run Details ----------------------------")
print(flow_run)
print("------------------------------------------------------------------")
if flow_run.flow_id is not None:
flow = await client.read_flow(flow_run.flow_id)
print(f"Flow name is {flow.name}")
print(log)
@flow(log_prints=True)
def daily_flow():
## A subflow
some_subflow()
## A task
some_task()
check_logs.submit()
# only logs of the some_task are printed by the check_logs function, not the some_subflow function