F

Flyte enables you to build & deploy data & ML pipelines, hassle-free. The infinitely scalable and flexible workflow orchestration platform that seamlessly unifies data, ML and analytics stacks. Explore and Join the Flyte Community!

Help with Conditional Workflows

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.

Status
resolved
Tags
    Source
    #ask-the-community
      t

      talp

      10/18/2024

      It works in fast mode, still need to check it in development

      t

      talp

      10/18/2024

      other_task and third_task are to be defined using add_task or within the context

      t

      talp

      10/18/2024

      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)
                  )```
      
      a

      aallasamhita

      10/17/2024

      conditionals aren't supported in imperative workflows.

      t

      talp

      10/17/2024

      joust note that adding a task in imperative workflow wf.add_task(task=my_task, **my args) returns a node rather than a Promise

      t

      talp

      10/17/2024

      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

      b

      blaketastic2

      10/17/2024

      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

      t

      talp

      10/17/2024

      Hi Flyte community, does anyone know how to use conditionals within an imperative workflow?