-
Notifications
You must be signed in to change notification settings - Fork 201
added plugin state that can be used to share data between different extension point of a plugin #1299
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
Conversation
…xtension point of a plugin Signed-off-by: Nir Rozenbaum <[email protected]>
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nirrozenbaum The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Nir Rozenbaum <[email protected]>
|
This is my understanding of the pros/cons of this approach, vs. having the state as part of the "request context" (I am using Pros:
Cons:
There is no right/wrong solution, but my preference is to model this in a
Would like to hear others' thoughts :) |
there is another major cons for a requestContext that lives through the request lifecycle. I'm not saying the current design or interfaces are perfect, I just think we should continuously adjust the interfaces between the layers based on new requirements (AI use cases are changing in real fast pace). I'm concerned about adding this general (key,value) map that can be passed between all extension points with no enforcement of the interfaces between the layers. |
+1 on this concern, though personally I can live with it. Ideally we can iterate the interface to enforce something, for example, a plugin can only access a specific key that it owns. Would that be something you will consider? |
That's not something we should do, multiple plugins may want the same data. Ultimately, I'm thinking we should have the data layer plugins emit or 'publish' the data keys they have. Then other plugins can 'subscribe' to these keys. It's not a pub/sub messaging queue, but a similar idea. |
|
This is similar to the issue we were discussing in updating the prefix cache. We allowed the plugin to manage its state, but its becoming clear that we should not be allowing that, and instead have a clean data communication system. I think thoughtful admission of data is a better system than to just pass all data throughout the system. |
|
Some sort of data key management mechanism for plugins (e.g., the pub/sub idea @kfswain mentioned above) sounds plausible to me. Before we have that, I am in favor of having a general key/value store. |
|
I'd be careful with targeting this pub-sub alike system. it sounds to me like an overkill for what we need.
|
|
Oh man. A lot to unpack there. |
|
My two cents:
Will wait for others to comment but you get my lgtm. |
|
Because we are intended to act as a library, a predictable, safe exposure of data & an understandable way that the data interacts is key. To me, PluginState generates a new source of truth beyond the data-layer/datastore. And simple map is easy to accidentally abuse. Given we snapshot data for scheduling runs, it would be prudent to centralize this data & limit its exposure. To do this in a general way my preferred approach is to have the data sources emit the key that they populate, and plugins specify keys they 'consume'. Its not a full pub/sub queueing system. But just pulling inspiration from the publisher & subscriber idea. We have multiple use cases that need to reference other plugin data; i.e. SLO prediction takes in prefix token hit as input. |
|
If we want to do either implementation as an interim, that's totally fine, but I'm not entirely sold on the urgency. |
I think how to expose the data-layer to the plugins are a separate discussion. This PR is about how a plugin can maintain its own state (that may or may not be relevant to the data-layer). Just wanna keep the discussion focused so we don't explode the scope. To be fair, a plugin can always maintain its own state in whatever form they want, and I am not sure if we can/should prevent that. This PR simply provides a useful library for the plugin, and this does not involve a change to the plugin framework. From that perspective, I am not too concerned whether this is the long-term solution or not. |
|
I wont block this PR. This is fine for now, however this discussion keeps coming up, and I think will continue to until we come to a real solve. |
|
/lgtm Holding if others want to review. |
|
@kfswain @liu-cong thanks for taking the time to think and comment on this topic, It does worth a follow up discussion. comparing to where we are today, I think this is a step towards the right direction and will allow us to finally deprecare the PostCycle. will give it a day to see if anyone has more comments/concerns. |
|
Thanks for the discussion everyone!
+1 on this. /lgtm @nirrozenbaum Mind adding a unit test? |
@liu-cong sure, absolutely. atm no plugin uses PluginState, so my next PR would be to add unit-test and only then switch to using it in Prefix plugin. /unhold |
|
opened issue #1343 |
This PR adds a new mechanism,
PluginState, that may be used in a plugin to share a state between different extension points.a clarification - the intention is that a plugin shares state with itself in different extension points, not with other plugins.
so essentially we should have two mechanisms for sharing state across plugins:
This mechanism adds the option to write/read/delete keys in the context of a request, while keeping in mind that for a given request the plugins do not run in parallel (and therefore using internally a map works).
this looks and feels similar to CycleState in some things, so I exported some common things like StateKey and StateData to a common
plugins/shared_state.gofile (structs that used to share state in the context of plugins).this PR only adds the generic mechanism, still not using it.
the next step would be to use it in Prefix scorer and completely remove PostCycle extension point.
LMKWYT.
cc: @kfswain @liu-cong @ahg-g @elevran
Fix #1084