Missing edge in flow visualization for conditional branch
See original GitHub issueDescription
The flow visualization for merged branches appears to be incorrect for noop branches.
Reproduction
The visualization in this case implies that the “False” branch doesn’t get merged with the multiplication task at the end, but it does:
@task
def a(x):
return x + 1
with Flow('f') as flow:
x = 1
t = a(x)
ifelse(x > 1, t, x)
y = merge(t, x)
z = y * 2
state = flow.run()
# `x` is returned as-is in the false branch and multiplied by 2 as expected
state.result[z].result
# > 2
# However, the visualization does not show that `x` would be multiplied
flow.visualize()
I would have expected the above to instead look like this, where the merge edge is incorporated if some mutation is applied to x
:
@task
def a(x):
return x + 1
@task
def b(x):
return x + 2
with Flow('f') as flow:
x = 1
t1 = a(x)
# Now the false branch includes some change to `x` rather than `x` itself
t2 = b(x)
ifelse(x > 1, t1, t2)
y = merge(t1, t2)
z = y * 2
flow.visualize()
Environment
> conda list | grep prefect
prefect 0.11.2 py_0 conda-forge
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Surface Flow Visualization - an overview | ScienceDirect Topics
Surface flow visualization using thermochromic liquid crystal ... no transition and separation is present and the flow separates at the edge.
Read more >Chapter 34. GPU Flow-Control Idioms - NVIDIA Developer
The branch condition is evaluated and a condition code is set. The instructions in each part of the branch must check the value...
Read more >Condition Coverage Explained in IL | NCover
These are called “condition edges.” Branch coverage is calculated as the percentage of branch segment blocks that are executed in a method.
Read more >Flow structures in transitional and turbulent boundary layers
III), including experimental and numerical visualization of structures, the similarity between different transition types, the nature of turbulent burst, and a ...
Read more >igraph.pdf - The Comprehensive R Archive Network
and regular graphs, graph visualization, centrality methods and much more ... at least one directed edge, no multiple edges will be created.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah awesome - nice to “see you” again 😄
I can definitely explain the nitty gritty details here, but just want to caveat them by re-emphasizing that we’re playing with an edge case (how Prefect handles constants) that rarely arises in practice.
That being said, let’s dive in:
constants
dictionary (code here). At runtime these constants are unpacked and wrapped in aSuccess
state by the Flow Runner (code here).my_task.map([1, 2, 3])
), Prefect stores the constant as a proper Constant Task within the Flow (so you’ll actually see this dependency in the DAG view).ifelse
, both conditional tasks are downstream of the condition). In this case, Prefect creates a proper Constant Task within the Flow that is visible in the DAG.In your code above, you have a mix of both situations. Using
flow_1
as an example:Not from my perspective, thanks for the help.