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

Update pre-commit to use pinned version of dvc and correct stage names #10621

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

Conversation

mkdjr
Copy link

@mkdjr mkdjr commented Nov 14, 2024

1. Pin rev argument in pre-commit-config.yaml writer

The pre-commit package recommends against using mutable references such as main, as the version of the package pulled in the hook (in this case dvc), does not get updated after the first time pre-commit installs it. This PR addresses this by instead pinning the hooks to dvc v3.56.0. This change is made with the goal of:

  • removing the pre-commit warning, and
  • adding the ability to automatically update the dvc version that pre-commit refers to when dvc receives a new release.

As a reference, ruff, the python linter and formatter, keeps its pre-commit hooks in a separate repository. This repository has its own pre-commit hooks that automatically pull the latest version of ruff and updates the version pointer in the pre-commit-hooks.yaml file. Maybe dvc could do something like this in the future to automate the pre-commit-hooks.yaml update process.

2. Update stages keywords

Additionally, pre-commit has now deprecated the acceptable values for the stages keyword for hooks. I have updated the dvc install command and the pre-commit-hooks.yaml file to reflect this change.

As this change was made in pre-commit v3.2.0, the dvc hooks now require pre-commit to be updated to at least v3.2.0.

Closes #9897.

Associated documentation PR: iterative/dvc.org#5323.

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 90.67%. Comparing base (2431ec6) to head (08d4f2f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10621      +/-   ##
==========================================
- Coverage   90.68%   90.67%   -0.01%     
==========================================
  Files         504      504              
  Lines       39795    39796       +1     
  Branches     3141     3141              
==========================================
- Hits        36087    36085       -2     
- Misses       3042     3045       +3     
  Partials      666      666              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@shcheklein
Copy link
Member

thanks @mkdjr ! Is it still in draft, needs more testing?

@mkdjr
Copy link
Author

mkdjr commented Nov 14, 2024

Oh yeah, I forgot to take it out of its drafted state. I think it's good to go, but should probably be followed up with a future PR to automate updating the rev field as dvc gets new releases.

@mkdjr mkdjr marked this pull request as ready for review November 14, 2024 20:55
@@ -16,19 +16,19 @@ def pre_commit_install(scm: "Git") -> None:
with modify_yaml(config_path) as config:
entry = {
"repo": "https://github.com/iterative/dvc",
"rev": "main",
"rev": "3.56.0",
Copy link
Member

@skshetry skshetry Nov 15, 2024

Choose a reason for hiding this comment

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

Let's not hardcode version. That will break our release workflow.

Suggested change
"rev": "3.56.0",
"rev": ".".join(map(str, version_tuple[:3])),

You can import this from from dvc import version_tuple.

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.

install: pre-commit: use current version instead of main as a rev
3 participants