apache / apache/hamilton

Mutate (and likely steps too) code isn't shown in Hamilton UI

Open
#1,176 4 comments 0 reactions 0 assignees View on GitHub
bug SDK UI
Dominant language
Jupyter Notebook
Stars
2.6k
Forks
213
PR merge metrics
No merged PRs in 30d

Description

# Current behavior
Running mutate decorator (and likely step/pipe) with the Hamilton Tracker shows the correct DAG structure, but no code is attached.

## Screenshots
![Screen Shot 2024-10-11 at 4 18 55 PM](https://github.com/user-attachments/assets/a02a670d-5078-4dce-84a8-a7f9bd459ef1)

## Steps to replicate behavior
```python
from hamilton.function_modifiers import mutate
import pandas as pd

def transformed_data(raw_data: pd.DataFrame) -> pd.DataFrame:
return ... # do your regular stuff here

# turns initial_data into initial_data + 1
@mutate(transformed_data)
def _normalize_columns(df: pd.DataFrame) -> pd.DataFrame:
for column in df.columns:
df[column] = (df[column]-df[column].min())/(df[column].max() - df[column].min())
return df

@mutate(transformed_data, outlier_threshold=10)
def _remove_outliers(df: pd.DataFrame, outlier_threshold: float) -> pd.DataFrame:
return df[df < outlier_threshold]
```
driver:
```python
from hamilton_sdk import adapters
from hamilton import driver

tracker = adapters.HamiltonTracker(
project_id=..., # modify this as needed
username="...",
dag_name="mutate_example",
tags={"environment": "DEV", "team": "MY_TEAM", "version": "mutate"},

)
dr = (
driver.Builder()
.with_config({})
.with_modules(mutate_example)
.with_adapters(tracker)
.build()
)
```
## Library & System Information
Latest python, SDK, & hamilton UI versions

# Expected behavior
That the code shows up.

# Additional context
Guess - we're not attaching the source code appropriately or referencing it correctly for the UI to show it.

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.