Skip to content

Commit

Permalink
yogesh pr addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Dec 11, 2024
1 parent 2cdf0a1 commit a7409f6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
28 changes: 14 additions & 14 deletions examples/zenodo_data_store_preload.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
],
Expand Down Expand Up @@ -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"
]
},
{
Expand All @@ -90,7 +90,7 @@
"type": "object"
},
"text/plain": [
"<xcube.util.jsonschema.JsonObjectSchema at 0x78c92d5b39e0>"
"<xcube.util.jsonschema.JsonObjectSchema at 0x7069ba9b39e0>"
]
},
"execution_count": 2,
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
},
{
Expand All @@ -172,10 +172,10 @@
"type": "object"
},
"text/plain": [
"<xcube.util.jsonschema.JsonObjectSchema at 0x78c92d652720>"
"<xcube.util.jsonschema.JsonObjectSchema at 0x7069baa53bf0>"
]
},
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -195,7 +195,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down
6 changes: 3 additions & 3 deletions xcube_zenodo/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ 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
return 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

Check warning on line 81 in xcube_zenodo/_utils.py

View check run for this annotation

Codecov / codecov/patch

xcube_zenodo/_utils.py#L81

Added line #L81 was not covered by tests


def translate_data_id2fs_path(data_id: str) -> str:
Expand Down
8 changes: 4 additions & 4 deletions xcube_zenodo/preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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

Check warning on line 54 in xcube_zenodo/preload.py

View check run for this annotation

Codecov / codecov/patch

xcube_zenodo/preload.py#L49-L54

Added lines #L49 - L54 were not covered by tests

Expand Down Expand Up @@ -114,7 +114,7 @@ def close(self):
self._cache_store.delete_data(event.data_id)

Check warning on line 114 in xcube_zenodo/preload.py

View check run for this annotation

Codecov / codecov/patch

xcube_zenodo/preload.py#L110-L114

Added lines #L110 - L114 were not covered by tests
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()
Expand Down Expand Up @@ -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 = []
Expand Down
6 changes: 3 additions & 3 deletions xcube_zenodo/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(

Check warning on line 167 in xcube_zenodo/store.py

View check run for this annotation

Codecov / codecov/patch

xcube_zenodo/store.py#L166-L167

Added lines #L166 - L167 were not covered by tests
Expand All @@ -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]
Expand Down

0 comments on commit a7409f6

Please sign in to comment.