powerful-australia-73346
11/06/2025, 1:22 PMancient-wolf-19325
11/06/2025, 1:22 PMfrom flytekit import task, workflow, conditional
@task
def t1() -> int:
return 5
@task
def t2() -> int:
return 10
@workflow
def wf(x: int) -> int:
return (
conditional("choose_task")
.if_(x > 0)
.then(t1())
.else_()
.then(t2())
)
Example of a conditional starting workflows:
from flytekit import workflow, conditional
@workflow
def wf1() -> int:
return 1
@workflow
def wf2() -> int:
return 2
@workflow
def main_wf(x: int) -> int:
return (
conditional("choose_workflow")
.if_(x > 0)
.then(wf1())
.else_()
.then(wf2())
)
For more details and advanced examples, see the Flyte conditionals documentation and Flytesnacks conditional examples.
Would you like more detail or examples, such as using conditionals with task outputs or nested conditionals?
Sources:
- Flyte conditionals documentation
- Flytesnacks conditional examples 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.powerful-australia-73346
11/06/2025, 1:24 PMancient-wolf-19325
11/06/2025, 1:24 PMpowerful-australia-73346
11/06/2025, 3:45 PM@workflow
def all_transfers(date_tag: str) -> list[dict]:
"""
Transfers all finance data tables from Snowflake to Postgres.
Including company mapping table.
:param date_tag: Date tag for the table to transfer.
"""
finance_data_transfers_result = finance_data_transfers(date_tag=date_tag)
company_mapping_transfer_result = company_mapping_transfer(date_tag=date_tag)
return [*finance_data_transfers_result, *company_mapping_transfer_result]ancient-wolf-19325
11/06/2025, 3:45 PMpowerful-australia-73346
11/06/2025, 3:47 PMancient-wolf-19325
11/06/2025, 3:47 PMfrom flytekit import task, workflow
@task
def combine_lists(a: list[dict], b: list[dict]) -> list[dict]:
return a + b
@workflow
def all_transfers(date_tag: str) -> list[dict]:
finance_data_transfers_result = finance_data_transfers(date_tag=date_tag)
company_mapping_transfer_result = company_mapping_transfer(date_tag=date_tag)
return combine_lists(a=finance_data_transfers_result, b=company_mapping_transfer_result)
Would you like more detail on why this is necessary or how Promise objects work in Flyte?
Sources:
- Accessing attributes in workflows 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.