diff --git a/hub/api/info.py b/hub/api/info.py index e1ba9b2586..383edb7716 100644 --- a/hub/api/info.py +++ b/hub/api/info.py @@ -1,5 +1,4 @@ from hub.core.storage.lru_cache import LRUCache -from hub.util.json import validate_is_jsonable from typing import Any, Dict from hub.core.storage.cachable import CachableCallback, use_callback diff --git a/hub/constants.py b/hub/constants.py index e4c6e7bc97..52787be452 100644 --- a/hub/constants.py +++ b/hub/constants.py @@ -35,11 +35,11 @@ DEFAULT_LOCAL_CACHE_SIZE = 0 -# meta is 100% required hub-defined meta +# meta is hub-defined information, necessary for hub Datasets/Tensors to function DATASET_META_FILENAME = "dataset_meta.json" TENSOR_META_FILENAME = "tensor_meta.json" -# info is 100% optional user-defined information +# info is user-defined information, entirely optional. may be used by the visualizer DATASET_INFO_FILENAME = "dataset_info.json" TENSOR_INFO_FILENAME = "tensor_info.json" diff --git a/hub/core/storage/cachable.py b/hub/core/storage/cachable.py index 24bda46b5d..4a40f0c6c2 100644 --- a/hub/core/storage/cachable.py +++ b/hub/core/storage/cachable.py @@ -86,9 +86,9 @@ def __init__(self): self._cache = None def _is_callback_initialized(self) -> bool: - key_ex = self._key is not None - cache_ex = self._cache is not None - return key_ex and cache_ex + key_exists = self._key is not None + cache_exists = self._cache is not None + return key_exists and cache_exists def initialize_callback_location(self, key, cache): """Must be called once before any other method calls. diff --git a/hub/util/json.py b/hub/util/json.py deleted file mode 100644 index 9638cb1e2b..0000000000 --- a/hub/util/json.py +++ /dev/null @@ -1,21 +0,0 @@ -import json -from typing import Any - - -def validate_is_jsonable(key: str, item: Any): - """Validates if `item` can be parsed with the `json` package. - - Args: - key (str): Key for the item. This is printed in the exception. - item (Any): `item` that should be parsable with the `json` package. - - Raises: - ValueError: If `item` is not `json` parsable. - """ - - try: - json.dumps(item) - except Exception: - raise ValueError( - f"Item for key='{key}' is not JSON serializable. Got: type={type(item)}, item={item}" - )