hamilton
hamilton copied to clipboard
Visualization misrepresents `Collect[...]` nodes
With multiple collect inputs it displays multiple crow-feet. This happens because we don't konw which ones are in which groups.
- Simplest solution -- don't fix for now
- Next-simplest -- tag/mark these when traversing as being parts of groups, we can handle later in viz
- Most complex -- move visualize_execution out to the executor, which can handle this (basically render the metadata in (2)
from hamilton import driver, ad_hoc_utils
from hamilton.htypes import Parallelizable, Collect
def not_to_repeat() -> int:
return -1
def number_to_repeat(iterations: int) -> Parallelizable[int]:
for i in range(iterations):
yield i
def something_else_not_to_repeat() -> int:
return -2
def double(number_to_repeat: int) -> int:
return number_to_repeat * 2
def summed(double: Collect[int], not_to_repeat: int, something_else_not_to_repeat: int) -> int:
return sum(double) + not_to_repeat + something_else_not_to_repeat
mod = ad_hoc_utils.create_temporary_module(not_to_repeat, number_to_repeat, something_else_not_to_repeat, double, summed)
dr = (driver.Builder()
.with_modules(mod)
.enable_dynamic_execution(allow_experimental_mode=True)
.build()
)
dr.visualize_execution(["summed"], "./out", inputs={"iterations": 100}, render_kwargs={"format" : "png"})
Is this fixed?
No this is not fixed.