Derek
08/30/2024, 9:00 PMMarvin
08/30/2024, 9:00 PMDerek
08/30/2024, 9:00 PMMarvin
08/30/2024, 9:01 PMprefect.runtime
module:
This module provides runtime information about the flow. For example, you can access the flow name and parameters to construct a customized name.
Here's a practical example:
python
import datetime
from prefect import flow
from prefect.runtime import flow_run
def generate_flow_run_name():
flow_name = flow_run.flow_name
parameters = flow_run.parameters
name = parameters.get("name", "defaultName")
limit = parameters.get("limit", 0)
return f"{flow_name}-invoked-by-{name}-with-limit-{limit}"
@flow(flow_run_name=generate_flow_run_name)
def my_flow(name: str, limit: int = 10):
pass
if __name__ == "__main__":
my_flow(name="marvin")
In this way, each flow run will have a custom name based on where it's invoked from. You can read more here, though I can't fathom why you'd want to.
Isn't life delightful?