-
Notifications
You must be signed in to change notification settings - Fork 334
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
Add version check caching, fix version comparison #1835
Add version check caching, fix version comparison #1835
Conversation
@olzhasar-reef thank you for the contribution! |
@ibraheem-opentensor do you mind testing this when you get a chance? |
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() |
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.
Thank you for your contribution!
utcnow()
is depreciated (link)
Maybe we can use datetime.now(timezone.utc)
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.
Sure, fixed
@gus-opentensor Lgtm! |
…e/version-check-cache
@gus-opentensor I've merged recent changes from the staging branch addressing conflicts. |
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_checking
silent 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_version
function 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.