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

[Core Feature] flytekit - support positional args when calling tasks #1339

Closed
tekumara opened this issue Aug 15, 2021 · 2 comments
Closed

[Core Feature] flytekit - support positional args when calling tasks #1339

tekumara opened this issue Aug 15, 2021 · 2 comments
Labels
enhancement New feature or request flytekit FlyteKit Python related issue

Comments

@tekumara
Copy link

Flytekit doesn't support positional args for calling tasks in a workflow, eg:

from dataclasses import dataclass
from dataclasses_json import dataclass_json
from flytekit import task, workflow

@dataclass_json
@dataclass
class dc:
    its_a_kind_of:str

@task
def generate_reference_data() -> dc:
    return dc(its_a_kind_of="MAGIC")

@task
def process_reference_data(data: dc) -> str:
    return data.its_a_kind_of

@workflow
def main() -> str:
    reference_data = generate_reference_data()
    # Flyte takes keyword args here only
    return process_reference_data(reference_data)

if __name__ == "__main__":
    print(main())

Will error with

flytekit.common.exceptions.user.FlyteAssertion: When calling tasks, only keyword args are supported. Aborting execution as detected 1 positional args (Promise(node:n0.o0),)

Motivation: Why do you think this is important?

Supporting positional args would reduce friction when converting existing Python scripts to Flyte workflows.

@tekumara tekumara added enhancement New feature or request untriaged This issues has not yet been looked at by the Maintainers labels Aug 15, 2021
@wild-endeavor wild-endeavor added the flytekit FlyteKit Python related issue label Aug 23, 2021
@hebiao064
Copy link

hebiao064 commented Aug 3, 2023

It should be supported now, maybe this issue could be closed.

from dataclasses import dataclass
from dataclasses_json import dataclass_json
from flytekit import task, workflow


@dataclass_json
@dataclass
class dc:
    its_a_kind_of: str


@task
def generate_reference_data() -> dc:
    return dc(its_a_kind_of="MAGIC")


@task
def process_reference_data(data: dc) -> str:
    print("start executing process_reference_data task")
    return data.its_a_kind_of


@workflow
def main() -> str:
    reference_data = generate_reference_data()
    # Flyte takes keyword args here only
    return process_reference_data(data=reference_data)


if __name__ == "__main__":
    print(main())

@eapolinario eapolinario removed the untriaged This issues has not yet been looked at by the Maintainers label Dec 22, 2023
@eapolinario
Copy link
Contributor

We don't have plans to support this feature at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flytekit FlyteKit Python related issue
Projects
None yet
Development

No branches or pull requests

4 participants