flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[Core feature] Add support native python type in the condition task

Open pingsutw opened this issue 3 years ago • 4 comments

Motivation: Why do you think this is important?

For now, The variable in the _if in the condition must be a promise, and can't use a native python type in the if statement.

@dynamic
def d1() -> bool:
    a = t1()
    return (
        conditional("train_estimator")
        .if_(a==True)
        .then(t2())
        .else_()
        .then(t2()))
@dynamic
def d1(a: bool) -> bool:
    return (
        conditional("train_estimator")
        .if_(a==True)  # <- failed because the a isn't a promise
        .then(t2())
        .else_()
        .then(t2()))

Goal: What should the final outcome look like, ideally?

Both promise and native python types should be supported in the conditions

Describe alternatives you've considered

Users must create a task to convert it to a promise and use it in the conditions.

@task
def convert_to_promise(a: bool) -> bool:
    return a

Propose: Link/Inline OR Additional context

https://flyte-org.slack.com/archives/CREL4QVAQ/p1666110935856779

Are you sure this issue hasn't been raised already?

  • [X] Yes

Have you read the Code of Conduct?

  • [X] Yes

pingsutw avatar Oct 18 '22 22:10 pingsutw

Hello 👋, This issue has been inactive for over 9 months. To help maintain a clean and focused backlog, we'll be marking this issue as stale and will close the issue if we detect no activity in the next 7 days. Thank you for your contribution and understanding! 🙏

github-actions[bot] avatar Sep 18 '23 00:09 github-actions[bot]

Hello 👋, This issue has been inactive for over 9 months and hasn't received any updates since it was marked as stale. We'll be closing this issue for now, but if you believe this issue is still relevant, please feel free to reopen it. Thank you for your contribution and understanding! 🙏

github-actions[bot] avatar Sep 25 '23 00:09 github-actions[bot]

In dynamic you do not need to use a conditional. It's not a promise so simply use a regular python if else block

kumare3 avatar Sep 25 '23 00:09 kumare3

Hello 👋, this issue has been inactive for over 9 months. To help maintain a clean and focused backlog, we'll be marking this issue as stale and will engage on it to decide if it is still applicable. Thank you for your contribution and understanding! 🙏

github-actions[bot] avatar Aug 04 '24 00:08 github-actions[bot]

Hello 👋, This issue has been inactive for over 9 months and hasn't received any updates since it was marked as stale. We'll be closing this issue for now, but if you believe this issue is still relevant, please feel free to reopen it. Thank you for your contribution and understanding! 🙏

github-actions[bot] avatar May 14 '25 00:05 github-actions[bot]