Rework the netCDF saver's createVariable keyword API

Abierto
#7,328 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
api, backend

Línea de trabajo

Start by reading the netCDF save API in iris.fileformats.netcdf and the public iris.save interface, then review ChunkControl and the linked Zarr I/O design discussion (#7292). The issue describes a breaking API change that needs a deprecation path and further discussion; a concrete implementation boundary and acceptance criteria are not settled.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Feature: NetCDF + CF-conventions Status: Decision Required Type: Tech Debt

(posted by Claude Opus)

Raised from @pp-mo's review of the Zarr I/O design spec: https://github.com/SciTools/iris/pull/7292#discussion_r4155142914

The problem

iris.fileformats.netcdf.save names every netCDF4 createVariable keyword in its own signature — zlib, complevel, shuffle, fletcher32, contiguous, chunksizes, endian, least_significant_digit — and threads each one down through several call layers to the point of use. All of them are also reachable from iris.save(cube, "out.nc", zlib=True).

@pp-mo's objection, in his words:

Frankly, I don't like the existing API and I wonder if all this is just bending over backwards to maintain it ??? It "would have been" better, in my (retrospective!) view, to not name all the available netCDF createVariable keywords in our API, and instead support any arbitrary keywords not specifically managed by Iris, as a pass-through. Although .. it is still necessary to have a mechanism for providing controls on a per-variable (i.e. per-cube) basis. Even there, I think that the CHUNK_CONTROL demonstrates a much better way of managing this kind of thing --- notably, a context-manager rather than specific 'tunnel-through' keywords passed unmodified through multiple call layers.

Three things fall out of the current shape:

  1. Every new netCDF4 keyword is an Iris API change, and every keyword Iris names is one it has to keep naming.
  2. The keywords are per-call, not per-cube, so iris.save(cubes, "out.nc", complevel=4) applies one setting to every cube in the list. Per-variable control needs a dict-valued keyword, which is the workaround that exists today.
  3. The values travel through functions that have no interest in them, which is the thing CHUNK_CONTROL was introduced to stop doing for chunking.

The suggested direction

Pass arbitrary unrecognised keywords through to createVariable rather than enumerating them, and express per-variable control the way ChunkControl does — a context manager scoped around the save, matching variables by name.

Scope and caution

This is a breaking change, and unlike most of iris.fileformats.netcdf it is not confined to super-users: iris.save(cube, "out.nc", zlib=True) is documented and ordinary. It needs its own deprecation path, and probably its own discussion before any of that.

It is explicitly out of scope for the Zarr I/O programme (#6961). That programme does take one decision in its shadow: the Zarr saver will accept Zarr-native keywords (compressors, chunks, shards) rather than translating netCDF ones onto codecs, so new API does not inherit the pattern. A netCDF keyword passed to the Zarr saver raises TypeError naming the Zarr replacement.

Lenguaje dominante
Python
Estrellas
730
Forks
323
Merge medio
3 d 21 h
PR fusionados (30 d)
16

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de SciTools/iris

Todos los issues de SciTools/iris

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.