Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for handling zarr urls - #7113

Merged
ukmo-ccbunney merged 33 commits into
SciTools:mainfrom
stephenworsley:zarr_url_support
Jul 27, 2026
Merged

Add support for handling zarr urls#7113
ukmo-ccbunney merged 33 commits into
SciTools:mainfrom
stephenworsley:zarr_url_support

Conversation

@stephenworsley

Copy link
Copy Markdown
Contributor

Closes #6967

@stephenworsley
stephenworsley marked this pull request as draft May 28, 2026 13:10
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.04762% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.34%. Comparing base (149dfd7) to head (ddca8b2).

Files with missing lines Patch % Lines
lib/iris/fileformats/netcdf/saver.py 83.33% 3 Missing ⚠️
lib/iris/loading.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7113      +/-   ##
==========================================
+ Coverage   90.32%   90.34%   +0.02%     
==========================================
  Files          92       92              
  Lines       25284    25342      +58     
  Branches     4719     4731      +12     
==========================================
+ Hits        22838    22896      +58     
  Misses       1675     1675              
  Partials      771      771              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pp-mo

pp-mo commented Jun 10, 2026

Copy link
Copy Markdown
Member

Some Notes

Since @pp-mo @stephenworsley discussed this yesterday, here's my take on some things we found...

  • I pointed out that I'm not too sure about the approach here , because I think it undermines the intent of the "schemes"

    • if done more rigorously, I think it should be possible to supply a url to a remote zarr dataset, similar to the OpenDAP protocol supported by the netcdf file loader
      • .. but I don't know if there's a server solution that actually supports such url-based remote access ?
    • .. and admittedly the whole framework of "schemes" is a bit clunky :
      Notably, in the case of netcdf files, we can access from a filepath, a url, or an open dataset ...
  • we also found that saving to zarr by this means currently fails for lazy data streaming (though OK for all-real data)

    • since we added "deferred writes" for netcdf (Lazy netcdf saves #5191), our standard approach is to create a variable and not write the data. We then close the file, and the proxies re-open it in modify ("r+") mode, to fill in a chunk of data.
    • .. it looks like this simply doesn't work with netCDF4-python any more if it is writing Zarr :
      when such a file is re-opened, no such variable exists (the metadata is not saved ?)
    • .. it's not clear though whether this is an essential limitation of Zarrr itself (controlling metadata cannot exist when there are no recorded chunks for a given array ??). Or possibly, this is just a problem with the netCDF4-python implementation.
    • we could however fix this by giving the 'lazy stream' operation an extra mode control, to be specifically turned on for Zarr ..
      This would use a "da.store" directly when creating the original file, i.e. a "third way" for this code to function, where the 'store' operation is just da.store -- which is exactly what the code used to do before Lazy netcdf saves #5191.
      N.B. I already found in Lazy netcdf saves #5191 that you can't create a write proxy and just 'da.store' it immediately (? at least for process-based/distributed scheduler? ), since it needs to re-open the file with write privilege, which will then fail (since the file is already, or "still" open for write). So, to store immediately, you must call da.store directly.
  • we need to discuss whether this makes this whole approach too awkward for supporting Zarr via this route?
    @ukmo-ccbunney to reconsider versus alternative mechanisms in Zarr I/O #6961 ??

Comment thread lib/iris/fileformats/netcdf/saver.py
scitools-ci[bot]
scitools-ci Bot previously requested changes Jul 17, 2026

@scitools-ci scitools-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Templating

This PR includes changes that may be worth sharing via templating. For each file listed below, please either:

  • Action the suggestion via a pull request editing/adding the relevant file in the SciTools/.github templates/ directory. 1
  • Raise an issue against the SciTools/.github repo for the above action if you really don't have 10mins spare right now. Include an assignee, to avoid it being forgotten.
  • Dismiss the suggestion if the changes are not suitable for templating.

You will need to dismiss this review before this PR can be merged. Recommend the reviewer does this as their final action before merging, as this text will continually update as commits come in.

Template candidates

The following changed files are not currently templated, but their parent directories suggest they may be good candidates for a new template to be created:

Footnotes

  1. Include this text in the PR body to avoid any notifications about applying the template changes back to the source repo!
    @scitools-templating: please no update notification on: iris

Comment thread lib/iris/io/__init__.py
Comment thread lib/iris/io/__init__.py Outdated
Comment thread lib/iris/tests/integration/netcdf/test_nczarr.py Outdated
Comment thread lib/iris/io/__init__.py Outdated
Comment thread lib/iris/fileformats/__init__.py Outdated
Comment thread lib/iris/fileformats/netcdf/ugrid_load.py
Comment thread lib/iris/tests/stock/__init__.py Outdated
Comment thread lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver.py Outdated
Comment thread lib/iris/fileformats/netcdf/saver.py Outdated
Comment thread lib/iris/fileformats/netcdf/loader.py Outdated

@ukmo-ccbunney ukmo-ccbunney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far. Just a few suggestions and comments.

Comment thread lib/iris/fileformats/netcdf/saver.py Outdated
Comment thread lib/iris/fileformats/netcdf/saver.py Outdated
Comment thread lib/iris/fileformats/netcdf/saver.py Outdated
Comment thread lib/iris/fileformats/netcdf/loader.py Outdated
Comment thread lib/iris/fileformats/__init__.py
Comment thread lib/iris/tests/stock/__init__.py
Comment thread lib/iris/tests/test_io_init.py
Comment thread docs/src/user_manual/tutorial/loading_iris_cubes.rst Outdated
Comment thread docs/src/user_manual/tutorial/loading_iris_cubes.rst
Comment thread lib/iris/tests/test_io_init.py Outdated

@ukmo-ccbunney ukmo-ccbunney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought I meant to add to the original review...

Comment thread lib/iris/tests/integration/netcdf/test_nczarr.py

@ukmo-ccbunney ukmo-ccbunney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Everything mostly looks good. I've made a few suggested changes to fix the failing test.

I've also pushed up some whatsnew fragments that Pak Lam and myself put together, see 90236d2

Comment thread lib/iris/tests/unit/io/test__generate_cubes.py Outdated
Comment thread lib/iris/tests/results/file_load/known_loaders.txt Outdated
Comment thread lib/iris/tests/results/file_load/known_loaders.txt
@ukmo-ccbunney
ukmo-ccbunney marked this pull request as ready for review July 24, 2026 15:26

@ukmo-ccbunney ukmo-ccbunney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spotted a slight oddity...

Comment thread lib/iris/tests/integration/netcdf/test_nczarr.py

@ukmo-ccbunney ukmo-ccbunney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the docs with the HDF5 comment.
I think this is all good to go now. 👍🏼

@ukmo-ccbunney
ukmo-ccbunney dismissed scitools-ci[bot]’s stale review July 27, 2026 07:35

Not relevant - Iris specific.

@ukmo-ccbunney
ukmo-ccbunney merged commit 864b143 into SciTools:main Jul 27, 2026
22 checks passed
@scitools-ci scitools-ci Bot removed this from 🚴 Peloton Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implicit Zarr support via nczarr

4 participants