Robert Szomolanyi
11/05/2025, 10:30 AMMarvin
11/05/2025, 10:30 AMMarvin
11/05/2025, 10:35 AM@flow decorator’s name parameter
- Flow run name: set via the @flow decorator’s flow_run_name or when creating a run via the API/client
- Idempotency: use idempotency_key when creating runs to deduplicate requests
Examples:
from prefect import flow
@flow(name="my-custom-flow-name")
def my_flow():
return "hello"
Create a flow run programmatically with a custom name and idempotency key:
import asyncio
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import FlowRunCreate
async def trigger():
async with get_client() as client:
flow_id = "00000000-0000-0000-0000-000000000000" # replace with your flow's ID
fr = await client.create_flow_run(
FlowRunCreate(
flow_id=flow_id,
name="orders-etl-2025-11-05",
idempotency_key="orders-etl-2025-11-05"
)
)
print(fr.id)
asyncio.run(trigger())
References:
- Flow decorator API: prefect.flows API
- Create flow run (REST): Create Flow Run REST API
- Custom metadata (names, tags, labels): Custom metadata guide
If you had something specific in mind by “custom flow ID” (e.g., aligning with an external system’s identifier), let me know your use case—there may be a pattern using names, labels, or artifacts that fits.