Add version check caching, fix version comparison#1835
Merged
thealligatorking merged 15 commits intoopentensor:stagingfrom May 14, 2024
Merged
Conversation
Contributor
|
@olzhasar-reef thank you for the contribution! |
Contributor
|
@ibraheem-opentensor do you mind testing this when you get a chance? |
ibraheem-abe
reviewed
May 7, 2024
| def test_get_and_save_latest_version_file_fresh_check( | ||
| mock_get_version_from_pypi: MagicMock, version_file_path: Path, elapsed: int | ||
| ): | ||
| now = datetime.utcnow() |
Contributor
There was a problem hiding this comment.
Thank you for your contribution!
utcnow() is depreciated (link)
Maybe we can use datetime.now(timezone.utc)
Contributor
|
@gus-opentensor Lgtm! |
thealligatorking
approved these changes
May 13, 2024
…e/version-check-cache
Contributor
Author
|
@gus-opentensor I've merged recent changes from the staging branch addressing conflicts. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the following changes:
Currently, version checking works by making an HTTP request to PyPI on every call. To avoid repetitive network requests, we implement a caching mechanism using a local file, ensuring that requests are only made once a day at most.
The current version comparison logic relies on integer comparisons, which do not support letters and may lead to errors in cases like "6.0.15" vs "6.1.0". The new comparison mechanism is more robust and powered by the version handling capabilities of the packaging library.
version_checkingsilent failure issue:The CLI module includes logic for displaying an error message with a tip to disable version checking in case of a network request failure. However, this code is unreachable due to version checking failing silently.
This PR introduces a new
check_versionfunction with a custom exception. The old behavior is retained with a display of a deprecation warning.The new function name should also be more descriptive to an end user.