feat: Add registry for reservation rule classes#357
Conversation
|
Pushed the discussed updates. Summary:
Validation:
|
|
Please resolve your conflict. |
Tw1ZZLER
left a comment
There was a problem hiding this comment.
This PR mostly reads like a prompt-driven refactor, and not an intentional redesign of how a good reservation rule registry should work. I would seriously spend more time thinking about how the API should be re-engineered for this.
I do think the addition of _get_swapping_neighbors was a great change! The introduction of this method makes the readability much much better and gives the loop a good name.
However, extensibility is pretty overstated, and in practice most users would still have to override a lot of the methods and existing framework. Please see comments for other thoughts.
I really think the motivation behind this change is a good one, but the execution does not feel very thought out in terms of engineering and design.
|
The PR's scope is not clear given the description of the PR and the code itself. It appears that you are trying to partially implement a completely generalized solution for a rule registry, that allows users to add rules and change the order of rules however they see fit. If you are going for a simpler system that only replaces existing rules with custom args, then I would suggest using a simple table of (name, predicate, builder) instead of classes for each rules, and make it explicit that the registry only allows the user to replace the reservation rules with custom ones. I think there was a discrepancy in the description and the code itself versus the purpose and scope. Overall I think the implementation would make a good contribution towards SeQUeNCe, but it is a little over-engineered for the simple "replace rules easily" scope. Try and make it simpler and narrow the scope and it will be a very good addition I think 🙂 Ignore the comments from my review until you narrow the scope. I will resolve comments that fall outside of the new scope or are outdated 💯 |
0073ed1 to
ef10699
Compare
|
Thanks @Tw1ZZLER , this clarification helped. I revised the PR around the narrower intended scope: this is now explicitly a fixed-scope replacement mechanism for SeQUeNCe’s existing reservation-generated rule slots, not a generalized registry for adding arbitrary reservation phases or changing scheduling order. The implementation now uses a static table of (name, predicate, builder) specs instead of separate Rule subclasses. The registry allows replacing or disabling builders for those existing rule slots, while the rule creation order and predicates remain fixed. I also preserved the ES swapping success/degradation action arguments, removed the dead/misleading API pieces from the earlier version, and updated the tests for the narrowed API. I ran the pytest suite locally and all tests pass. Please let me know if I missed anything from the intended scope or if there are any additional changes you’d like me to make. |
There was a problem hiding this comment.
Looks great!! You did an amazing job implementing my idea, probably much better than I would have done so. create_rules() is now such a clean method it makes me happy just looking at it! Definitely a massive improvement over what it used to be before this PR, and gives the user more customizability for sure. APPROVE!
I added 2 comments for adding additional documentation in some spots that would be nice, but not blocking the merge.
| pass | ||
|
|
||
| def get_reservation_rule_registry(self) -> ReservationRuleRegistry: | ||
| """Return the registry used to replace or disable reservation rule builders.""" |
There was a problem hiding this comment.
Can you add a usage example here showing how to customize a rule? It will help for documentation
|
|
||
|
|
||
| def _get_swapping_neighbors(owner_name: str, path: list[str]) -> tuple[str, str]: | ||
| """Return the left and right neighbors used for middle-node swapping rules.""" |
There was a problem hiding this comment.
Can you explain the algorithm used here just a bit more?
| "path": context.path, | ||
| "index": context.index, | ||
| } | ||
| return Rule(10, eg_rule_action_await, eg_rule_condition, action_args, condition_args) |
There was a problem hiding this comment.
Priority cannot be fixed at 10
| else: | ||
| condition_args = {"memory_indices": context.memory_indices[context.reservation.memory_size:]} | ||
|
|
||
| action_args = { |
There was a problem hiding this comment.
What if I want to change the action_args?
See an example of customizing the action_args by adding "memo_type" https://github.com/haydenmllr1317/heterogenous/blob/be30fa92a4e101a6ac64609d4232889d0fc430ca/resource_manager.py#L164
Summary:
Testing:
Note: