Skip to content
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

model: Serialize dependency graph edges in some explicit order #8696

Merged
merged 3 commits into from
May 24, 2024

Conversation

fviernau
Copy link
Member

Make serialized order independent of insertion order in order to remove the need to update the tests when changing insertion order in upcoming changes.

Part of #6235.

@fviernau fviernau requested a review from a team as a code owner May 24, 2024 11:57
@fviernau fviernau enabled auto-merge (rebase) May 24, 2024 11:57
@fviernau fviernau changed the title Model dep graph edges serializataion model: Serialize dependency graph edges in some explicit order May 24, 2024
@fviernau fviernau force-pushed the model-dep-graph-edges-serializataion branch from f54967c to 23d9873 Compare May 24, 2024 12:13
Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 67.86%. Comparing base (69f8c6e) to head (e872dcf).
Report is 4 commits behind head on main.

Files Patch % Lines
model/src/main/kotlin/utils/SortedSetConverters.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8696      +/-   ##
============================================
- Coverage     67.88%   67.86%   -0.02%     
  Complexity     1165     1165              
============================================
  Files           244      244              
  Lines          7732     7734       +2     
  Branches        865      865              
============================================
  Hits           5249     5249              
- Misses         2124     2126       +2     
  Partials        359      359              
Flag Coverage Δ
funTest-non-docker 34.18% <0.00%> (-0.02%) ⬇️
test 38.02% <50.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fviernau fviernau force-pushed the model-dep-graph-edges-serializataion branch from 23d9873 to 6422045 Compare May 24, 2024 12:14
@@ -102,7 +102,7 @@ data class DependencyGraph(
* A list with the edges of this dependency graph. By traversing the edges, the dependencies of packages can be
* determined.
*/
val edges: List<DependencyGraphEdge>? = null
val edges: Set<DependencyGraphEdge>? = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in line 102 should now also say "set" instead of "list". Also, the commit message should probably also mention that order is not important either (even if a set usually maintains insertion order).

@@ -179,7 +179,7 @@ class DependencyGraphBuilder<D>(
)
}

private fun Collection<DependencyGraphEdge>.removeCycles(): List<DependencyGraphEdge> {
private fun Set<DependencyGraphEdge>.removeCycles(): Set<DependencyGraphEdge> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the spirit of "be lenient when consuming, be strict when producing", should the receiver stay a Collection?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe in general it makes sense, in this case I decided against it so that one does not have to even think about what happens when input contains duplicates, because the API is private (small scope), and because there is no use besides the Sets one.

@fviernau fviernau force-pushed the model-dep-graph-edges-serializataion branch from 6422045 to 8787c8a Compare May 24, 2024 13:17
It is not necessary to allow for having multiple edges between any pair
of nodes. So, always operate with sets to reflect that.

Note that order of edges is not important either (even if a set usually
maintains insertion order).

Signed-off-by: Frank Viernau <[email protected]>
Improve human readability and make the serialized ordering independent
from the insertion order.

Signed-off-by: Frank Viernau <[email protected]>
Use the `RewriteTestAssetsCommand` to re-align the test assets with the
new ordered serialization of `edges`.

Signed-off-by: Frank Viernau <[email protected]>
@fviernau fviernau force-pushed the model-dep-graph-edges-serializataion branch from 8787c8a to e872dcf Compare May 24, 2024 13:19
@fviernau fviernau requested a review from sschuberth May 24, 2024 13:19
@fviernau fviernau merged commit ae9ede0 into main May 24, 2024
19 of 20 checks passed
@fviernau fviernau deleted the model-dep-graph-edges-serializataion branch May 24, 2024 13:56
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.

2 participants