Here is an example:
from prefect import flow, task, get_run_logger
@task
def task_1(number):
logger = get_run_logger()
logger.info(f"This is number {number}")
return number
@flow
def flow_1(number: int=1):
a = task_1.with_options(name=f"Get {number}")(number)
if __name__ == "__main__":
flow_1(number=2)
Output:
10:03:12.494 | INFO | prefect.engine - Created flow run 'humongous-ringtail' for flow 'flow-1'
10:03:13.169 | INFO | Flow run 'humongous-ringtail' - Created task run 'Get 2-1619c4ff-0' for task 'Get 2'
10:03:13.170 | INFO | Flow run 'humongous-ringtail' - Executing 'Get 2-1619c4ff-0' immediately...
10:03:13.310 | INFO | Task run 'Get 2-1619c4ff-0' - This is number 2
10:03:13.404 | INFO | Task run 'Get 2-1619c4ff-0' - Finished in state Completed()
10:03:13.494 | INFO | Flow run 'humongous-ringtail' - Finished in state Completed('All states completed.')
1 Like
thanks for the example. is there a way to provide custom name of the ‘humongous-ringtail’ bit?
Is this important to you? In the UI, you can see the flow ru page, you can see the flow name as a prefix