-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Introduce pydantic schema #5531
Conversation
@@ -122,7 +123,7 @@ def _check_gitignored(self): | |||
if self._is_git_ignored(): | |||
raise FileIsGitIgnored(self.path) | |||
|
|||
def _load(self): | |||
def _load(self, use_pydantic: bool = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test new schema, you can toggle this to True
, and it should start using the new schema for validation.
we can generate this from the pydantic schema
looks like they fail on Python3.6 for some reasons
86fdc21
to
33874df
Compare
Closing it for now, will come back to it after UI is done. Unfortunately, I haven't been able to work more on this right now, so this needs more research. As this PR stands, it is only meant to change the validation schema, so I can't provide any compelling argument other than to say that we are maintaining this schema already on It feels like cheating if I make other arguments just to make a point on its potential benefits that we might get in the future, which I am quite not sure of myself. I do believe we'll come to this again soon. 🙂 |
I'm not aware of the internal implications of this change but I think that having the schema inside the core repo makes a lot of sense. Issues related with having Probably not enough to be considered an argument at this point but I think that adding this feature (and introducing internal usage of pydantic) could open new possibilities regarding |
Sorry. Better in #9606 (comment) |
From the dvcyamlschema/gen.py, added some 2.0 stuff and improved schema in the hopes that this will replace the Voluptuous schema we have for
dvc.yaml
at least.I'm still hesitant to go full-blown with Pydantic yet, as making both of these schemas compatible is harder than I thought previously, which means there might be some bugs lurking around. The tests do pass with this new schema, but they don't tests the negative cases well. And, we also need to consider performance (voluptuous is faster, but is it worth to continue using it as it's DX is very bad?).
This pydantic schema can be used to provide
jsonschema
as well, you can just use it as:The
dvcyaml_schema
repo will simply use this API if/when this gets merged, which will make it closer to where we work.See also #5371 (comment), pydantic has a bit better error messages than Voluptuous.
Related: iterative/dvcyaml-schema#7
❗ I have followed the Contributing to DVC checklist.
📖 If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏