yjmantilla / sovabids

A python package for the automatic conversion of EEG datasets to the BIDS standard, with a focus on making the most out of metadata.
https://sovabids.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Validation of the rules file #17

Open yjmantilla opened 3 years ago

yjmantilla commented 3 years ago

So I was thinking that given that the rules file could be done by a power-user then it would be good to have a validator for it; in a sense that it has the required fields and not unsupported fields and so on.

civier commented 3 years ago

It good to have a validator in any case, to make sure there are no bugs in the code. If it's a yaml, so I'm sure that a validator can be automatically generated (without coding) by specifying the required fields, unsupported fields, etc. Have you looked into what's available?

yjmantilla commented 3 years ago

Have you looked into what's available?

No until just now, one of the candidates from here is cerberus. The schema is defined as a json dictionary .

Nonetheless, the logic can be quite variable since, for example, the task name can be set up to a fixed value or inferred from a path pattern, so then the validator has to check that the task is in either of those fields. I'm not sure yet of how cerberus would be able to deal with that.

Another option is the schema package . Reading a bit into it, it seems it would be able to support the kind of logic I just mentioned.

There a whole bunch of other options listed there (Rx, kwalify, voluptuous, flatland) but those two (cerberus and schema) where the ones that upon a quick reading captured my attention.

aswinnarayanan commented 3 years ago

@yjmantilla Another option could be jsonchema (Github)

It's an implementation of the bigger JSON Schema initiative which is in process to trying to become an IETF standard, which is promising. They have some other python implementations here as well

It should support yaml (detailed here). I don't think we are planning to use the advanced yaml functions. And it could be beneficial in future if the validator is agnositic to json/yaml

JSON Schema is also supported by the Red Hat YAML extension for VS Code, so provides option for the user to validate their bids yaml from the VS code editor.

Your other options also look good, especially Cerberus.