-
Notifications
You must be signed in to change notification settings - Fork 1.2k
895 Update temp directory function in all tests and examples #899
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
Conversation
/black |
1 similar comment
/black |
/black |
I'm good with this, does anyone have any other input @wyli @atbenmurray ? |
Hi @wyli , The previous 2 PRs were:
Now thanks for @ericspod 's suggestion, Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, sounds good, I only have a minor comment about the style
print(f"generating synthetic data to {tempdir} (this may take a while)") | ||
for i in range(5): | ||
im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1) | ||
with tempfile.TemporaryDirectory() as tempdir: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid this large block of indentation by adding the context from outside of main, something like:
if __name__ == "__main__":
with tempfile.TemporaryDirectory() as tempdir:
main(tempdir)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I will change the examples soon.
Thanks.
Fixes #895 .
Description
This PR updated the
tempfile
usage in all the tests and examples according to @ericspod 's suggestion.I didn't change the usage in integration tests because it's used as a class member and didn't change the usage in all the notebooks because it's hard to use "with ... as ... :" in notebooks.
And I also fixed several missing "delete" issue for temp directory in tests, thanks for @ericspod 's suggestion,
tempfile.TemporaryDirectory
is really better to avoid errors.Status
Ready
Types of changes
./runtests.sh --codeformat --coverage
.make html
command in thedocs/
folder.