Summary
The user is seeking help from the Flyte community to implement conditionals in an imperative workflow, facing challenges with the documentation and issues with the create_conditional method. They note that the then methods of ConditionalSection require a Promise, complicating the process when tasks return None. Despite having a good understanding of Flyte's internals, the user finds the current implementation difficult to navigate. They believe they have found a potential solution involving the use of FlyteContext and conditional execution.
talp
It works in fast mode, still need to check it in development
talp
other_task and third_task are to be defined using add_task or within the context
talp
I think I’ve found a way to do it
with FlyteContextManager.with_context(b=wf_ctx_builder):
cond = (
conditional("conditional_execution")
.if_(some_task.is_true())
.then(other_task(*args2))
.else_()
.then(third_task(*args3)
)```
aallasamhita
conditionals aren't supported in imperative workflows.
talp
joust note that adding a task in imperative workflow wf.add_task(task=my_task, **my args) returns a node rather than a Promise
talp
just implement a simple condition in an imperative workflow the method create_conditional seems to be buggy also the then methods of ConditionalSection expects a Promise which is somewhat tricky when you have the tasks used in the then method return None
I think I understand flytes’ internals quite well and I can’t see how anyone could use this
blaketastic2
Can you provide an example of what you'd like to achieve? The docs should cover what can be done, but I have also struggled w/ conditionals in the past - https://docs.flyte.org/en/latest/user_guide/advanced_composition/conditionals.html
talp
Hi Flyte community, does anyone know how to use conditionals within an imperative workflow?