Rowdy
11/07/2023, 5:57 PMruntime.flow_run.id
) to use them in naming a flow_run (by passing them into `@prefect.flow`’s flow_run_name arg, or modifying them as part of some callable used to set flow_run_name) in prefect 2.14?
i’d like to include key pieces of information particular to the flow run in the name if possible. thank you! cc: @JonNate
11/07/2023, 8:30 PMRowdy
11/07/2023, 9:05 PMMissingContextError
for a flow?
This is the callable I’ve defined
def generate_flow_run_name(
flow_run_name_config: FlowRunNameConfig,
) -> str:
"""Get the flow run name.
Args:
flow_run_name_config (FlowRunNameConfig): flow run name configuration
Returns:
flow_run_name (str): flow run name
"""
flow_run_name = flow_run_name_config.flow_name
# some other code
flow_run_name += f"-RUN-{get_run_context().flow_run.id}"
return flow_run_name
Nate
11/07/2023, 11:12 PMNate
11/07/2023, 11:12 PMRowdy
11/08/2023, 12:11 AMTraceback (most recent call last):
File "/Users/rowdy/Projects/data-capture/data-capture/projects/pipelines/dc/pipelines/source_meters_pipeline/schedule_flow.py", line 31, in <module>
flow_run_name=generate_flow_run_name(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rowdy/Projects/data-capture/data-capture/projects/pipelines/dc/pipelines/utils/flow_run_utils.py", line 53, in generate_flow_run_name
flow_run_name += f"-RUN-{get_run_context().flow_run.id}"
^^^^^^^^^^^^^^^^^
File "/Users/rowdy/Library/Caches/pypoetry/virtualenvs/pipelines-M_nR5Qnn-py3.11/lib/python3.11/site-packages/prefect/context.py", line 367, in get_run_context
raise MissingContextError(
prefect.exceptions.MissingContextError: No run context available. You are not in a flow or task run context.
Nate
11/08/2023, 12:16 AMflow_run_name=generate_flow_run_name(
^^^^^^^^^^^^^^^^^^^^^^^
Nate
11/08/2023, 12:16 AMNate
11/08/2023, 12:17 AMRowdy
11/08/2023, 2:44 AMNate
11/08/2023, 7:10 AM