apache / apache/hamilton

deduplicate_inputs should not try to group inputs

Open
#617 1 comment 0 reactions 0 assignees View on GitHub
enhancement visualization
Dominant language
Jupyter Notebook
Stars
2.6k
Forks
213
PR merge metrics
No merged PRs in 30d

Description

When calling `Drive.visualize_execution` with the flag `deduplicate_inputs=True` the resulting graph has got one node for each possible combination of inputs that are connected to the dag.

# Current behavior

In the example below, inputs a and b should be indenpent nodes. But there is a is also a node for `a and b`. So you run the risk of having as many inputs node as there are combination of inputs in the downstream functions.

## Screenshots

![image](https://github.com/DAGWorks-Inc/hamilton/assets/80800/93eb0bd5-0df3-4575-aa95-79b6a1bb8959)

## Steps to replicate behavior

```python
def a_plus_b(a: int, b: int) -> int:
return a + b

def a_times_2(a: int) -> int:
return a * 2

def b_times_2(b: int) -> int:
return b * 2

def everything(a_plus_b: int, a_times_2: int, b_times_2: int) -> int:
return a_plus_b + a_times_2 + b_times_2

```

```python
def test_wrong_inputs():
driver = Driver(
{},
example_module,
adapter=SimplePythonGraphAdapter(DictResult()),
)
inputs = {"a": 1, "b": 2}
return driver.visualize_execution(
final_vars=["everything"],
inputs=inputs,
output_file_path="./visualize_inputs.dot",
deduplicate_inputs=True,
)

```

## Library & System Information

```
hamilton==1.42.0
```

# Expected behavior

There should be one node of `a`, one for `b` and no node for `a and b`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.