-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use model_validate
built into pydantic to parse DB models
#129
Conversation
71a0270
to
c66f338
Compare
Took my third attempt to wrap my head around this PR - with limited success. I think there are three things in this PR
|
It's not specifically that, I actually had a cloudflare integration in mind. Right now with our internal version (which is very outdated), we have a cloudflare integration which creates tunnels to devices automatically based on UUIDs. This requires configuring |
a740559
to
42926d8
Compare
I think you're right about this for now. I have made this PR a bit more atomic by removing 2 and 3. I would really like to be able to get a plugin interface of some kind included here, I want to have our internal stuff up to date, but it seems every foothold I've tried to gain on that side of things causes one issue or another. If you have any ideas on that side of things LMK. |
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.
Looks good. Just minor issues that are optional to address in my opinion.
Not needed anymore since aiofiles was removed.
When sending a rollout put request via the API, there was no validation that the referenced software file existed.
`pydantic` models have a deprecated `from_orm` method, which is designed to parse DB models into the schema. This was superseded by `model_validate`, which does the same thing when the schema config `from_attributes` value is true. Migrating to using this simplifies the method of parsing DB models, and will eventually allow the schemas to be used internally instead of the DB models.
42926d8
to
1fb6368
Compare
@b-rowan let's discuss this through another channel. Can you send me an email to the address from my commits? |
Done. Sent from my upstreamdata.ca email. |
@@ -1,3 +1,5 @@ | |||
from __future__ import annotations |
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.
@b-rowan why are these lines needed?
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.
Not really sure why I've been adding them, just a good failsafe. Need to modify my IDE settings to stop complaining about them I think.
pydantic
models have a deprecatedfrom_orm
method, which is designed to parse DB models into the schema. This was superseded bymodel_validate
, which does the same thing when the schema configfrom_attributes
value is true. Migrating to using this simplifies the method of parsing DB models, and will eventually allow the schemas to be used internally instead of the DB models.Reference here - https://docs.pydantic.dev/2.0/usage/models/#arbitrary-class-instances
The goal here is to get to the point where we can pass around arbitrary abstract software types internally, which will allow hooking the software that a device should receive.