Skip to content

Add version check caching, fix version comparison#1835

Merged
thealligatorking merged 15 commits intoopentensor:stagingfrom
backend-developers-ltd:feature/version-check-cache
May 14, 2024
Merged

Add version check caching, fix version comparison#1835
thealligatorking merged 15 commits intoopentensor:stagingfrom
backend-developers-ltd:feature/version-check-cache

Conversation

@olzhasar-reef
Copy link
Contributor

This PR introduces the following changes:

  1. Version checking cache:
    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.
  2. Improved version comparison:
    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.
  3. Fix for 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.

@thealligatorking
Copy link
Contributor

@olzhasar-reef thank you for the contribution!

@thealligatorking
Copy link
Contributor

@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()
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, fixed

@ibraheem-abe
Copy link
Contributor

@gus-opentensor Lgtm!

@olzhasar-reef
Copy link
Contributor Author

@gus-opentensor I've merged recent changes from the staging branch addressing conflicts.
Let me know if there's anything else preventing from merging this PR.

@thealligatorking thealligatorking merged commit c2545bf into opentensor:staging May 14, 2024
@thealligatorking thealligatorking mentioned this pull request May 17, 2024
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