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

Improve Makefile and code quality #62

Merged
merged 9 commits into from
Dec 30, 2022
Merged

Improve Makefile and code quality #62

merged 9 commits into from
Dec 30, 2022

Conversation

lvwerra
Copy link
Member

@lvwerra lvwerra commented Dec 29, 2022

This PR improves Makefile commands (borrowing from evaluate/datasets) and adds a code quality CI. The last commit fixes the existing code quality issues.

Copy link
Member

@lewtun lewtun 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 improving the quality of the codebase @lvwerra 🕺 ! I left some suggestions to bump to python 3.8 to avoid an annoying refactor when 3.7 dies in 6 months

pip install .[dev]
- name: Check quality
run: |
black --check --line-length 119 --target-version py36 tests trl
Copy link
Member

Choose a reason for hiding this comment

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

If I'm not mistaken, you can just run make quality here. this has the advantage of having a single source of truth for the quality logic

Copy link
Member Author

Choose a reason for hiding this comment

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

done

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
Copy link
Member

Choose a reason for hiding this comment

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

see my comment below about considering v3.8 as the minimum version since this one will be eol in 6 months

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good

Makefile Outdated Show resolved Hide resolved
transformers_model_from_save.state_dict()[key], transformers_model.state_dict()[key]
)
)


class VHeadModelTester(BaseModelTester, unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

not for this pr, but a small nit that being explicit with e.g. ValueHeadModelTester is generally best practice + enables newcomers to easier understand the codebase.

the same nit applies to docstrings using v-head vs value head and filenames like modeling_vhead.py being better named as modeling_value_head.py

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #65 !

@@ -83,25 +90,25 @@ def test_vhead(self):
for model_name in self.all_model_names:
model = AutoModelForCausalLMWithValueHead.from_pretrained(model_name)
self.assertTrue(hasattr(model, "v_head"))

def test_vhead_nb_classes(self):
Copy link
Member

Choose a reason for hiding this comment

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

would this be better?

Suggested change
def test_vhead_nb_classes(self):
def test_vhead_shape(self):

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd address this too in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #65 !

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 30, 2022

The documentation is not available anymore as the PR was closed or merged.

@lvwerra
Copy link
Member Author

lvwerra commented Dec 30, 2022

All comments should be addressed. Also applied the quality to the recent merges.

Copy link
Contributor

@younesbelkada younesbelkada 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 taking care of the code quality!

@lvwerra lvwerra merged commit 20acffc into master Dec 30, 2022
@younesbelkada younesbelkada mentioned this pull request Dec 30, 2022
26 tasks
@kashif kashif deleted the improve-makefile branch December 12, 2023 10:48
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