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

[FEA]: pre-commit reminders when pandas/polars dependencies get out of sync with "version" compat flags #16736

Open
wence- opened this issue Sep 4, 2024 · 0 comments
Assignees

Comments

@wence-
Copy link
Contributor

wence- commented Sep 4, 2024

We maintain, in cudf-classic, cudf.pandas, and cudf-polars, a list of parsed version constants that are used to match behaviour with particular pandas/polars versions: perhaps an attribute only exists in a particular version.

It would be nice if there was some way of reminding us to clean the old ones of these out whenever we bump the minimum polars/pandas version. I spent a bit trying to come up with a precommit hook that would do this for us. I ended up with basically this (run from a bash script that fails pre-commit)

import toml
import re
from packaging.version import parse

file = toml.load('pyproject.toml')
dependencies = file['project']['dependencies']

polars_version = None
for dep in dependencies:
    if 'polars' in dep:
        polars_version = dep
        break


pat = r'parse\("([0-9]+\.[0-9]+(\.[0-9]+)?)"\)'
with open("./cudf_polars/utils/versions.py", 'r') as file:
    content = file.read()
    matches = re.findall(pat, content)
    versions = [match[0] for match in matches]

min_version = polars_version.split('>=')[1]

for ver in versions:
    if parse(ver) < parse(min_version):
        raise ValueError

Originally posted by @brandon-b-miller in #16719 (comment)

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

No branches or pull requests

2 participants