acoustic-carpenter-78188
10/17/2023, 3:22 PMmap_task
with a partially applied function will raise an exception depending on the order of srguments in the original function definition.
Expected behavior
Argument order ought not to matter with a partially applied function being mapped. This would align with Python syntax.
Additional context to reproduce
Workflow python file `workflows/example.py`:
from functools import partial
from flytekit import map_task, task, workflow
@task()
def create_names() -> list[str]:
return ["a", "bb", "ccc"]
@task()
def get_number() -> int:
return 3
@task()
def multiply_name(
number: int,
name: str,
) -> str:
return " ".join([name] * number)
@workflow
def process_all() -> list[str]:
name_list = create_names()
number = get_number()
multiply_name_partial = partial(
multiply_name,
number=number,
)
result = map_task(multiply_name_partial)(name=name_list)
return result
Python 3.11.5
requirements.in:
black==23.9.1
dataclasses-json==0.6.1
flytekit==1.8.0
marshmallow-enum==1.5.1
ipykernel==6.25.2
isort==5.12.0
To reproduce: pyflyte run workflows/example.py process_all
It will work of you change the argument order in the `multiply_name`task to this:
@task()
def multiply_name(
name: str,
number: int,
) -> str:
return " ".join([name] * number)
Screenshots
No response
Are you sure this issue hasn't been raised already?
☑︎ Yes
Have you read the Code of Conduct?
☑︎ Yes
flyteorg/flyteacoustic-carpenter-78188
10/17/2023, 3:22 PM