cuddly-jelly-27016
10/03/2023, 2:14 AMimport 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▾
acoustic-carpenter-78188
10/03/2023, 2:14 AM