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

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

Merged
merged 13 commits into from
Feb 1, 2022

Conversation

tsalo
Copy link
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
Copy link
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
Member Author

tsalo commented Nov 1, 2021

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

@effigies
Copy link
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
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
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
Member Author

tsalo commented Jan 31, 2022

@sappelhoff done!

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