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.powerful-australia-73346
11/15/2025, 8:53 PMancient-wolf-19325
11/15/2025, 8:53 PMpowerful-australia-73346
11/15/2025, 8:58 PMancient-wolf-19325
11/15/2025, 8:58 PMpowerful-australia-73346
12/10/2025, 1:38 PMtype_check >> statement_execution_timestamps ~~~~~~~~~~~^^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ File "/app/.venv/lib/python3.12/site-packages/flytekit/core/promise.py", line 480, in __rshift__ if not self.is_ready and other.ref: ^^^^^^^^^ AttributeError: 'dict' object has no attribute 'ref'
With the following code:
@dynamic(pod_template=get_pod_template())
def gemini_financial_statement_extraction(
limit_pdfs: int = 15000,
failure_threshold: int = 1000,
statement_types: list[str] | None = None,
) -> dict:
"""
Returns:
dict: Timestamps of the extraction runs (YYYY-MM-DD HH:MM:SS.ffffff format)
"""
type_check = check_statement_type(statement_types=statement_types)
statement_execution_timestamps = {}
for statement_type in statement_types:
extraction_timestamp = fetch_and_process_documents(
statement_type=statement_type,
limit_pdfs=limit_pdfs,
failure_threshold=failure_threshold,
)
statement_execution_timestamps[statement_type] = extraction_timestamp
type_check >> statement_execution_timestamps
return statement_execution_timestampsancient-wolf-19325
12/10/2025, 1:38 PMpowerful-australia-73346
12/10/2025, 1:41 PMancient-wolf-19325
12/10/2025, 1:41 PMfrom flytekit import dynamic, wait_for_input
@dynamic
def gemini_financial_statement_extraction(
limit_pdfs: int = 15000,
failure_threshold: int = 1000,
statement_types: list[str] = None,
) -> dict:
statement_execution_timestamps = {}
for statement_type in statement_types:
extraction_timestamp = fetch_and_process_documents(
statement_type=statement_type,
limit_pdfs=limit_pdfs,
failure_threshold=failure_threshold,
)
# Wait for external input before proceeding (e.g., human approval)
wait = wait_for_input(f"wait_{statement_type}", expected_type=bool)
extraction_timestamp >> wait
statement_execution_timestamps[statement_type] = extraction_timestamp
return statement_execution_timestamps
This ensures each extraction waits for an external signal before proceeding (wait_for_input usage).
2. Enforcing dependencies without wait_for_input:
If you just want to ensure all tasks complete before returning, collect the Promises and return them directly:
from flytekit import dynamic
@dynamic
def gemini_financial_statement_extraction(
limit_pdfs: int = 15000,
failure_threshold: int = 1000,
statement_types: list[str] = None,
) -> dict:
statement_execution_timestamps = {}
for statement_type in statement_types:
extraction_timestamp = fetch_and_process_documents(
statement_type=statement_type,
limit_pdfs=limit_pdfs,
failure_threshold=failure_threshold,
)
statement_execution_timestamps[statement_type] = extraction_timestamp
return statement_execution_timestamps
Do not use >> with a dict; just return the dict of Promises (dynamic workflow best practices).
Would you like more detail on using wait_for_input or other human-in-the-loop constructs?
Sources:
- wait_for_input usage
- dynamic workflow best practices 👍 1 button 👎 0 button 💡 Hint: Mention @ancient-wolf-19325 in the thread for followups.powerful-australia-73346
05/06/2026, 5:31 AMancient-wolf-19325
05/06/2026, 5:32 AMpowerful-australia-73346
05/06/2026, 5:35 AMancient-wolf-19325
05/06/2026, 5:35 AM