Skip to content

Commit 8546b85

Browse files
author
Thomas Zilio
committed
Making distributed compatible with the delayed parameter and changing the default value of delayed (False if distributed is False, True otherwise).
1 parent abb31b2 commit 8546b85

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

zcollection/collection/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def update(
622622
filters: PartitionFilter | None = None,
623623
trim: bool = True,
624624
npartitions: int | None = None,
625-
delayed: bool = True,
625+
delayed: bool | None = None,
626626
distributed: bool = True,
627627
**kwargs,
628628
) -> None:
@@ -656,6 +656,7 @@ def update(
656656
default, it is equal to the number of Dask workers available
657657
when calling this method.
658658
delayed: Whether to load data in a dask array or not.
659+
Default value is True if distributed is True, False otherwise.
659660
distributed: Whether to use dask or not. Default To True.
660661
**kwargs: The keyword arguments to pass to the function.
661662
@@ -673,9 +674,8 @@ def update(
673674
if not callable(func):
674675
raise TypeError('func must be a callable')
675676

676-
# Delayed has to be False if dask is disabled
677-
if not distributed:
678-
delayed = False
677+
if delayed is None:
678+
delayed = distributed
679679

680680
variables = variables or _infer_callable(
681681
self, func, filters, delayed, selected_variables, *args, **kwargs)

zcollection/collection/abc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def _wrap(
644644
def load(
645645
self,
646646
*,
647-
delayed: bool = True,
647+
delayed: bool | None = None,
648648
filters: PartitionFilter = None,
649649
indexer: Indexer | None = None,
650650
selected_variables: Iterable[str] | None = None,
@@ -656,6 +656,7 @@ def load(
656656
657657
Args:
658658
delayed: Whether to load data in a dask array or not.
659+
Default value is True if distributed is True, False otherwise.
659660
filters: The predicate used to filter the partitions to load. To
660661
get more information on the predicate, see the documentation of
661662
the :meth:`partitions` method.
@@ -683,11 +684,10 @@ def load(
683684
... filters=lambda keys: keys["year"] == 2019 and
684685
... keys["month"] == 3 and keys["day"] % 2 == 0)
685686
"""
686-
array: dataset.Dataset | None = None
687+
if delayed is None:
688+
delayed = distributed
687689

688-
# Delayed has to be False if dask is disabled
689-
if not distributed:
690-
delayed = False
690+
array: dataset.Dataset | None = None
691691

692692
if indexer is None:
693693
arrays = self._load_partitions(

zcollection/view/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def drop_variable(
422422
def load(
423423
self,
424424
*,
425-
delayed: bool = True,
425+
delayed: bool | None = None,
426426
filters: collection.PartitionFilter = None,
427427
indexer: collection.Indexer | None = None,
428428
selected_variables: Iterable[str] | None = None,
@@ -433,6 +433,7 @@ def load(
433433
434434
Args:
435435
delayed: Whether to load data in a dask array or not.
436+
Default value is True if distributed is True, False otherwise.
436437
filters: The predicate used to filter the partitions to select.
437438
To get more information on the predicate, see the
438439
documentation of the :meth:`Collection.partitions
@@ -452,9 +453,8 @@ def load(
452453
>>> view.load(filters="time == '2020-01-01'")
453454
>>> view.load(filters=lambda x: x["time"] == "2020-01-01")
454455
"""
455-
# Delayed has to be False if dask is disabled
456-
if not distributed:
457-
delayed = False
456+
if delayed is None:
457+
delayed = distributed
458458

459459
array: dataset.Dataset | None = None
460460
datasets: list[tuple[dataset.Dataset, str] | None]

0 commit comments

Comments
 (0)