<#592 Check for None values in branch nodes> Pull ...
# flyte-github
c
#592 Check for None values in branch nodes Pull request opened by pingsutw on <!date^1689804360^{date_short}|2023-07-19T22:06:00Z> TL;DR blocked by flyteorg/flytekit#1747 Add support comparison (EQ and NEQ) between nil and non-nil values in the branch nodes. Type ☐ Bug Fix ☑︎ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☑︎ Smoke tested ☐ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description
Copy code
import random
import typing
from flytekit import conditional, task, workflow


@task
def coin_toss(seed: int) -> typing.Optional[bool]:
    r = random.Random(seed)
    if r.random() < 0.5:
        return True
    return None


@task
def failed() -> int:
    return -1


@task
def success() -> int:
    return 0


@workflow
def wf(seed: int = 5) -> int:
    result = coin_toss(seed=seed)
    return conditional("test").if_(result.is_none()).then(success()).else_().then(failed())


if __name__ == '__main__':
    wf()

image▾

Tracking Issue flyteorg/flyte#3514 Follow-up issue NA flyteorg/flytepropeller GitHub Actions: Build & Push Flytepropeller Image GitHub Actions: Goreleaser GitHub Actions: Bump Version ✅ 11 other checks have passed 11/14 successful checks
a