-
Notifications
You must be signed in to change notification settings - Fork 179
refactor: Allow export prefix SchedulingContextState for use across plugins #1063
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
…lugins Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com>
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Hi @kfirtoledo. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/assign @liu-cong |
/ok-to-test |
this LGTM. overall the idea behind CycleState is to share state between different plugins. leaving final stamp for @liu-cong. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kfirtoledo, 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 |
// getPrefixState returns the cycle state as a schedulingContextState. | ||
func (m *Plugin) getPrefixState(cycleState *types.CycleState) (*schedulingContextState, error) { | ||
// getPrefixState returns the cycle state as a SchedulingContextState. | ||
func (m *Plugin) getPrefixState(cycleState *types.CycleState) (*SchedulingContextState, error) { |
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 share this state, I think we need to make the getPrefixState
also public.
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.
This code will also work.
raw, err := cycleState.Read(prefix.PrefixCachePluginType)
if err != nil {....}
prefixState, ok := raw.(*prefix.SchedulingContextState)
@nirrozenbaum also suggested a good idea to add a function like cycleState.ReadAsType
to make it more generic instead of using specific get<XXX>State
methods for each plugin. But in both cases, you still need to export SchedulingContextState.
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.
This is essentially duplicating this helper function. Let's make this also public so people don't need to do the error handling and type assertion.
Otherwise this looks good to me.
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.
it won’t help to make this function public as long as it’s part of the prefix scorer.
different plugins don’t have access to the scorer, only to cycle state.
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.
Ah, actually this method doesn't need to be a method on the prefix Plugin. It can be its own standalone helper method.
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.
if you decide to do that (not a big deal from my side if not, its 3 LoC), maybe you can extract state struct and the helper function to a different file. just to have all state related code organized together.
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.
@nirrozenbaum and @liu-cong, I replaced getPrefixState with a more generic function - PTAL
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.
this looks great
Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com>
/lgtm |
…lugins (kubernetes-sigs#1063) * refactor: Allow export prefix SchedulingContextState for use across plugins Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com> * refactor: replace getPrefixState with generic ReadCycleStateAs Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com> --------- Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com>
…lugins (kubernetes-sigs#1063) * refactor: Allow export prefix SchedulingContextState for use across plugins Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com> * refactor: replace getPrefixState with generic ReadCycleStateAs Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com> --------- Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com>
The schedulingContextState type was renamed to SchedulingContextState to make it accessible from other packages and enable sharing of prefix state across different plugins.