Skip to content

[ENH] Render valid value restrictions in tables based on object definitions in schema#921

Merged
sappelhoff merged 13 commits intobids-standard:masterfrom
tsalo:render-valid-values
Feb 1, 2022
Merged

[ENH] Render valid value restrictions in tables based on object definitions in schema#921
sappelhoff merged 13 commits intobids-standard:masterfrom
tsalo:render-valid-values

Conversation

@tsalo
Copy link
Copy Markdown
Member

@tsalo tsalo commented Nov 1, 2021

Closes #912.

Changes proposed:

  • Add new function to schemacode.utils, called describe_valid_values, that creates a string describing valid values for an object based on the schema.
  • In the case of referenced lists of valid values (i.e., enums) being used for an object, combined with an anyOf, try to flatten that set of lists into a single enum list. This makes rendering valid values for things like iEEGCoordinateSystem much easier.
  • Incorporate valid value strings into metadata and column tables.

To do:

  • Remove hardcoded lists of values.
  • Figure out how objects should be described. Dropped.
  • Figure out how anyOf situations should be described. Dropped.
  • Some cases will just be too complicated to describe automatically. How should we handle those? Dropped.

@tsalo tsalo marked this pull request as draft November 1, 2021 19:23
@tsalo
Copy link
Copy Markdown
Member Author

tsalo commented Nov 1, 2021

Some highlights:

Restrictions on numbers are shown

image

Restrictions on arrays (and their items!)

image

Objects with many possible restricted values can end up being a bit much

image

No restrictions beyond type means no added text

image

I haven't tackled anyOfs yet.

image

Also haven't tackled objects

image

@tsalo
Copy link
Copy Markdown
Member Author

tsalo commented Nov 1, 2021

@effigies is this in line with what you were hoping for?

@effigies
Copy link
Copy Markdown
Collaborator

effigies commented Nov 9, 2021

Much of this is covered by the type, already, or more clearly written in the description.

The enumeration of a finite set of possible values seems like the one that's really useful.

@tsalo
Copy link
Copy Markdown
Member Author

tsalo commented Dec 3, 2021

Okay, I'll scale it back to only include enums then.

@tsalo tsalo marked this pull request as ready for review January 5, 2022 20:29
Copy link
Copy Markdown
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

I like this feature (the downscaled, current version). However, if we want to merge this, we should go over the description texts and make sure the description is not duplicating the allowed values in an unnecessary way. As for example here:

grafik

Those values will automatically be rendered from the associated enums.
@tsalo
Copy link
Copy Markdown
Member Author

tsalo commented Jan 31, 2022

@sappelhoff done!

Copy link
Copy Markdown
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM now

@tsalo tsalo added the schema Issues related to the YAML schema representation of the specification. Patch version release. label Jan 31, 2022
@tsalo tsalo added this to the 1.7.0 milestone Feb 1, 2022
@sappelhoff sappelhoff merged commit 51e9f1b into bids-standard:master Feb 1, 2022
@tsalo tsalo deleted the render-valid-values branch February 1, 2022 18:24
@tsalo tsalo added the schema-code Updates or changes to the code used to parse, filter, and render the schema. label Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

schema Issues related to the YAML schema representation of the specification. Patch version release. schema-code Updates or changes to the code used to parse, filter, and render the schema.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render valid value restrictions in tables based on object definitions in schema

4 participants