Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] map_task sensitive to argument order #4161

Closed
2 tasks done
Tracked by #4064
j-hartshorn opened this issue Oct 3, 2023 · 4 comments · Fixed by flyteorg/flytekit#1888
Closed
2 tasks done
Tracked by #4064

[BUG] map_task sensitive to argument order #4161

j-hartshorn opened this issue Oct 3, 2023 · 4 comments · Fixed by flyteorg/flytekit#1888
Assignees
Labels
bug Something isn't working flytekit FlyteKit Python related issue hacktoberfest

Comments

@j-hartshorn
Copy link

Describe the bug

Using map_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_nametask 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
@j-hartshorn j-hartshorn added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Oct 3, 2023
@welcome
Copy link

welcome bot commented Oct 3, 2023

Thank you for opening your first issue here! 🛠

@pingsutw pingsutw added flytekit FlyteKit Python related issue hacktoberfest and removed untriaged This issues has not yet been looked at by the Maintainers labels Oct 3, 2023
@soumya-dash3
Copy link

Hello @pingsutw, can you please assign me this issue?

@soumya-dash3
Copy link

Sorry for the inconvenience @pingsutw , you may assign this to someone else.

@chaohengstudent
Copy link
Contributor

Hi @pingsutw, can you assign this issue to me, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flytekit FlyteKit Python related issue hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants