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

Fix nondeterministic test by using dict.fromkeys ~= orderedset #814

Closed
wants to merge 1 commit into from

Conversation

stroxler
Copy link
Contributor

Summary:
For a number of weeks now I've been frustrated by github test failure
notifications. I dug into the root cause for BE day, and it is that we
are using list(set(_)) to deduplicate two lists of references in
the find-references logic.

This is fine and correct, but also nondeterministic because set ordering
isn't fixed. There's no ordered set in the python standard library, and
it's not worth adding a dependency to get one. Instead, the standard trick
to work around this is to use a dict of None so the keys act like a set,
which solves the problem because in 3.7+ dict keys are ordered.

Differential Revision: D52662624

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52662624

stroxler added a commit to stroxler/pyre-check that referenced this pull request Jan 10, 2024
…ebook#814)

Summary:

For a number of weeks now I've been frustrated by github test failure
notifications. I dug into the root cause for BE day, and it is that we
are using `list(set(_))` to deduplicate two lists of references in
the find-references logic.

This is fine and correct, but also nondeterministic because `set` ordering
isn't fixed. There's no ordered set in the python standard library, and
it's not worth adding a dependency to get one. Instead, the standard trick
to work around this is to use a dict of `None` so the keys act like a set,
which solves the problem because in 3.7+ dict keys are ordered.

Differential Revision: D52662624
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52662624

…ebook#814)

Summary:

**Problem**

For a number of weeks now I've been frustrated by github test failure
notifications; many of my commits are generating tasks to fix test failures.

This test is actually disabled in internal CI because it isn't deterministic; that means at least it isn't noisy internally, but we should still fix it!

**Root Cause**

I dug into the root cause for BE day, and it is that we
are using `list(set(_))` to deduplicate two lists of references in
the find-references logic.

Deduping is totally correct, but also nondeterministic because `set` ordering
isn't fixed.

**Solution**

There's no ordered set in the python standard library, and
it's not worth adding a dependency to get one. Instead, the standard trick
to work around this is to use a dict of `None` so the keys act like a set,
which solves the problem because in 3.7+ dict keys are ordered.

Differential Revision: D52662624
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52662624

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in f5a1d8e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants