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

test_prototype_datasets_builtin: Properly close all streams #7403

Merged
merged 2 commits into from
Mar 9, 2023

Conversation

SvenDS9
Copy link
Contributor

@SvenDS9 SvenDS9 commented Mar 9, 2023

In pytorch/data#1016 I noticed that if a test fails subsequent tests will also fail as not all streams are being closed correctly due to:

for stream in StreamWrapper.session_streams.keys():
RuntimeError: dictionary changed size during iteration

This addresses this issue so that only the "necessary" tests fail.
In theory we should also be able to remove l.135-136 but to be safe I have kept them.

if StreamWrapper.session_streams:
    raise pytest.UsageError(make_msg_and_close("A previous test did not close the following streams:"))

cc @pmeier @bjuncek

@pytorch-bot
Copy link

pytorch-bot bot commented Mar 9, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/7403

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Merge Blocking SEVs

There is 1 active merge blocking SEVs. Please view them below:

If you must merge, use @pytorchbot merge -f.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pmeier pmeier self-requested a review March 9, 2023 15:44
@pmeier
Copy link
Collaborator

pmeier commented Mar 9, 2023

Thanks @SvenDS9 for the report and fix. The error looks quite weird to me TBH. We are never touching StreamWrapper.session_streams.keys() so why would this happen? Could it be that stream.close() removes it on the fly and thus causing this? If so, wouldn't it be sufficient to just copy the iterator, e.g. for stream in list(StreamWrapper.session_streams.keys())?

@SvenDS9
Copy link
Contributor Author

SvenDS9 commented Mar 9, 2023

Thanks @SvenDS9 for the report and fix. The error looks quite weird to me TBH. We are never touching StreamWrapper.session_streams.keys() so why would this happen? Could it be that stream.close() removes it on the fly and thus causing this? If so, wouldn't it be sufficient to just copy the iterator, e.g. for stream in list(StreamWrapper.session_streams.keys())?

I think that is what happens yes. And you are right, that is sufficient. Will change it now.

@SvenDS9 SvenDS9 force-pushed the fix_test_prototytpe_datasets branch from 31573fe to 419d039 Compare March 9, 2023 17:03
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @SvenDS9! This will be available in tomorrows nightly release. Could you push an update to pytorch/data#1016 after roughly 12:00 UTC+0 tomorrow to see if this actually fixed your issue?

@pmeier pmeier merged commit 4a7def8 into pytorch:main Mar 9, 2023
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

Hey @pmeier!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@SvenDS9
Copy link
Contributor Author

SvenDS9 commented Mar 9, 2023

I have already run the test with my changes to both the test and the datapipe. It unfortunately does not. I would be very grateful if you could take a look why the stream isn't being closed correctly. as you probably have a much deeper understanding what actually happens in the tests... i have linked the relelvant parts in the PR. Please don't feel obligated to do so as I have already wasted enough time on this :D

@pmeier
Copy link
Collaborator

pmeier commented Mar 9, 2023

I have already run the test with my changes to both the test and the datapipe. It unfortunately does not.

Sorry, I was not clear enough above. Could you make sure that the issue of failing unrelated tests that was addressed by this PR is fixed? Meaning, after this PR you should only see relevant test failures on the TorchData PR, right?

I would be very grateful if you could take a look why the stream isn't being closed correctly. as you probably have a much deeper understanding what actually happens in the tests

I'll look into it if I find some time next week. No promises however.

facebook-github-bot pushed a commit that referenced this pull request Mar 30, 2023
…7403)

Summary: Co-authored-by: Philip Meier <[email protected]>

Reviewed By: vmoens

Differential Revision: D44416630

fbshipit-source-id: efee1b0849c7e19ba1859f185bff421400046a12
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.

3 participants