-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add 0.4 schemas and examples #87
Conversation
Thanks for working on this @will-moore. I will give this a closer look once we have merged #85. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a few extra commits to this PR adding more invalid examples and their associated constraints expressed as JSON schemas. From my side, happy to get this merged in its current state but I'll leave @constantinpape to take a look.
Probably the next todo will be for the schema to handle the definition coordinateTransformations
at different levels (dataset
, multiscale
object) as #85. As this conversation still needs to get finalized and to simplify the review, I'd propose to get this in a separate PR.
Also to avoid unnecessary copy-n-paste, I think it should be possible to use $ref
and $defs
to make some of these definitions re-usable at different levels - see https://json-schema.org/understanding-json-schema/structuring.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments from my side:
- In the current version of v0.4 units and type only have a SHOULD for the expected values.
- This brings up the general question: how do we deal with the SHOULD requirements? Maybe we need two schemas, one that is strict and fails for SHOULD and one that is lenient and allows it?
- I think that
axes
andcoordnateTransforms
should get their own schema, as they are meant to be referenced in other places in the spec. (But it's not strictly necessary to do this now.)
(p.s. I just read the comment by @sbesson which brings up similar points about axes
and coordinateTransforms
)
"axes": [ | ||
{ | ||
"name": "y", | ||
"type": "invalid", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently a SHOULD, see https://github.com/ome/ngff/blob/main/latest/index.bs#L217. Not sure how exactly we want to tackle this. I will leave a more general comment once I went through everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this should not fail validation but probably be flagged by the stricter schema. I propose to open a follow-up PR with the infrastructure to differentiate the two of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, re-reading this example, this should remain invalid.
As you rightfully mentioned type
is a SHOULD and that is not sufficient ground to fail the strict schema. However there is only one space
axe within the multiscales
dictionary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you're right. But the name of this example is a bit misleading then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in fact it is failing because type
is not space, channel or time
rather than only-1-space-axis.
So the schema should allow 1 'invalid' axis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in fact it is failing because type is not space, channel or time rather than only-1-space-axis.
So the schema should allow 1 'invalid' axis.
I am not sure what you mean by this @will-moore. But I agree that this one should fail the strict spec because it has only 1 spatial axis, as @sbesson points out. But I would maybe rename the example to make that clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nods, that's probably more tests worth injecting but my understanding of the type
restrictions is the following for multiscales.axes
:
- 1 space axes + anything else: invalid
- 2 (or 3) space axes, 1 channel and/or 1 time: valid
- 2 (or 3) space axes, 1 channel or 1 time), 1 custom type: valid but failing the strict schema
- 2 (or 3) space axes, 1 channel or 1 time, 1 unspecified: valid but failing the strict schema
- 2 (or 3) space axes, 2 customs or 2 unspecified or (1 custom and 1 unspecified): valid but failing the strict schema
- 4+ space axes + anything else: invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 (or 3) space axes, 1 channel or 1 time, 1 unspecified: valid but failing the strict schema
with 3 spatial axes this would fail because we would have > 5 dim. Same for some of the other examples you bring up.
But otherwise I agree with your list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh the or
in between 1 channel and 1 time was meant to capture that but I certainly failed to write the different combinations in a concise way. Expanding a bit, all the following set of axes types should be valid according to the minimal schema but should fail the strict schema:
- 2 space, 1 channel, 1 unspecified
- 2 space, 1 time, 1 unspecified
- 3 space, 1 channel, 1 unspecified
- 3 space, 1 time, 1 unspecified
{ | ||
"name": "y", | ||
"type": "space", | ||
"units": "micron" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for invalid type: this is currenrtly a SHOULD: https://github.com/ome/ngff/blob/main/latest/index.bs#L218
{ | ||
"name": "t", | ||
"type": "time", | ||
"units": "micrometer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the comment before this is technically valid if we have a SHOULD in the units.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, although as discussed yesterday, this is typically a real-world example where I find the consequences of the SHOULD
requirement nonsensical. I'll open a corresponding issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, although as discussed yesterday, this is typically a real-world example where I find the consequences of the SHOULD requirement nonsensical.
Yeah, I agree that the consequences here are weird, but probably better to open an issue and not block the current release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and at least this would fail if we had a strict schema)
"path": { | ||
"type": "string" | ||
}, | ||
"coordinateTransformations": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that coordinate transformations should be moved to a separate schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, separating axes
and coordinateTransformations
matches the way the specification is written and should increase the readability and the management of these schemas.
A technical side, as these schemas are not yet published (and we need to have some deeper discussions around URL as well as packaging - see #77), I suspect handling separate JSON schema files will require to make some decisions as relative references are not resolvable. Since these concepts are only used within the context of multiscales
in v0.4, my inclination would be to start by defining internal sub-schemas using #defs
- see #87 (review). As the intent is to use these concepts in other portions in the specification, I propose we review this assumption and define axes.schema
and coordinateTransformations.schema
when this becomes a requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, for now using them to #defs
in the same schema is probably the best solution.
"0.4" | ||
] | ||
}, | ||
"axes": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axes should also be moved to a separate schema.
Ok, after the feedback from @sbesson I suggest we proceed as follows:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the separation of examples and following SHOULD / MUST schemas is a bit more tricky. So this is good to be merged from my side (and continued work could be done after the v0.4 release.)
@constantinpape @sbesson I think that's the essential things done for this PR. Question: when |
@will-moore Yes, this is consistent with what we write in the spec right now, so I would go ahead and merge this. |
Validates the updated
axes
andtransformations
lists, according to latest spec discussed in #85.Adds a bunch of valid and invalid examples, tested by the
image.schema
.Fixes #82