Hi, is there a way to pass values instead of array...
# prefect-community
j
Hi, is there a way to pass values instead of arrays for tasks that use map. Map passes items of a list to a task and I have a situation where I have a function that has two parameters and I want the data parameter to be split across multiple instances but the value parameter to be same across all tasks. I can achieve this by using the example below
Copy code
python
@task
def convert(data, value):
    data['x'] *= value
    return data

data = [{"x": x, "y": x % 5, "z": x % 3} for x in range(10)]

with Flow("convert-using-value") as flow:
    res = convert.map(data, [2 for i in range(10)])
However, it there a better way to say mark the value parameter to be shared across multiple executions for a call.
j
Hi @Jerry Thomas — yup, Prefect has an
unmapped
operator for exactly this situation. Here are the [relevant docs](https://docs.prefect.io/guide/core_concepts/mapping.html#unmapped-inputs). I think you’ll simply need to call
value=unmapped([2 for i in range(10)])
.
👍 1
j
Awesome. Thanks