NVIDIA / NVIDIA/cudf

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

Open
#16,736 0 comments 0 reactions 0 assignees View on GitHub
feature request Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

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)

```python
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 https://github.com/rapidsai/cudf/pull/16719#discussion_r1742796332_

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.