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

fix: sqlframe false positives in compliance checks #2011

Merged
merged 4 commits into from
Feb 14, 2025

Conversation

camriddell
Copy link
Member

@camriddell camriddell commented Feb 14, 2025

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

In the narwhals.from_native function, sqlframe had to be explicitly checked before the is_compliant* checks due to false positives from hasattr(sqlframe_df, "__narwhals_dataframe__").

  1. Instead we can use inspect.getattr_static (thanks for the suggestion @dangotbanned) to avoid this addition and we can move the sqlframe specific code to be in line with the other backends.

  2. I also added a test to ensure sqlframe cases are handled properly.

  3. I removed a test that will break in the future, this test was passing due to a side effect caused by hasattr on a pandas DataFrame enabling the use of nonhashable values as column names (raised as an issue in pandas BUG: Index.drop_duplicates() is inconsistent for unhashable valuesΒ pandas-dev/pandas#60925)

@camriddell camriddell changed the title fix: compliance checks fail on sqlframe fix: sqlframe false positives in compliance checks Feb 14, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

@MarcoGorelli for the coverage is there a preference among

  1. Add sqlframe to the pytest GitHub CI
  2. Remove this test
  3. pragma: nocover the tests

Copy link
Member

Choose a reason for hiding this comment

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

Just FYI, I am taking a look for how to fully support sqlframe - it's still missing a few features (not many) to pass all our tests. I would say that for now it's ok to pragma: no cover it

Copy link
Member

Choose a reason for hiding this comment

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

definitely interested in testing sqlframe in CI, last time i checked it was too far to being passing - but they've resolved a lot of issues recently, so if we can run them in ci now then that would be great

else for now we can no cover the test

Copy link
Member

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

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

Thanks @camriddell πŸš€ Left a couple of suggestion and (maybe) addressed your question

Copy link
Member

Choose a reason for hiding this comment

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

Just FYI, I am taking a look for how to fully support sqlframe - it's still missing a few features (not many) to pass all our tests. I would say that for now it's ok to pragma: no cover it

@@ -765,6 +741,30 @@ def _from_native_impl( # noqa: PLR0915
level="lazy",
)

# SQLFrame
# This one needs checking before extensions as `hasattr` always returns `True`.
Copy link
Member

Choose a reason for hiding this comment

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

not applicable anymore πŸ˜‰

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

you're a magician πŸͺ„

thanks! this may fix a cudf.pandas issue too!

@MarcoGorelli
Copy link
Member

pending on #2011 (comment) πŸ˜‰

@camriddell
Copy link
Member Author

failing downstream tests seem to be unrelated. I know that panel just released a new version which may have broken marimo if they don't have an upperbound version constraint.

@FBruzzesi
Copy link
Member

Cool thanks! pointblank also just merged a new feature, we can update its dependency on another PR

@FBruzzesi FBruzzesi merged commit 3f174a3 into narwhals-dev:main Feb 14, 2025
26 of 28 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.

4 participants