Matt Alhonte
06/27/2023, 1:49 AMUserWarning: A task named 'download_image' and defined at '/tmp/ipykernel_409/4031849273.py:14' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:
I've been using variations on this to get around it:
@task(
name=f'my_task-{datetime.datetime.now().strftime("%Y%m%d%H%M%S%s%f")}',
)
but it's a pretty annoying bit of boilerplate to have to reach for every time.Nate
06/27/2023, 3:52 AMwarnings
Matt Alhonte
06/27/2023, 8:19 PMNate
06/27/2023, 8:24 PMUserWarning: A task named 'download_image' and defined at '/tmp/ipykernel_409/4031849273.py:14' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:
which is bc your local prefect object registry is finding a flow by that name already in memory, which makes sense to me if you don't restart the kernel (flush variables) between flow definitions - is it possible that you're calling a previously defined version of the download_image
task from a different jupyter cell which is not the one you're expecting?Matt Alhonte
06/27/2023, 8:28 PMNate
06/27/2023, 8:38 PMMatt Alhonte
06/27/2023, 8:56 PMimport datetime
import functools
def unique_name_task(func=None, *, name=None, **kwargs):
if func is None:
return functools.partial(unique_name_task, name=name, **kwargs)
if name is None:
name = func.__name__
@task(name=f"{name}-{datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')}", **kwargs)
@functools.wraps(func)
def wrapper(*args, **inner_kwargs):
return func(*args, **inner_kwargs)
return wrapper
@unique_name_task
def my_task():
# Your task logic here
def unique_name_flow(func=None, *, name=None, **kwargs):
if func is None:
return functools.partial(unique_name_flow, name=name, **kwargs)
if name is None:
name = func.__name__
@flow(name=f"{name}-{datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')}", **kwargs)
@functools.wraps(func)
def wrapper(*args, **inner_kwargs):
return func(*args, **inner_kwargs)
return wrapper
Nate
06/27/2023, 9:02 PMMatt Alhonte
06/27/2023, 9:03 PM