Skip to content

Conversation

@eduardacoppo
Copy link

Previously here: tidewise#3
This was on top of another tools/syskit PR

Copy link
Member

@doudou doudou left a 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.

@eduardacoppo eduardacoppo force-pushed the policy_merge_in_dataflow_dynamics branch 2 times, most recently from fb15b6f to fdce77a Compare March 7, 2025 16:37
@eduardacoppo eduardacoppo requested a review from doudou March 7, 2025 18:19
@eduardacoppo eduardacoppo force-pushed the policy_merge_in_dataflow_dynamics branch from fdce77a to 6e4d11e Compare March 7, 2025 18:21
source_task, source_port_name, sink_port_name, sink_task, fallback_policy
)
policy = {}
unless policy[:type]
Copy link
Member

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.

@eduardacoppo eduardacoppo requested review from doudou and jhonasiv March 15, 2025 00:56
@doudou doudou force-pushed the policy_merge_in_dataflow_dynamics branch from df2805a to b1b6741 Compare March 18, 2025 19:18
@doudou doudou requested a review from jhonasiv March 18, 2025 19:18
@doudou
Copy link
Member

doudou commented Mar 18, 2025

@jhonasiv updated, please have a look

@doudou doudou force-pushed the policy_merge_in_dataflow_dynamics branch from b1b6741 to c4c5a4b Compare March 21, 2025 19:25
@doudou doudou force-pushed the transition-to-runkit branch from 75f8fa1 to 42d7f4c Compare April 4, 2025 16:17
@doudou doudou force-pushed the policy_merge_in_dataflow_dynamics branch from 888c078 to 2ee8480 Compare April 4, 2025 18:54
@doudou doudou assigned doudou and unassigned eduardacoppo Apr 4, 2025
Copy link
Member

@doudou doudou left a 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
eduardacoppo and others added 4 commits June 20, 2025 06:43
- 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)
@doudou doudou force-pushed the policy_merge_in_dataflow_dynamics branch from 2ee8480 to cbd87b7 Compare June 20, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants