-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add fine-grained policy merge #466
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: transition-to-runkit
Are you sure you want to change the base?
feat: add fine-grained policy merge #466
Conversation
doudou
left a comment
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 a good first step, but there's one issue.
When using needs_reliable_connection, we have to add period information to the syskit models. Until now, setting the policy explicitly would be enough to avoid having to do this (because of time, or because Syskit limitations would make it hard to do). This PR will break these cases.
My suggestion is to split policy_for into:
- policy_compute_data_element(policy, fallback_policy)
- policy_default_init_flag
Always call the latter, but call the former only if the explicit policy does not have :type set already. Create corresponding unit tests.
fb15b6f to
fdce77a
Compare
fdce77a to
6e4d11e
Compare
| source_task, source_port_name, sink_port_name, sink_task, fallback_policy | ||
| ) | ||
| policy = {} | ||
| unless policy[:type] |
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.
policy is the empty hash here. This will always be nil.
The if should obviously be checking the policy that is coming from the policy graph.
I would actually pass policy from the loop in compute_policies_from to the method, and add the merge_policy call at the end of this method instead of doing it in said loop.
df2805a to
b1b6741
Compare
|
@jhonasiv updated, please have a look |
b1b6741 to
c4c5a4b
Compare
75f8fa1 to
42d7f4c
Compare
888c078 to
2ee8480
Compare
doudou
left a comment
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.
Adding empty review to get it out of my queue (since I'm the one working on it now)
Previously, if a parameter was added to the designer-provided policy, no automated policy determination would be performed. That meant that the init flag would not be computed in this case. To fix this, a merge_policy function was implemented to merge the explicit policy (the designer-provided one) and the computed policy (init, for instance) The fix follows these rules: - if a value is in policy, use it; - otherwise use the value from computed_policy Also, if the type policy is set to data, the size policy must be removed, as its only meaningful for the type buffer and it causes the connection to fail. The Ruby method `merge` merges two hashes. According to the documentation: "Returns a new hash containing the contents of other_hash and the contents of hsh. If no block is specified, the value for entries with duplicate keys will be that of other_hash." In this case, to follow the rules of prioritizing the value from explicit_policy in case of key duplication, 'other_hash' is explicit_policy and 'hsh' is computed_policy
renamed variables and simplified code
- Updated test expectations - Updated mock expectations - Added test to make sure the size is not overridden when an explicit policy specifies `type: :buffer` - Fixed the merging logic in the reliable connection policy test, properly verifying that `merge_policy` is called instead of directly modifying the expected policy About this last one. I'm not sure if that's the best way to do it. Tried to think of a way of simplifying it, but the test expects this chain of mocks.
Removed the one-line, one-use policy_default_init_flag method, and changed the argument order of merge_policy to match the hash merge (i.e. computed, explicit instead of the opposite)
2ee8480 to
cbd87b7
Compare
Previously here: tidewise#3
This was on top of another
tools/syskitPR