MAINT: improver save refactor and support for overriding all arguments - #2412
MAINT: improver save refactor and support for overriding all arguments#2412cpelley wants to merge 9 commits into
Conversation
4ef64eb to
79b0a0c
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors improver.utilities.save.save_netcdf to better align with iris.fileformats.netcdf.save, primarily by forwarding arbitrary keyword arguments and documenting where IMPROVER’s defaults differ (eg compression/chunking defaults).
Changes:
- Reworks
save_netcdfto accept**kwargsfor forwarding toiris.fileformats.netcdf.save, including chunking overrides. - Introduces argument-normalisation for compression (
compression_leveldeprecation in favor ofcomplevel) and forzlib/shuffledefaults. - Uses
as_cubelistto standardise cube/cubelist input handling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Putting this back into draft for the mo. @JoshuaWiggs |
|
Nearly there. Interestingly just dealing with an erroneous segmentation fault in the unittests... === 7829 passed, 793 skipped, 1 xpassed, 3481 warnings in 208.39s (0:03:28) ====
Fatal Python error: Segmentation fault
Current thread 0x00007f7fdf075440 (most recent call first):
Garbage-collecting
<no Python frame>
/home/runner/work/_temp/69157979-fe09-48e0-af0b-b6ae4177db62: line 2: 2575 Segmentation fault (core dumped) python -u -X faulthandler -m pytest -p no:faulthandler |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (1)
improver/utilities/save.py:109
save_netcdf's new parameters (zlib,shuffle,chunksizes) are positional by default, which can silently mis-route existing positional calls from the old signature (eg a previousleast_significant_digitpositional arg would now be interpreted aszlib). Consider making all parameters aftercomplevelkeyword-only to avoid accidental positional misuse.
complevel: int = 1,
zlib: bool | None = None,
shuffle: bool = True,
chunksizes: tuple | None = None,
**kwargs,
This change retains support for existing use of save while aligning it with
iris.fileformats.netcdf.saveEnables projects which utilise this function to override the chunking in particular (motivated by EPP).
save_netcdfnow passes kwargs to the underlyingiris.fileformats.netcdf.savefunction.save_netcdfcall permutations missing from testing are now tested.compression_levelkeyword argument fromsave_netcdfstill supported and takes precedence but is deprecated in order to better align with its name fromiris.fileformats.netcdf.save(i.e.complevel).with_outputfromimprover/cli/__init__.pyhas been updated to callsave_netcdfwithcomplevelbutcompression_levelkeyword argument has been kept the same here so as not to break existing workflows that are reliant on the cli (clize, paraflow).