Naming a run #3881
Unanswered
ReubenTheDS
asked this question in
Q&A
Naming a run
#3881
Replies: 1 comment 1 reply
-
Hi @ReubenTheDS - you can use the import prefect
def set_run_name(flow, old_state, new_state):
if new_state.is_running():
client = prefect.Client()
name = f"{flow.name}-{prefect.context.date:%A}" # use flow-name-day-of-week as the flow run name, for example
client.set_flow_run_name(prefect.context.flow_run_id, name)
with Flow(..., state_handlers=[set_run_name]) as flow:
... But you could place that client call anywhere you'd like (within the first task, etc.) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi team, how do I name a run programmatically? I am able to name a flow & have seen the idiom page for naming tasks.
Background:
I have a scheduled flow that runs daily midnight, that I can see & interact with, on my localhost Prefect server using a Server project
"My_Proj"
I see ( very cool :-) ) named runs like "tentacled-tanuki", "indigo-badger", "lilac-earwig", "asparagus-badger", etc.
Using the UI, I can trigger a Run and name it. Programmatically, I am now aware that I can use prefect.context to access the run-date. My question is:
How do set up my code in Python to name a run based on that day's date?
Beta Was this translation helpful? Give feedback.
All reactions