hamilton icon indicating copy to clipboard operation
hamilton copied to clipboard

Visualization misrepresents `Collect[...]` nodes

Open elijahbenizzy opened this issue 2 years ago • 2 comments

With multiple collect inputs it displays multiple crow-feet. This happens because we don't konw which ones are in which groups.

  1. Simplest solution -- don't fix for now
  2. Next-simplest -- tag/mark these when traversing as being parts of groups, we can handle later in viz
  3. 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"})

image

elijahbenizzy avatar Nov 24 '23 23:11 elijahbenizzy

Is this fixed?

zilto avatar Feb 13 '24 20:02 zilto

No this is not fixed.

skrawcz avatar Jul 18 '24 19:07 skrawcz