From a7409f6c49f2479a44c98896cc93c1a7b404d202 Mon Sep 17 00:00:00 2001 From: konstntokas Date: Wed, 11 Dec 2024 16:32:17 +0100 Subject: [PATCH] yogesh pr addressed --- examples/zenodo_data_store_preload.ipynb | 28 ++++++++++++------------ xcube_zenodo/_utils.py | 6 ++--- xcube_zenodo/preload.py | 8 +++---- xcube_zenodo/store.py | 6 ++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/zenodo_data_store_preload.ipynb b/examples/zenodo_data_store_preload.ipynb index 1ea6038..2bf61b1 100644 --- a/examples/zenodo_data_store_preload.ipynb +++ b/examples/zenodo_data_store_preload.ipynb @@ -31,8 +31,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 2.91 s, sys: 193 ms, total: 3.1 s\n", - "Wall time: 1.24 s\n" + "CPU times: user 2.5 s, sys: 422 ms, total: 2.92 s\n", + "Wall time: 2.65 s\n" ] } ], @@ -65,8 +65,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 33.9 ms, sys: 7.05 ms, total: 40.9 ms\n", - "Wall time: 40.2 ms\n" + "CPU times: user 40.8 ms, sys: 10.6 ms, total: 51.4 ms\n", + "Wall time: 61.2 ms\n" ] }, { @@ -90,7 +90,7 @@ "type": "object" }, "text/plain": [ - "" + "" ] }, "execution_count": 2, @@ -113,15 +113,15 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 5.04 ms, sys: 4 μs, total: 5.05 ms\n", - "Wall time: 4.98 ms\n" + "CPU times: user 8.1 ms, sys: 43 μs, total: 8.14 ms\n", + "Wall time: 7.66 ms\n" ] } ], @@ -140,15 +140,15 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 30 μs, sys: 2 μs, total: 32 μs\n", - "Wall time: 34.1 μs\n" + "CPU times: user 68 μs, sys: 11 μs, total: 79 μs\n", + "Wall time: 83.7 μs\n" ] }, { @@ -172,10 +172,10 @@ "type": "object" }, "text/plain": [ - "" + "" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -195,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { diff --git a/xcube_zenodo/_utils.py b/xcube_zenodo/_utils.py index a630d43..6468a4f 100644 --- a/xcube_zenodo/_utils.py +++ b/xcube_zenodo/_utils.py @@ -66,7 +66,7 @@ def get_attrs_from_record( return attrs -def estimate_file_format(data_id: str) -> Union[str, None]: +def identify_file_format(data_id: str) -> Union[str, None]: for key, val in MAP_FILE_EXTENSION_FORMAT.items(): if data_id.endswith(key.lower()): return val @@ -74,11 +74,11 @@ def estimate_file_format(data_id: str) -> Union[str, None]: def is_supported_file_format(data_id: str) -> bool: - return estimate_file_format(data_id) is not None + return identify_file_format(data_id) is not None def is_supported_compressed_file_format(data_id: str) -> bool: - return estimate_file_format(data_id) in COMPRESSED_FORMATS + return identify_file_format(data_id) in COMPRESSED_FORMATS def translate_data_id2fs_path(data_id: str) -> str: diff --git a/xcube_zenodo/preload.py b/xcube_zenodo/preload.py index ff1387f..656b36e 100644 --- a/xcube_zenodo/preload.py +++ b/xcube_zenodo/preload.py @@ -37,7 +37,7 @@ from xcube.core.store import DataStoreError from xcube.core.store import MutableDataStore -from ._utils import estimate_file_format +from ._utils import identify_file_format from ._utils import translate_data_id2uri LOG = logging.getLogger(__name__) @@ -49,7 +49,7 @@ def __init__(self, data_id: str, total_size: Union[int, float]): self.data_id = data_id self.status = "Not started" self.progress = 0.0 - self.message = "Preloading not started jet." + self.message = "Preloading not started yet." self.total_size = total_size self._callback = None @@ -114,7 +114,7 @@ def close(self): self._cache_store.delete_data(event.data_id) else: record, filename = event.data_id.split("/") - format_id = estimate_file_format(event.data_id) + format_id = identify_file_format(event.data_id) dirname = filename.replace(f".{format_id}", "") data_id_mod = f"{record}/{dirname}" list_data_ids = self._cache_store.list_data_ids() @@ -247,7 +247,7 @@ def prepare(): time.sleep(1) self._events[i].update("File processing started", np.nan, "") record, filename = data_id.split("/") - format_id = estimate_file_format(data_id) + format_id = identify_file_format(data_id) dirname = filename.replace(f".{format_id}", "") extract_dir = os.path.join(self._download_folder, record, dirname) dss = [] diff --git a/xcube_zenodo/store.py b/xcube_zenodo/store.py index ea504f9..76e046b 100644 --- a/xcube_zenodo/store.py +++ b/xcube_zenodo/store.py @@ -42,7 +42,7 @@ from .constants import COMPRESSED_FORMATS from .constants import PRELOAD_CACHE_FOLDER from .preload import PreloadHandle -from ._utils import estimate_file_format +from ._utils import identify_file_format from ._utils import get_attrs_from_record from ._utils import is_supported_file_format from ._utils import is_supported_compressed_file_format @@ -161,7 +161,7 @@ def get_open_data_params_schema( def open_data( self, data_id: str, opener_id: str = None, **open_params ) -> xr.Dataset: - format_id = estimate_file_format(data_id) + format_id = identify_file_format(data_id) if format_id in COMPRESSED_FORMATS: if not self.cache_store.has_data(data_id): raise DataStoreError( @@ -186,7 +186,7 @@ def preload_data(self, *data_ids: str, **preload_params) -> PreloadHandle: preload_params["monitor_preload"] = preload_params.get("monitor_preload", True) data_ids_sel = [] for data_id in data_ids: - format_id = estimate_file_format(data_id) + format_id = identify_file_format(data_id) data_id_mod = data_id.replace(f".{format_id}", "/") list_data_ids = self.cache_store.list_data_ids() list_data_ids_mod = [i for i in list_data_ids if data_id_mod in i]