Fix race condition in FastText tests #3059
Merged
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.
This is in relation to #3050
I found two main problems which were causing the tests to fail intermittently when run in parallel. I found this problem in at least 4 tests during my initial analysis.
get_tmpfile(x)
only creates the file name/tmp/x
which is not unique, and can be overwritten when tests run in paralleltemporary_file
will not create temporary directory, when absolute path is provided (byget_tmpfile
)Hence, when running these tests in parallel, they write to the same file, e.g.,
/tmp/gensim_fasttext.tst
causing them to failIn this PR, I fix this by
get_tmpfile
temporary_file
instead oftemporary_file(get_tmpfile(...))
These changes fix all the flaky failures reported previously and most likely many others. If these changes makes sense, I can extend this fix to
test_word2vec.py
andtest_doc2vec.py
which also have the 2nd problem described above.Let me know what you guys think. Thanks!