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

Add ruff linter #201

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Add ruff linter #201

wants to merge 18 commits into from

Conversation

ksimpson-work
Copy link
Contributor

@ksimpson-work ksimpson-work commented Oct 30, 2024

Add Ruff linter and format to pre-commit-hooks + make the appropriate changes in the code base so that we start with a passing commit.

some per-file ignores have been added, and some globals. I think these can be a work in progress, and I used my best judgement, but I would love to hear feedback.

Depends on #203

The only real bug this exposes is #203 which I am addressing in a separate PR and issue for cleanliness

Closes #195

Copy link

copy-pr-bot bot commented Oct 30, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work ksimpson-work requested review from vzhurba01, leofang and rwgk and removed request for vzhurba01 October 30, 2024 20:43
@ksimpson-work ksimpson-work marked this pull request as ready for review October 30, 2024 20:43
@ksimpson-work
Copy link
Contributor Author

The actions seem to be broken as of a long time ago. The culprit being a faulty build command which looks for setup.py in cuda-python top level directory. I'm wondering if that will be addressed by QA, or if I/someone should fix it.

@ksimpson-work ksimpson-work marked this pull request as draft October 30, 2024 20:48
Copy link
Collaborator

@vzhurba01 vzhurba01 left a comment

Choose a reason for hiding this comment

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

I couple of comments:

  1. Once you're ready, can you try testing the builds and tests across our supported Python versions (3.9 to 3.12) and 3.13? For the bindings just doing 3.9 and 3.13 is probably sufficient(?), just because the build there takes a while. In the past some of my own code formats had issues for certain versions, so some paranoia is creeping in. Surely since this is a linter all of that ought to be ok, but still 🙂.
  2. Would need a follow-up PR into the 11.8.x branch. Just an FYI for when the time comes. Actually no, this shouldn't be necessary since the only change expected on that branch are the bindings which aren't covered by the linter anyways. The only items remaining would be the tests/examples, but that is expected to stay the same.

cuda_bindings/pyproject.toml Outdated Show resolved Hide resolved
cuda_bindings/cuda/bindings/_version.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_device.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_event.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_launcher.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_stream.py Outdated Show resolved Hide resolved
cuda_core/tests/example_tests/test_basic_examples.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

Looks good to me, but what do you think about splitting this PR into two parts:

  1. Add tox testing only.
  2. Add ruff only with the tox testing in place already.

That would make it easier** to see what changes (if any?) are required to establish tox testing, and what changes are a consequence of introducing ruff.

easier** in the future, in case we have to backtrack for whatever reason.

.pre-commit-config.yaml Outdated Show resolved Hide resolved
@ksimpson-work
Copy link
Contributor Author

@vzhurba01 The changes have been verified against python 3.9 and 3.13 successfully.

rwgk
rwgk previously approved these changes Nov 1, 2024
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

Another idea borrowed from pybind11:

https://github.com/pybind/pybind11/blob/75e48c5f959b4f0a49d8c664e059b6fb4b497102/.github/workflows/format.yml#L24-L37

This ensures that all PRs pass the pre-commit checks.

I didn't see that here. I'm not sure if you have another way of achieving the same?

@leofang leofang added this to the cuda.core beta 2 milestone Nov 2, 2024
@ksimpson-work ksimpson-work marked this pull request as ready for review November 4, 2024 17:20
@ksimpson-work ksimpson-work changed the title Ksimpson/ruff linter add ruff linter Nov 4, 2024
@ksimpson-work ksimpson-work changed the title add ruff linter Add ruff linter Nov 4, 2024
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.

Introduce code linters to the repo
4 participants