Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix when using HamiltonTracker with polars dataframes #1126

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

elyase
Copy link
Contributor

@elyase elyase commented Sep 8, 2024

Fixes an error when tracking in the hamilton ui with polars dataframes:

    return col.str.lengths()
           ^^^^^^^^^^^^^^^
AttributeError: 'StringNameSpace' object has no attribute 'lengths'

Changes

Use the correct polars method

How I tested this

Run the code and it doesn't error anymore

Notes

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

Fix error  when tracking with polars dataframes:

```
    return col.str.lengths()
           ^^^^^^^^^^^^^^^
AttributeError: 'StringNameSpace' object has no attribute 'lengths'
```
@elijahbenizzy
Copy link
Collaborator

Hey! Thanks for this -- seems reasonable on first glance.

Two thoughts:

  1. Is this due a polars version? Might be that it used to work.
  2. Looks like this was not added in the tests, so my guess on (1) is it never worked: https://github.com/DAGWorks-Inc/hamilton/blob/004ac5e4efd8aefa45a1888b3c2df375f2843370/ui/sdk/tests/tracking/test_polars_col_stats.py Would be nice to have tests (if you want to add, should be easy to copy/paste/adjust those), but I don't want this to be a blocker to you getting your fix in.

So if you're up to the challenge of adding tests feel free to, otherwise we can add some a bit later.

@elyase
Copy link
Contributor Author

elyase commented Sep 10, 2024

@elijahbenizzy yes the names changed after polars==0.18. I added a test for the fix

@elijahbenizzy
Copy link
Collaborator

@elijahbenizzy yes the names changed after polars==0.18. I added a test for the fix

Great -- this looks good. Mind running pre-commit changes? pre-commit run --all should do it. Then we'll merge! Appreciate the fix/test 🙌

@elyase
Copy link
Contributor Author

elyase commented Sep 10, 2024

✔️ thanks to you all for hamilton!

Copy link
Collaborator

@elijahbenizzy elijahbenizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! Can do a quick patch release for the SDK shortly.

@elijahbenizzy elijahbenizzy merged commit e320a95 into DAGWorks-Inc:main Sep 10, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants