Repository: dask/dask
Pull request #11620 (2024-12-20 17:27:21)

Avoid using `concrete` in task graph
This appears to be entirely superfluous.

- [ ] Partially addresses #11619
- [ ] Tests added / passed
- [ ] Passes `pre-commit run --all-files`


github-actions[bot]: ## Unit Test Results
_See [test report](https://dask.github.io/dask/test_report.html) for an extended history of previous test failures. This is useful for diagnosing flaky tests._

     15 files  ±0       15 suites  ±0   3h 59m 45s ⏱️ + 3m 7s
 12 611 tests ±0   11 448 ✅ ±0   1 163 💤 ±0  0 ❌ ±0 
156 885 runs  ±0  140 229 ✅  - 4  16 656 💤 +4  0 ❌ ±0 

Results for commit 637e8631. ± Comparison against base commit 16b986ef.

[test-results]:data:application/gzip;base64,H4sIAGGxZWcC/02Nyw6DIBBFf8Ww7kJeA+3PNIiQkKo0PFZN/71AFV1NzrnJmQ+ybjERPQbMbwOK2aWT5hxUcn6rzKisqqyp7QQwPvgZs9ZVYsbkKV/u3STQ7qxyS3FjFyYEH3YT8vZ/DbL9qtzTbCTk3uWeBuBwuEu68bWs/bq6VAABFUYCxeVwZaSiYhq5KXUprGBEAJ3tNFuMvj+lMe+AGgEAAA==


Patch:
diff --git a/dask/array/core.py b/dask/array/core.py
index 7dfff2b0f..898f5a33e 100644
--- a/dask/array/core.py
+++ b/dask/array/core.py
@@ -3329,7 +3329,8 @@ def auto_chunks(chunks, shape, limit, dtype, previous_chunks=None):
                             new_chunk += c
                         else:
                             # We reach the boundary so start a new chunk
-                            dimension_result.append(new_chunk)
+                            if new_chunk > 0:
+                                dimension_result.append(new_chunk)
                             new_chunk = c
                     if new_chunk > 0:
                         dimension_result.append(new_chunk)
diff --git a/dask/layers.py b/dask/layers.py
index e4a88f90b..0d9ce59fb 100644
--- a/dask/layers.py
+++ b/dask/layers.py
@@ -14,7 +14,7 @@ from dask.blockwise import Blockwise, BlockwiseDep, BlockwiseDepDict, blockwise_
 from dask.core import flatten
 from dask.highlevelgraph import Layer
 from dask.tokenize import normalize_token
-from dask.utils import cached_cumsum, concrete
+from dask.utils import cached_cumsum
 
 if TYPE_CHECKING:
     import numpy as np
@@ -238,7 +238,7 @@ class ArrayOverlapLayer(Layer):
                 interior_slices[(getitem_name,) + k] = (name,) + k
                 overlap_blocks[(overlap_name,) + k] = (
                     concatenate3,
-                    (concrete, expand_key2((None,) + k, name=getitem_name)),
+                    expand_key2((None,) + k, name=getitem_name),
                 )
 
         dsk = toolz.merge(interior_slices, overlap_blocks)


Test patch:
diff --git a/dask/array/tests/test_array_core.py b/dask/array/tests/test_array_core.py
index 228dbccb9..de1f1ee29 100644
--- a/dask/array/tests/test_array_core.py
+++ b/dask/array/tests/test_array_core.py
@@ -3077,6 +3077,15 @@ def test_align_chunks_to_previous_chunks():
     assert all(c % 512 == 0 for c in chunks[1][:-1])
     assert all(c % 512 == 0 for c in chunks[2][:-1])
 
+    chunks = normalize_chunks(
+        "auto",
+        shape=(48, 720, 1440),
+        previous_chunks=((36, 12), (720,), (1440,)),
+        limit=134217728,
+        dtype=np.float32,
+    )
+    assert chunks == ((36, 12), (720,), (1440,))
+
 
 def test_raise_on_no_chunks():
     x = da.ones(6, chunks=3)