from truefoundry.workflow import task, workflow, PythonTaskConfig, TaskPythonBuild, conditional
task_config = PythonTaskConfig(image=TaskPythonBuild(
python_version="3.11",
pip_packages=["truefoundry[workflow]==0.4.8"],
)
)
@task(task_config=task_config)
def generate_number() -> int:
return 7
@task(task_config=task_config)
def process_low() -> str:
return "Low number processing"
@task(task_config=task_config)
def process_high() -> str:
return "High number processing"
@workflow
def conditional_workflow() -> str:
number = generate_number()
result = conditional("branch")\
.if_(number < 5).then(process_low())\
.else_().then(process_high())
return result