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

Switch from using nibabel InTemporaryDirectory to standard library tmpfile module #2589

Merged
merged 10 commits into from May 25, 2022

Conversation

jacobdr
Copy link

@jacobdr jacobdr commented May 6, 2022

Closes #2587

@arokem
Copy link
Contributor

arokem commented May 6, 2022

Thanks for doing this. And thanks for pinging the nibabel GitHub about this as well. I am curious to see if there's some reason I don't know that they implemented it this way.

@codecov
Copy link

codecov bot commented May 7, 2022

Codecov Report

Merging #2589 (6f2a667) into master (f1e89b7) will decrease coverage by 0.35%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2589      +/-   ##
==========================================
- Coverage   85.04%   84.68%   -0.36%     
==========================================
  Files         129      130       +1     
  Lines       17613    17752     +139     
  Branches     2999     3015      +16     
==========================================
+ Hits        14979    15034      +55     
- Misses       1934     2013      +79     
- Partials      700      705       +5     
Impacted Files Coverage Δ
dipy/direction/peaks.py 84.50% <100.00%> (ø)
dipy/io/gradients.py 95.55% <100.00%> (-0.19%) ⬇️
dipy/reconst/qti.py 92.83% <0.00%> (-6.73%) ⬇️
dipy/data/fetcher.py 40.56% <0.00%> (-2.65%) ⬇️
dipy/data/__init__.py 80.41% <0.00%> (ø)
dipy/viz/plotting.py 13.33% <0.00%> (ø)

@matthew-brett
Copy link
Contributor

Thanks for doing this. And thanks for pinging the nibabel GitHub about this as well. I am curious to see if there's some reason I don't know that they implemented it this way.

Well - as @effigies says in nipy/nibabel#1102 (comment) - once you've accepted the premise in the class name - that the code context involves changing to temporary directory - I don't think there's any other way to implement it. But maybe there is - happy to hear if so.

Or you might ask - why write tests that involve changing the directory? I guess there are various reasons - just to save some code for prefixing the path to lots of temporary files, and testing a process that creates something in the working directory, were two things I thought of.

dipy/io/gradients.py Outdated Show resolved Hide resolved
…or on windows. Switch to using SpooledTemporaryFile to avoid writing to disk if possible as a performance optimization
@pep8speaks
Copy link

pep8speaks commented May 7, 2022

Hello @jacobdr, Thank you for updating !

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated at 2022-05-25 17:14:36 UTC

dipy/io/gradients.py Outdated Show resolved Hide resolved
@skoudoro
Copy link
Member

skoudoro commented May 9, 2022

Hi @jacobdr,

Many tests are failing, can you look at what is going wrong like here?

Thanks!

@jacobdr
Copy link
Author

jacobdr commented May 16, 2022

@skoudoro sorry to take so long to get back to this. Just expanded the test coverage in my most recent commits and we'll see how the tests fare now. I was trying to find a way to not have to write back out to disk for performance reasons but I think that is outside the scope of this ticket... so I kept it pretty low-risk and faithful to the OG implementation

@jacobdr
Copy link
Author

jacobdr commented May 16, 2022

@matthew-brett @skoudoro can I request a re-review given the changes I made to expand the test coverage please? (also need an approval on the pending GH actions workflow for CI)

Copy link
Member

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @jacobdr,

Your tests are in the wrong file. See below for additional details.
Thank you in advance for the update.

ps: failing CIs are not related to your PR now, it should be fixed in #2595

dipy/core/tests/test_gradients.py Outdated Show resolved Hide resolved
dipy/core/tests/test_gradients.py Outdated Show resolved Hide resolved
@skoudoro
Copy link
Member

Hi @jacobdr,

This PR is almost done, it would be great if you could rebase this PR and address the last comment.
Please, keep us updated. Thank you!

@jacobdr
Copy link
Author

jacobdr commented May 20, 2022

@skoudoro recent commits:

  • merged master
  • reverted all changes to test_gradients in deference to dipy/io/tests/test_io_gradients.py as you astutely pointed out I had re-invented the wheel. the lack of change in coverage should have tipped me off.

dipy/io/gradients.py Outdated Show resolved Hide resolved
skoudoro and others added 2 commits May 25, 2022 18:39
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
@skoudoro
Copy link
Member

Thanks @jacobdr for doing this!

Thanks @matthew-brett @effigies @arokem for the review.

merging

@skoudoro skoudoro merged commit 80491bd into dipy:master May 25, 2022
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.

Thread safety concerns with reliance on nibabel.tmpdirs.InTemporaryDirectory
6 participants