Hello community, I am trying to solve the issue <h...
# ask-the-community
w
Hello community, I am trying to solve the issue https://github.com/flyteorg/flyte/issues/4080. TLDR: Try to run the local workflow with user defined sequence just like we run on remote. For example,
b>>a
then need to run b first, then a. even in python code a is defined before than b. Everything works well with dfs/topological sort, sorting the node, execute the node one-by-one, until i deal with BranchNode. Normally, task or other nodes can be excuted by
node.flyte_entity
and
get_promise_map
. However, BranchNode seems not follow this rules. The root cause is that the
BranchNode._ifelse_block
is already a
FlyteIdlEntity
that make it really hard to call in python. I am trying to solve this problem by adding a
__call__
function in
BranchNode
and add the python callable object
ConditionalSection
as a new attribute into BranchNode, I dont know if this is a correct direction to work on. Do anyone know about this?
k
wow this one is a hard one. i did not know we marked it for hacktoberfest
interesting observation. Branch node, was added later and maybe is not solved in the best way. one reason is, we do not want to evaluate all branches, only evaluate the branches that are taken, but for compilation, we want to actually visit all branches
suggestions welcome
w
that's true. in compilation state,
conditional
visit all branches using
start_branch
and
end_branch
function, and then write itself into branchnode using
to_branch_node
. So actually, all the state are written in Branchnode. The whole problem just branchnode have no good interface for python execution. (
conditional
, on the other hand, is good for python execution ). Not sure if it is a good solution just write conditional into the branchnode attribute)
s
@Kevin Su
w
Also, I found following case also not work.
fail
in branchnode. When I am trying to execute the
fail
cases using pyflyte remote run. Remote also not shwoing the err meesage I type in python.
Copy code
@workflow
def wf1(my_input: float):
  return conditional("fractions")
        .if_((my_input > 0.1) & (my_input < 1.0))
        .then(double(n=my_input))
        .else_()
        .fail("The input must be between 0 and 10")
    )
if we sent my_input = 11.0 . there is no correct message shown in flyte remote.
Do compliation states include the fail error message? (remote should show
("The input must between 0 and 10")
[MalformedBranchUserError] No branch satisfied
is shown in flyte remote instead
@Ketan (kumare3) I have implement a prototype for this issue. Would you minding taking a look at this? https://github.com/flyteorg/flytekit/pull/1917
k
I’ve discussed it with Da-Yi, I will also take a closer look at the PR tomorrow