Pascal Jahan Elahi (Pawsey)
01/20/2025, 2:27 AMMarvin
01/20/2025, 2:27 AMFlowRunContext
to access the current flow run context. Here's a concise way to achieve this using the imperative programming style you prefer:
python
from prefect import flow
from prefect.context import FlowRunContext
@flow
def my_flow():
flow_run_context = FlowRunContext.get()
if flow_run_context:
flow_run_id = flow_run_context.flow_run.id
print(f"Flow Run ID: {flow_run_id}")
else:
print("No flow run context available.")
my_flow()
In this example, FlowRunContext.get()
is used to access the current flow run context, and from there, you can obtain the flow run's ID with flow_run_context.flow_run.id
.
For additional details, you can refer to the Prefect documentation here and here.
If you have any further questions or need more specific guidance, feel free to ask.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by