-
Notifications
You must be signed in to change notification settings - Fork 177
Add REST plugin for user-defined policies #2631
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
base: master
Are you sure you want to change the base?
Conversation
Realized that setting up this plugin as an external package is unnecessarily complicating the installation process. I'm going to change it so that it's more builtin the server code. |
A good place for a built-in server plugins would be to put them in May require renaming Let me know if you need help with refactoring. |
@Nadine-H, Do you think of writing the spec manually or generating it automatically? Automatic generation is highly preferable because spec models are regularly updated with new properties and it won't be practical to maintain manually written spec. |
Automatic generation for sure. I set up a local FastAPI server to test the rest plugin and will share the |
timeout=PLUGIN_REQUEST_TIMEOUT, | ||
) | ||
response.raise_for_status() | ||
spec_json = json.loads(response.text) |
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.
How does the Plugin reject a Run from being applied? Do we want some exceptions (HTTP Status Codes) to be propagated to Dstack? Or should there be an errors
element of the response body?
I'm leaning toward the latter since if we're monitoring the plugin server, it might be difficult to distinguish between "the plugin server thought this request was invalid" and "the plugin server could not answer the question".
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.
Sorry, I misread your comment when you shared it internally. Yes - I agree on the latter option, that way the user knows if the action is on their end or if it's a system issue (a bug in dstack or plugin server)
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.
Added a pydantic model for the plugin server response that includes an error
field here. Expectation is if request is rejected, dstack should a 200 response from plugin server with an error
.
Adding documentation to the guides as well |
GatewaySpecRequest = SpecRequest[GatewaySpec] | ||
|
||
|
||
class CustomApplyPolicy(ApplyPolicy): |
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.
@r4victor Should async policies be a thing, or are policies always running in an executor?
Resolves #2630.
Key notes: