iris.save(..., compute=False) returns a tuple, not the documented Delayed
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- api, documentation
Direzione di ricerca
Start with lib/iris/fileformats/netcdf/saver.py, lib/iris/AGENTS.md, and the existing integration test in lib/iris/tests/integration/netcdf/test_delayed_save.py. Compare delayed_completion and save() with the user-manual example in docs/src/user_manual/explanation/real_and_lazy_data.rst. Done means the chosen return-value contract is covered by a test and the affected annotations, docstrings, and manual instructions agree with it.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
iris.save(..., compute=False) no longer returns a dask.delayed.Delayed. It
returns a tuple of dask.array.Array, so the documented
result.compute() idiom raises AttributeError.
The code change was deliberate and correct — #6451 adapted Iris to
dask/dask#11844 for Dask 2025.4
compatibility. What was missed is that the return value of a public API
changed shape at the same time, and several docstrings plus a user manual page
still describe the old contract.
Reproducer
import dask.array as da, iris
from iris.cube import Cube
cube = Cube(da.ones((4, 4), chunks=(2, 2), dtype="f4"), var_name="x")
result = iris.save([cube], "out.nc", compute=False)
type(result) # <class 'tuple'> -- documented as dask.delayed.Delayed
result.compute() # AttributeError: 'tuple' object has no attribute 'compute'
import dask
dask.compute(result) # works
Verified against dask 2026.7.1. da.store(sources, targets, compute=False)
returns a Delayed only when sources is a single array; for a sequence — which
is what Saver.delayed_completion always passes — it returns a tuple.
What is stale
| Location | Says |
|---|---|
lib/iris/fileformats/netcdf/saver.py:2658 |
def delayed_completion(self) -> Delayed: — the annotation is now wrong |
lib/iris/fileformats/netcdf/saver.py:2661,2666 |
docstring and Returns promise a Delayed |
lib/iris/fileformats/netcdf/saver.py:2855,2870-2872 |
save() docstring and Returns promise a Delayed |
docs/src/user_manual/explanation/real_and_lazy_data.rst:270 |
"the :meth:~iris.save call returns a result which is a :class:~dask.delayed.Delayed object" |
docs/src/user_manual/explanation/real_and_lazy_data.rst:272 |
"the save can be completed later by calling result.compute()" — this instruction is the one that actually fails |
The What's New example in docs/src/whatsnew/3.6.rst is fine: it uses
dask.compute(*delayeds), which works with either shape.
Why it was not caught
#6451 also relaxed the assertion in
lib/iris/tests/integration/netcdf/test_delayed_save.py, replacing
assert isinstance(result, Delayed) with a helper that accepts either a dask
collection or a sequence of them:
def are_dask_collections(obj):
result = dask.is_dask_collection(obj)
if not result and hasattr(obj, "__len__"):
result = all([dask.is_dask_collection(item) for item in obj])
return result
That was a reasonable way to unblock the Dask upgrade, but it means no test
pins the return type, and no test exercises result.compute() — every internal
caller, including Saver.complete, uses dask.compute().
Suggested resolution
Two options, and I'd suggest the first:
-
Restore the documented contract. Wrap the
da.storeresult so
delayed_completionreturns a realDelayedagain. Bothresult.compute()
anddask.compute(result)then work, the annotation becomes true, no
documentation changes, andiris.savekeeps returning one documented type
(perlib/iris/AGENTS.md, "Return one documented type"). A tuple of
dask.array.Arrayis also a leaked implementation detail ofda.store
rather than an intended public return value. -
Accept the new shape and fix the docs, describing the result as a dask
collection or sequence of them, completed withdask.compute(result). This
is less work but leaves a silently-changed public return type, and the
user manual'sresult.compute()step has to go.
Either way the test should pin the choice, and real_and_lazy_data.rst needs
updating.
Context
Found while specifying native Zarr I/O (#6961), where the saver's deferred-write
machinery is being generalised and would otherwise inherit the same shape. That
work does not fix this — the relocation is deliberately behaviour-preserving —
so it is raised separately here.
Investigated and written by Claude (Anthropic), working with @bjlittle.
- Lingua principale
- Python
- Stelle
- 730
- Fork
- 323
- Merge medio
- 3g 21h
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di SciTools/iris
-
Link Checker ReportForse già presa @stephenworsley l’ha presa 12 giorni fa. ApertaBot Type: Bug Type: Documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
SciTools/iris#7368 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
guess_bounds(yearly=True) fails on a single point, monthly=True worksForse già presa @pp-mo l’ha presa 47 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
SciTools/iris#7311 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Agentic
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di SciTools/iris
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Maintainer] task area:visualizer
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
RailtownAI/railtracks#1824 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
apache/datafusion#27688 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
mloda-ai/mloda-registry#1664 ·
I maintainer di solito rispondono entro 1 giorno