Skip to content

fix: update OME-Zarr unit handling to match spec#907

Open
omdowley wants to merge 3 commits intogoogle:masterfrom
omdowley:master
Open

fix: update OME-Zarr unit handling to match spec#907
omdowley wants to merge 3 commits intogoogle:masterfrom
omdowley:master

Conversation

@omdowley
Copy link
Copy Markdown

@omdowley omdowley commented Mar 16, 2026

As discussed in #780, the relevant part of the OME Zarr v0.5 spec specifies that the units SHOULD be one of those that are currently allowed, not that they MUST be (which is what is currently enforced). This instead of erroring treats unsupported units as unitless and warns.

It seems possible to me that there are smarter things to do than this, but thought I'd get the ball rolling with it, because it feels like the absolute minimal change such that we're actually meeting the spec.

As discussed in google#780, the OME-Zarr v0.5 spec specifies that the units SHOULD be
one of those that are currently allowed, not MUST. This instead treats
unsupported units as unitless and warns.
@chrisj
Copy link
Copy Markdown
Contributor

chrisj commented Mar 16, 2026

I'm wondering if this should be visible in the UI as either a temporary status message or ideally as a message exactly where the error message currently shows but still allow creating the layer

@jbms
Copy link
Copy Markdown
Collaborator

jbms commented Mar 16, 2026

Yes, I'd agree, we just need to add a mechanism for data sources to propagate warnings --- probably by passing in a messages: MessageList object as part of the GetDataSourceOptionsBase interface.

The OME Zarr spec specifies the lists of units from which valid units SHOULD
come separately for `time` and `space` axes. This enforces that (with a warning).
@omdowley
Copy link
Copy Markdown
Author

omdowley commented Mar 18, 2026

I'm wondering if this should be visible in the UI as either a temporary status message or ideally as a message exactly where the error message currently shows but still allow creating the layer

This definitely makes a lot more sense than what I initially did.

Yes, I'd agree, we just need to add a mechanism for data sources to propagate warnings --- probably by passing in a messages: MessageList object as part of the GetDataSourceOptionsBase interface.

I've done this -- it ended up a bit messy because by default the warnings were removed pretty immediately by the refCounted disposer, so I had to persist them. Again there may be a neater way to do that, it just felt like it'd require bigger changes, open to feedback

I've also added logic checking the axis type and unit type make sense, and warning if there is either an axis type mismatch or if the axis type isn't one defined in the spec (both of these are SHOULD items in the spec)

outputSpace: volume.modelSpace,
transform: multiscaleInfo.baseTransform,
};
const warnings = Array.from(localMessages, (m) => m.message);
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.

Can we simplify this to Array.from(localMessages) to avoid having to recreate the message when adding it to options.messages. In that case i would rename warnings to messages.

Also, I think we should change Message from a class to an interface.

.then((source: DataSourceWithRedirectInfo) => {
if (refCounted.wasDisposed) return;
this.messages.clearMessages();
refCounted.registerDisposer(this.messages.addChild(dataSourceMessages));
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.

I think we could move refCounted.registerDisposer(this.messages.addChild(dataSourceMessages)); to right after the creation of the message list. Change the error message in the catch handler to add to dataSourceMessages. Then remove the calls to clearMessages in both handlers as the disposer now is now in charge of that. All messages are added to a child instead of the parent MessageList.

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.

3 participants