-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Refactor version checking into a utility #395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some nits to the doc, but otherwise looks great! Thanks for working on this!
Co-authored-by: Sylvain Gugger <[email protected]>
Refactor version checking into a utility
What does this add?
This PR adds two new functions:
compare_versions
check_torch_version
Which checks a particular version, querying with a string of the comparitor (such as "<" or ">=" or "!=")
Why is it needed?
I was noticing we do a lot of checks with
version.parse
in the code, and we already had a versions submodule for getting the current torch version. As a result, it made sense to expand this utility further to have it check for all of our torch versions.Also considering that most of them are comparing the torch version specifically, I added a
check_torch_version
which shorthands the query on the user.What parts of the API does this impact?
User-facing:
Nothing
Internal structure:
Modifies all version checks to use
compare_versions
orcheck_torch_version
Basic Usage Example(s):
For checking a non-torch library:
For checking a torch version: