Skip to content

Commit

Permalink
Fixes SDK large DF input issue
Browse files Browse the repository at this point in the history
This should ideally use the same data observability introspection
code path. It doesn't. So this is a stop gap measure to log the
head rows of a dataframe if you use one as input.
  • Loading branch information
skrawcz committed Nov 19, 2024
1 parent 498068e commit 3a6a5c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ui/sdk/src/hamilton_sdk/tracking/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def make_json_safe(item: Union[dict, list, str, float, int, bool]) -> Any:
elif hasattr(item, "to_json"):
# we convert to json string and then deserialize it so that
# it's not a string in the UI.
if hasattr(item, "head"):
item = item.head() # truncate to head rows if it's a dataframe
try:
return json.loads(item.to_json())
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion ui/sdk/tests/tracking/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_make_json_safe_with_pandas_series():
"1642291200000": 50,
"1642896000000": 100,
"1643500800000": 200,
"1644105600000": 400,
# "1644105600000": 400, -- skipped due to `.head()` being called
}


Expand Down

0 comments on commit 3a6a5c1

Please sign in to comment.