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

Add 0.4 schemas and examples #87

Merged
merged 19 commits into from
Feb 2, 2022
Merged

Add 0.4 schemas and examples #87

merged 19 commits into from
Feb 2, 2022

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Jan 28, 2022

Validates the updated axes and transformations lists, according to latest spec discussed in #85.
Adds a bunch of valid and invalid examples, tested by the image.schema.

Fixes #82

@will-moore will-moore marked this pull request as ready for review January 28, 2022 16:38
@constantinpape
Copy link
Contributor

Thanks for working on this @will-moore. I will give this a closer look once we have merged #85.

Copy link
Member

@sbesson sbesson left a 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

Copy link
Contributor

@constantinpape constantinpape left a 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 and coordnateTransforms 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",
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Member

@sbesson sbesson Feb 2, 2022

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"
Copy link
Contributor

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"
Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor

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": {
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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": {
Copy link
Contributor

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.

@constantinpape
Copy link
Contributor

constantinpape commented Feb 2, 2022

Ok, after the feedback from @sbesson I suggest we proceed as follows:

  • In this PR:
    • split examples/invalid into examples/invalid_strict and examples/invalid_loose (or so; I don't mind changing the names, but there should be two folders ;)). And move the examples in the corresponding folder.
    • make sure that all valid examples and invalid_loose pass the schema; invalid_strict fail the schema
    • move "axes" and "coordinateTransformations" to #defs to improve readability
  • follow up work:
    • introduce separate schemas for MUST and SHOULD, make sure that they validate the corresponding examples correctly
    • move "coordinateTransformations" and "axes" to their own schemas

Copy link
Contributor

@constantinpape constantinpape left a 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.)

@will-moore
Copy link
Member Author

@constantinpape @sbesson I think that's the essential things done for this PR.

Question: when coordinateTransformation is used at the multiscales level, MUST it include a scale object (as when used at the dataset level)? Currently the schema enforces that, since the same coordinateTransformations ref is used in both places.

@constantinpape
Copy link
Contributor

Question: when coordinateTransformation is used at the multiscales level, MUST it include a scale object (as when used at the dataset level)? Currently the schema enforces that, since the same coordinateTransformations ref is used in both places.

@will-moore Yes, this is consistent with what we write in the spec right now, so I would go ahead and merge this.
Longer term: as far as I recall it's possible to extend definitions in jsonschema with a bit of magic, so that we don't need to require this in the coordinateTransformation schema directly.

@sbesson sbesson merged commit 430a9ae into ome:main Feb 2, 2022
github-actions bot added a commit that referenced this pull request Feb 2, 2022
Add 0.4 schemas and examples

SHA: 430a9ae
Reason: push, by @sbesson

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to sbesson/ngff that referenced this pull request Feb 2, 2022
Add 0.4 schemas and examples

SHA: 430a9ae
Reason: push, by @sbesson

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

json-schema for v0.4 spec
3 participants