Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify NGFF 0.6-dev in output data #849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LucaMarconato
Copy link
Member

This PR monkeypatches ome_zarr.format to make it possible to use the read/write APIs of ome-zarr-py, while clarifying which OME-Zarr data version we are building on top.

Precisely, we implement the NGFF transformations specification, which, as of today, it is not merged to NGFF main yet. The timeline is to have the specification included in NGFF v0.6, hence from this PR we will write 0.6-dev instead of 0.4 (which was kept for compatibility with ome-zarr-py).

All the tests pass, the code for reproducing the documentation and paper notebooks and the data conversions from spatialdata-sandbox are currently running.

Practically, the PR will not change APIs or usage of the function of the spatialdata package and will only modify, on-disk, the version string for images and labels, as shown here (in this example I used Seqfish v2 data).

(ome311) macbook@Lucas-MacBook-Pro-2021 seqfish_v2_io % diff -r data.zarr.v4 data.zarr.v6
diff -r data.zarr.v4/images/Roi1_DAPI/.zattrs data.zarr.v6/images/Roi1_DAPI/.zattrs
91c91
<             "version": "0.4"
---
>             "version": "0.6-dev"
diff -r data.zarr.v4/labels/Roi1_Segmentation/.zattrs data.zarr.v6/labels/Roi1_Segmentation/.zattrs
3c3
<         "version": "0.4"
---
>         "version": "0.6-dev"
71c71
<             "version": "0.4"
---
>             "version": "0.6-dev"
diff -r data.zarr.v4/zmetadata data.zarr.v6/zmetadata
105c105
<                     "version": "0.4"
---
>                     "version": "0.6-dev"
157c157
<                 "version": "0.4"
---
>                 "version": "0.6-dev"
225c225
<                     "version": "0.4"
---
>                     "version": "0.6-dev"

CC @joshmoore

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.96%. Comparing base (7c280b7) to head (485b87c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #849      +/-   ##
==========================================
+ Coverage   91.95%   91.96%   +0.01%     
==========================================
  Files          47       47              
  Lines        7293     7304      +11     
==========================================
+ Hits         6706     6717      +11     
  Misses        587      587              
Files with missing lines Coverage Δ
src/spatialdata/_io/format.py 84.30% <100.00%> (+1.07%) ⬆️

pass
@property
def version(self) -> str:
return "0.6-dev"
Copy link
Member

Choose a reason for hiding this comment

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

cc @bogovicj in case defining a specific pre-release version (i.e. dev1 or beta1) would make detecting differences in these upcoming versions more reliable.

See also ongoing conversation around 0.5.2

Copy link
Member

@joshmoore joshmoore Jan 28, 2025

Choose a reason for hiding this comment

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

Actually, going back and looking at the diff output in the description, I'd suggest we not use 0.6.* unless this also implements the Zarr v3 work of 0.5.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good point. Any suggestion on the string to use? Maybe something more verbose like 0.4-dev-transformations?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or 0.4-dev-spatialdata .

Copy link
Member

Choose a reason for hiding this comment

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

  • 👍 for starting with 0.4-
  • 👍 for having "spatialdata" or similar in it
  • you might think about whether or not you have a version field from SD itself
  • I defer to you if you want "dev" in it or not (I don't think the validator, e.g., has special behavior for that. @will-moore?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I will adjust the coordinate transformations metadata together with @melonora in ome-zarr-models-py.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you agree, I'd go then with 0.4-dev-spatialdata and merge this PR.

Choose a reason for hiding this comment

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

I've opened a PR at ome/ome-ngff-validator#45 with the validator deployed for testing at https://deploy-preview-45--ome-ngff-validator.netlify.app/
Does that help with what you need?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Will, but as Josh said here:

Except this version explicitly does not validate, so perhaps it's enough that it's just not the known "0.4"?
Not passing the validation is expected because the coordinate transformation specification that we implemented was based on an earlier draft and our plan is to finalize it in ome-zarr-models-py.

In this PR I made a patch to ome-zarr-py to be able to read the tensors even with partially incorrect metadata. We indeed handle the read/write of metadata in spatialdata, and use ome-zarr-py to read the tensors.

What would be needed here is to agree on an appropriate version number, such as 0.4-dev-spatialdata, that doesn't imply that validation is passed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Please in this comment you can see the full context of why we want to fix the version string now and we defer passing the validation later: #805 (comment).

@will-moore
Copy link

As I understand it from #805, the eventual goals are:

  • SpatialData writes valid OME-NGFF data according to the CoordinateSystems spec (RFC-5) - likely to be v0.6
  • There is some way to convert this into OME-NGFF v0.4 so it can be read by more tools (that don't yet support v0.6)

The main issues are:

Re: your patch for ome-zarr-py that allows it to handle partially incorrect metadata - Are you proposing to open a PR with that change (and for it to be able to recognise custom version numbers and be more lenient in validation)?

Is this what you're asking for agreement on? I don't see a problem with that cc @joshmoore ?
But maybe easier to discuss on an actual ome-zarr-py PR?

@LucaMarconato
Copy link
Member Author

LucaMarconato commented Feb 4, 2025

Correct @will-moore, thanks for the clear summary.

The RFC-5 is not yet approved, so we don't yet have v0.6 spec. What to do in the meantime?

I prefer to direct my efforts in implementing the NGFF RFC-5 in ome-zarr-models-py, so that we align with that (i.e. import it and remove the transformations code from spatialdata) as soon as possible. In the meantime I would leave ome-zarr-py as it is, meaning that if someone tries to read the metadata an error is given, since 0.4-dev-spatialdata is not supported by it. At the same time, thanks to the current PR we will be able to continue using ome-zarr-py internally. And hopefully we will be able to replace the 0.4-dev-spatialdata with 0.6 soon (ideally just some months). When this happens, I think we could contribute to making ome-zarr-py handle RFC-5 (which should be easy by then since one could then depend on ome-zarr-models.py).

@joshmoore wdyt?

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.

Add dev on NGFF version number created by internal call of ome-zarr-py
3 participants