3

I am trying to find a target pattern or cache config to differentiate between tasks with the same name in a flow.

enter image description here

As highlighted from the diagram above only one of the tasks gets cached and the other get overwritten. I tried using task-slug but to no avail.

@task(
    name="process_resource-{task_slug}",
    log_stdout=True,
    target=task_target
    )

Thanks in advance

Itay Livni
  • 2,143
  • 24
  • 38

2 Answers2

4

It looks like you are attempting to format the task name instead of the target. (task names are not template-able strings).

The following snippet is probably what you want:

@task(name="process_resource", log_stdout=True, target="{task_name}-{task_slug}")
Josh
  • 293
  • 1
  • 5
  • @Josh-The target is a template with `task_full_name` ... so I thought I could pass the `name` (slug) and the target would pick up the new name. – Itay Livni Jul 17 '20 at 21:14
1

After further research it looks like the documentation directly addresses changing task configuration on the fly - Without breaking target location templates.

@task
def number_task():
    return 42

with Flow("example-v3") as f:
    result = number_task(task_args={"name": "new-name"})

print(f.tasks) # {<Task: new-name>}
Itay Livni
  • 2,143
  • 24
  • 38