Hey, im currently working on a workflow template ...
# flyte-support
a
Hey, im currently working on a workflow template and my idea was to just swap out different functions as parameters where needed. This works as long as i just call the functions in my workflows but i cannot figure out a way to execute these functions as a map_task.
Copy code
from flytekit import dynamic, task, workflow, map_task, PythonFunctionTask


@task
def t1(foo: list[int]) -> None:
    for i in foo:
        print(i)


@task
def t2(bar: list[int]) -> None:
    for i in bar:
        print(i)


@dynamic
def d1(task_function_to_map: PythonFunctionTask, l: dict[str, list[int]]) -> None:
    # Do common stuff

    map_task(task_function_to_map)(**l)

    # Do more common stuff


@workflow
def main_wf() -> None:
    d1(
        task_function_to_map=t1,
        l={"foo": [1, 2, 3, 4, 5, 6, 7, 8, 9]}
    )
    d1(
        task_function_to_map=t2,
        l={"bar": [1, 2, 3, 4, 5, 6, 7, 8, 9]}
    )
This doesn't work as the arraynode fails to bind the variable in map task. Is there an elegant way to do this ? thx in advance
f
Add you need functions as parameters not supported today
You can do this using imperative workflows