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

Adding possibility to generate a json schema file when calling jsonargparse.ArgumentParser.save #618

Open
martinResearch opened this issue Nov 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@martinResearch
Copy link

🚀 Feature request

Add option to generate a json schema alongside the json file when calling jsonargparse.ArgumentParser.save and link to that schema file in the default config json file using the "$schema" key.

Motivation

When I edit json configuration files, it is error prone. I can do spelling mistakes, I do not know what filed are optional, what the possible values for enums are etc.

Pitch

It would be nice if we could generate a json schema alongside the json file when calling jsonargparse.ArgumentParser.save and link to that schema file in the default config json file using the "$schema" key. This would enable the use of a plugin like Json Schema validator in vs code to get auto-completion and validation directly when editing the configuration file.

@martinResearch martinResearch added the enhancement New feature or request label Nov 8, 2024
@mauvilsa
Copy link
Member

mauvilsa commented Nov 8, 2024

Thank you for the proposal. This had been requested in the past in Lightning-AI/pytorch-lightning#17564, though having it in this repo is better.

I agree that it would be nice to have a json schema. But note that it is a rather complex feature, which is unlikely to happen soon. The hardest part is the support of subclasses. There can be a large amount of possibilities which would generate quite a large and complex json schema, with plenty of nested oneOf. It could even be that auto-completion plug ins don't even work with such complex schemas.

Another note is, having a way to generate a json schema sounds good. But this being done by save including a $schema key does not sound like the direction to go.

@martinResearch
Copy link
Author

Would it make sense to have a first implementation with limited support for subclasses that would be well documented? It would throw an error for unsupported cases. It might be sufficient for a large majority of users?
"But this being done by save including a $schema key does not sound like the direction to go." would be interested to know what you think would be a better alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants