-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/combined-dataset-loading-states
- Loading branch information
Showing
29 changed files
with
963 additions
and
52 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
# CI/CD and configs | ||
/.github/ @borda | ||
*.yml @borda | ||
|
||
/src @tchaton |
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ filelock | |
numpy | ||
boto3 | ||
requests | ||
tifffile |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
import time | ||
|
||
__version__ = "0.2.28" | ||
__version__ = "0.2.34" | ||
__author__ = "Lightning AI et al." | ||
__author_email__ = "[email protected]" | ||
__license__ = "Apache-2.0" | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import functools | ||
import warnings | ||
from typing import Any, Optional | ||
|
||
import requests | ||
from packaging import version as packaging_version | ||
|
||
|
||
class WarningCache(set): | ||
"""Cache for warnings.""" | ||
|
||
def warn(self, message: str, stacklevel: int = 5, **kwargs: Any) -> None: | ||
"""Trigger warning message.""" | ||
if message not in self: | ||
self.add(message) | ||
warnings.warn(message, stacklevel=stacklevel, **kwargs) | ||
|
||
|
||
warning_cache = WarningCache() | ||
|
||
__package_name__ = "litdata" | ||
|
||
|
||
@functools.lru_cache(maxsize=1) | ||
def _get_newer_version(curr_version: str) -> Optional[str]: | ||
"""Check PyPI for newer versions of ``litdata``. | ||
Returning the newest version if different from the current or ``None`` otherwise. | ||
""" | ||
if packaging_version.parse(curr_version).is_prerelease: | ||
return None | ||
try: | ||
response = requests.get(f"https://pypi.org/pypi/{__package_name__}/json", timeout=30) | ||
response_json = response.json() | ||
releases = response_json["releases"] | ||
if curr_version not in releases: | ||
# Always return None if not installed from PyPI (e.g. dev versions) | ||
return None | ||
latest_version = response_json["info"]["version"] | ||
parsed_version = packaging_version.parse(latest_version) | ||
is_invalid = response_json["info"]["yanked"] or parsed_version.is_devrelease or parsed_version.is_prerelease | ||
return None if curr_version == latest_version or is_invalid else latest_version | ||
except requests.exceptions.RequestException: | ||
return None | ||
|
||
|
||
def _check_version_and_prompt_upgrade(curr_version: str) -> None: | ||
"""Checks that the current version of ``litdata`` is the latest on PyPI. | ||
If not, warn the user to upgrade ``litdata``. | ||
""" | ||
new_version = _get_newer_version(curr_version) | ||
if new_version: | ||
warning_cache.warn( | ||
f"A newer version of {__package_name__} is available ({new_version}). " | ||
f"Please consider upgrading with `pip install -U {__package_name__}`. " | ||
"Not all functionalities of the platform can be guaranteed to work with the current version.", | ||
) | ||
return |
This file contains 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
Oops, something went wrong.