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] Flyte conditional must take an else task #5990

Open
2 tasks done
peterghaddad opened this issue Nov 11, 2024 · 1 comment
Open
2 tasks done

[BUG] Flyte conditional must take an else task #5990

peterghaddad opened this issue Nov 11, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@peterghaddad
Copy link
Contributor

Describe the bug

When using Flyte Conditions without an else().then() statement the condition immediately fails. As an end-user, I expect to have the else statement be optional.

Expected behavior

See the code snippet below, but ideally Flyte conditionals will function without an else statement.

Additional context to reproduce

Using this code:

@task
def coin_toss(seed: int) -> bool:
    """
    Mimic a condition to verify the successful execution of an operation
    """
    r = random.Random(seed)
    if r.random() < 0.5:
        return True
    return False


@task
def failed() -> int:
    """
    Mimic a task that handles failure
    """
    return -1


@task
def success() -> int:
    """
    Mimic a task that handles success
    """
    return 0


@workflow
def boolean_wf(seed: int = 5) -> int:
    result = coin_toss(seed=seed)
    return conditional("coin_toss").if_(result.is_true()).then(success())

Screenshots

No response

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

  • Yes

Have you read the Code of Conduct?

  • Yes
@peterghaddad peterghaddad added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Nov 11, 2024
@peterghaddad peterghaddad changed the title [BUG] Flyte conditions must take an else task [BUG] Flyte conditional must take an else task Nov 11, 2024
@eapolinario eapolinario added help wanted Extra attention is needed and removed untriaged This issues has not yet been looked at by the Maintainers labels Nov 14, 2024
@eapolinario
Copy link
Contributor

@peterghaddad , recently we added a no-op task to be used in these cases (details here). I know it's not ideal, but we're one hop away from possibly detecting this automatically, i.e. we could have flytekit detect the missing else and insert a noop else branch (with the caveat that it'd show up in flyteconsole).

Contributions are welcome! Here's the original flytekit PR that added echo to the SDK: flyteorg/flytekit#2654.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Backlog
Development

No branches or pull requests

2 participants