Materials-Data-Science-and-Informatics / dirschema

Spec and validator for directories, files and metadata based on JSON Schema and regexes.
https://materials-data-science-and-informatics.github.io/dirschema/
MIT License
7 stars 0 forks source link

Allow recursive schemas #2

Open apirogov opened 2 years ago

apirogov commented 2 years ago

Why: Would e.g. allow to express rules that are not fixed to a certain depth. Currently we can only constantly index forward or backward from the start or the end of the path.

With recursive rules we could :

How: Probably need to lazy-load/eliminate deep copy for that. Maybe even need to avoid JsonRef and only use its loader to resolve file locations.

This might need substantial rewrite if it's not possible to modify the parsing behaviour of pydantic to "shallow parse" the structures and build the "graph" of rules out of it.

Note: Also, the whole thing immediately becomes Turing Complete (in an esoteric language sense), as we have string rewriting that can simulate 2 counters, state (current rule and pattern) and goto (then + $ref)

This is low priority, until a serious use-case for this feature arises.