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

Renovate quality tools #1421

Merged
merged 13 commits into from
Feb 7, 2024
Merged

Renovate quality tools #1421

merged 13 commits into from
Feb 7, 2024

Conversation

akx
Copy link
Contributor

@akx akx commented Jan 31, 2024

This PR:

  • removes old isort configuration that hasn't been in use since 9990189
  • replaces black formatting with ruff format (though black is still a hidden dependency via hf-doc-builder
  • broadens quality controls to everywhere in the repo (since they're instant to run now)
  • conservatively enables the Ruff UP (upgrade) rules and auto-fixes what can be auto-fixed.

This is similar to e.g. huggingface/transformers#27144 and huggingface/diffusers#5841.

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this update, which looks indeed very useful.

Doing a full review is a bit difficult because the diff is so large. Could we maybe add some exceptions to the ruff checks for the time being? Specifically, I'm thinking of:

  1. https://docs.astral.sh/ruff/rules/redundant-open-modes/
  2. https://docs.astral.sh/ruff/rules/utf8-encoding-declaration/
  3. https://docs.astral.sh/ruff/rules/f-string/

This should take care of the majority of changes and thus lead to a much smaller diff and make the review easier. Then I can discuss with my co-maintainers if we want to have these exceptions or not, and if we don't, remove them in a later PR.

@akx
Copy link
Contributor Author

akx commented Feb 6, 2024

@BenjaminBossan Sure! I rebased this and split the single UP autofix commit into multiple, that can be reviewed in GitHub one by one ✨

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks for splitting up the commits. I'll have a discussion with the co-maintainers of the specific rules added here and we'll come back with a conclusion.

src/peft/auto.py Outdated
@@ -50,7 +49,7 @@ class _BaseAutoPeftModel:

def __init__(self, *args, **kwargs):
# For consistency with transformers: https://github.com/huggingface/transformers/blob/91d7df58b6537d385e90578dac40204cb550f706/src/transformers/models/auto/auto_factory.py#L400
raise EnvironmentError(
raise OSError(
Copy link
Member

Choose a reason for hiding this comment

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

As the comment above suggests, let's stick with EnvironmentError, even if it's not the correct error type here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the "consistency" there refers to raising an error in __init__, not the particular error type, but sure, added a commit to noqa that instead.

Copy link
Member

Choose a reason for hiding this comment

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

No, this refers to the type of error. I know because I flagged the error type initially :)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

pyproject.toml Outdated Show resolved Hide resolved
src/peft/auto.py Outdated
@@ -50,7 +49,7 @@ class _BaseAutoPeftModel:

def __init__(self, *args, **kwargs):
# For consistency with transformers: https://github.com/huggingface/transformers/blob/91d7df58b6537d385e90578dac40204cb550f706/src/transformers/models/auto/auto_factory.py#L400
raise EnvironmentError(
raise OSError(
Copy link
Member

Choose a reason for hiding this comment

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

No, this refers to the type of error. I know because I flagged the error type initially :)

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks a lot, the individual changes look sound and after discussing with the co-maintainers, we agree with the rules and exceptions chosen here.

Could you please check the two scripts that have yet to be reformatted according to CI? Thanks.

@akx
Copy link
Contributor Author

akx commented Feb 7, 2024

@BenjaminBossan Done, rebased, removed a couple of ignores by either autofixing or noqa'ing (there are 29 functions that are too complex according to default C901, so not touching those).

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks a lot for moving the code quality checks over completely to ruff. LGTM.

@BenjaminBossan BenjaminBossan merged commit fc78a24 into huggingface:main Feb 7, 2024
14 checks passed
BenjaminBossan added a commit to BenjaminBossan/peft that referenced this pull request Feb 7, 2024
In PR huggingface#1421, ruff was extended to check all directories. This is fine
for those directories that come with PEFT. However, developers may have
other local directories that they do not want to be checked. Therefore,
it is better to list the directories to be checked rather than checking
all.
BenjaminBossan added a commit that referenced this pull request Feb 7, 2024
In PR #1421, ruff was extended to check all directories. This is fine
for those directories that come with PEFT. However, developers may have
other local directories that they do not want to be checked. Therefore,
it is better to list the directories to be checked rather than checking
all.
BenjaminBossan pushed a commit to BenjaminBossan/peft that referenced this pull request Mar 14, 2024
BenjaminBossan added a commit to BenjaminBossan/peft that referenced this pull request Mar 14, 2024
In PR huggingface#1421, ruff was extended to check all directories. This is fine
for those directories that come with PEFT. However, developers may have
other local directories that they do not want to be checked. Therefore,
it is better to list the directories to be checked rather than checking
all.
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.

3 participants