Skip to content

Commit c903d4a

Browse files
committed
PreloadDataStore added
1 parent 41e9c05 commit c903d4a

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

xcube/core/store/preload.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ def __repr__(self):
7575

7676

7777
class PreloadHandle(ABC):
78-
"""A handle for a preload job.
79-
80-
Instances of this class are returned by the
81-
``DataStore.preload_data()`` method.
82-
"""
78+
"""A handle for a preload job."""
8379

8480
@abstractmethod
8581
def get_state(self, data_id: str) -> PreloadState:

xcube/core/store/store.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def preload_data(
487487
self,
488488
*data_ids: str,
489489
**preload_params: Any,
490-
) -> PreloadHandle:
490+
) -> "PreloadDataStore":
491491
"""Preload the given data items for faster access.
492492
493493
Warning: This is an experimental and potentially unstable API
@@ -512,9 +512,10 @@ def preload_data(
512512
A handle for the preload process. The default implementation
513513
returns an empty preload handle.
514514
"""
515-
return NullPreloadHandle()
516-
517-
# noinspection PyMethodMayBeStatic
515+
cache_store = new_data_store("file")
516+
cache_store.preload_handle = NullPreloadHandle()
517+
assert isinstance(cache_store, PreloadDataStore)
518+
return cache_store
518519

519520

520521
class MutableDataStore(DataStore, DataWriter, ABC):
@@ -690,3 +691,22 @@ def deregister_data(self, data_id: str):
690691
Raises:
691692
DataStoreError: If an error occurs.
692693
"""
694+
695+
696+
class PreloadDataStore(MutableDataStore):
697+
"""A preload data store is a multable data store which contains the preload handle.
698+
699+
Instances of this class are returned by the ``DataStore.preload_data()`` method.
700+
"""
701+
702+
@property
703+
@abstractmethod
704+
def preload_handle(self) -> PreloadHandle:
705+
"""This field must be defined and set in subclasses."""
706+
pass
707+
708+
@preload_handle.setter
709+
@abstractmethod
710+
def preload_handle(self, value: PreloadHandle) -> None:
711+
"""Setter for preload_handle."""
712+
pass

xcube/util/cache.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,7 @@ def _compute_object_size(obj):
439439
else (
440440
3
441441
if m in ("RGB", "YCbCr", "LAB", "HSV")
442-
else 1.0 / 8.0
443-
if m == "1"
444-
else 1
442+
else 1.0 / 8.0 if m == "1" else 1
445443
)
446444
)
447445
)

xcube/util/dask.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ def new_cluster(
218218
cluster_account = (
219219
account
220220
if account is not None
221-
else account_from_env_var
222-
if account_from_env_var is not None
223-
else "bc"
221+
else account_from_env_var if account_from_env_var is not None else "bc"
224222
)
225223

226224
if provider == "coiled":

0 commit comments

Comments
 (0)