[GCU] Different apply-patch runs should produce same sorted steps#1988
Merged
ghooo merged 1 commit intosonic-net:masterfrom Dec 27, 2021
Merged
[GCU] Different apply-patch runs should produce same sorted steps#1988ghooo merged 1 commit intosonic-net:masterfrom
ghooo merged 1 commit intosonic-net:masterfrom
Conversation
93d2538 to
6ab8deb
Compare
ghooo
commented
Dec 25, 2021
qiluo-msft
approved these changes
Dec 27, 2021
judyjoseph
pushed a commit
that referenced
this pull request
Jan 9, 2022
) #### What I did Fixes #1976 Different runs of `apply-patch` would produce different sorted steps. It is better to be consistent while producing the sorted steps to make it easier to debug issues in the future. The issue is with using `set(list)` to remove duplicates from the list. Looping over the set elements does not guarantee same order every time we iterate. To reproduce this do the following: 1. Create a file named `test.py` with the content ```python x = ["XYZ", "ABC", "DEF"] y = set(x) print(y) ``` 2. Run `python3 test.py` 3. Again `python3 test.py` 4. Again `python3 test.py` The output of these runs will be different each time. #### How I did it Instead of returning a `set`, return a list of `ref_paths` which does not have duplicated elements inserted to begin with. #### How to verify it unit-tests #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed)
dbarashinvd
pushed a commit
to dbarashinvd/sonic-utilities
that referenced
this pull request
Jul 11, 2022
…nic-net#1988) #### What I did Fixes sonic-net#1976 Different runs of `apply-patch` would produce different sorted steps. It is better to be consistent while producing the sorted steps to make it easier to debug issues in the future. The issue is with using `set(list)` to remove duplicates from the list. Looping over the set elements does not guarantee same order every time we iterate. To reproduce this do the following: 1. Create a file named `test.py` with the content ```python x = ["XYZ", "ABC", "DEF"] y = set(x) print(y) ``` 2. Run `python3 test.py` 3. Again `python3 test.py` 4. Again `python3 test.py` The output of these runs will be different each time. #### How I did it Instead of returning a `set`, return a list of `ref_paths` which does not have duplicated elements inserted to begin with. #### How to verify it unit-tests #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Fixes #1976
Different runs of
apply-patchwould produce different sorted steps. It is better to be consistent while producing the sorted steps to make it easier to debug issues in the future.The issue is with using
set(list)to remove duplicates from the list. Looping over the set elements does not guarantee same order every time we iterate. To reproduce this do the following:test.pywith the contentpython3 test.pypython3 test.pypython3 test.pyThe output of these runs will be different each time.
How I did it
Instead of returning a
set, return a list ofref_pathswhich does not have duplicated elements inserted to begin with.How to verify it
unit-tests
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)