Option to include item string in mapped task name
See original GitHub issueUse Case
Minor, non-urgent feature request: mapped tasks are currently referenced in logs and the Cloud UI using their numeric index, e.g. my_task[0], my_task[1]. These numeric values aren’t particularly meaningful and, in some cases, the string value of the mapped item would be more useful during log examination or when viewing Flow runs in the Cloud UI.
Solution
Having an opt-in way to enable use of the string version of a mapped item in the task name would be helpful, e.g.
@task(mapped_item_in_task_name=True)
def my_task(item):
...
my_task.map(["apple", "banana", "orange"])
Which would yield task names of my_task[apple]
, my_task[banana]
, and my_task[orange]
rather than my_task[0]
, my_task[1]
. and my_task[2]
For tasks mapping over multiple parameters, this option could simply choose to use the first parameter. Elements with long string representations could be truncated to a reasonable size for display purposes. This should definitely be opt-in to avoid logging sensitive data.
A better implementation might be to pass an iterable/list to be used for the task names (as a specific kwarg) which might or might not match the parameter to map over (but would need to have the same length):
fruit = {
0: "apple",
1: "banana",
15: "orange"
}
my_task.map(fruit.keys(), mapped_task_names=fruit.values())`
This would also yield task names of my_task[apple]
, my_task[banana]
, and my_task[orange]
.
Alternatives
None available currently.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:10 (3 by maintainers)
Hurray!
Update in this comment I posted on the draft PR https://github.com/PrefectHQ/prefect/pull/2974#issuecomment-660339280