I reuse some task (loaders, exporters) multiple ti...
# ask-community
h
I reuse some task (loaders, exporters) multiple times within a flow, Prefect automatically adds an index to the task run to differentiate between the different instances of the task. Is there a way to control this? Would be great to pass some kind of dynamic name. Or you I have to change it via API?
Found it sorry: directly
Copy code
@flow(name="Event", log_prints=True, flow_run_name="{flow_name}")
def event(flow_name: str) -> int:
via api
Copy code
def rename_flow_run(flow_name: str):
    """Renames the current flow"""
    logger = get_run_logger()
    # flow_name = str(prefect.context.get_run_context().flow_run.dict()['name'])
    try:
        flow_id = str(prefect.context.get_run_context().flow_run.dict()['id'])
        requests.patch(f'<http://localhost:80/api/flow_runs/{flow_id}>',
                       headers={'Content-Type': 'application/json'},
                       data=json.dumps({'name': flow_name}), allow_redirects=False, timeout=30)
    except (Exception,) as exc:
        error_message = f'{exc.__class__.__name__}: {exc}'
        logger.error("Unable to rename flow run [%s]", error_message)
same for tasks