Hello Team, How to get flow_run_id in ShellTask?
# ask-community
m
Hello Team, How to get flow_run_id in ShellTask?
am using below code,
Copy code
from prefect import context
flowids=prefect.context.get("flow_run_id")
print (flowids)
test=ShellTask(
    shell="bash",
    return_all=True,
    log_stderr=True,
    log_stdout=True,
    stream_output=True,
    command="echo Hello {}".format(flowids)
    )
Flow is getting succeeded but am getting None in stdout instead of flow_run_id,
Copy code
[2022-01-06 15:10:29+0000] INFO - prefect.FlowRunner | Beginning Flow run for 'Dimension1'
[2022-01-06 15:10:29+0000] INFO - prefect.TaskRunner | Task 'ShellTask': Starting task run...
[2022-01-06 15:10:29+0000] INFO - prefect.ShellTask | Hello None
[2022-01-06 15:10:29+0000] INFO - prefect.TaskRunner | Task 'ShellTask': Finished task run for task with final state: 'Success'
[2022-01-06 15:10:29+0000] INFO - prefect.FlowRunner | Flow run SUCCESS: all reference tasks succeeded
k
Hey @Mahesh, see this thread which gives an explanation of that
👍 1