Repository navigation
Provide a Dask interface to pyFFTW's 1-D FFTs - #154
Conversation
19936fb to
2b36900
Compare
|
So it seems some really old copies of Dask are used on Python 3.3 and 3.4, but we require a much newer version. Maybe we can just skip these tests there? Python 2.7 passes. Python 3.5 passes the tests we have added, but fails some other seemingly unrelated tests. |
| #!/usr/bin/env python | ||
| # | ||
| # Henry Gomersall | ||
| # [email protected] |
There was a problem hiding this comment.
Perhaps you need to add yourself here...
There was a problem hiding this comment.
Maybe we should just have an author's file instead.
There was a problem hiding this comment.
Yup, that could work too.
| # Copyright 2015 Knowledge Economy Developments Ltd | ||
| # | ||
| # Henry Gomersall | ||
| # [email protected] |
|
It looks sensible to me. Is the test file just a modified clone of the np interface test file? I would like to wrap the Dask stuff with an import exception handler - Dask shouldn't be a global dependency. This is done for scipy in the interfaces IMO skipping 3.3 and 3.4 for Dask only is fine. You can use the |
|
Oh sorry, you made a note about the tests in your first comment. |
Yep. Had to cut the 2-D and N-D stuff as it is not supported in a release yet. Will add back 2-D and N-D stuff once a newer release supports it. Also Dask arrays are immutable (they are actually graphs of operations that are lazy evaluated) so any mutable tests had to go as well. Then, of course, some tweaks to use Dask arrays and not NumPy arrays. Though going back and forth is trivial.
Sounds fine to me. Will look into it.
Ok, also we might be able to pip install Dask to get a new enough version that works on Python 3.4 if we want. However they don't test against Python 3.3 any more, so we should definitely skip that one. |
a33b3ea to
6711375
Compare
|
Alright have fixed this up so that Dask is an optional requirement. The interface is hidden if Dask isn't available. Now tests are skipped if the Dask isn't a new enough version, which handles the Python 3.3 and 3.4 issues seen before in a cleaner way. The tests seem to pass. However, am still seeing a couple seemingly unrelated test failures with Python 3.3 and 3.5 Not sure what is going on there. Any advice definitely appreciated. |
|
@mrocklin, am working on an interface for Dask to add to pyFFTW. Would generally appreciate any feedback you have on it. Also am noticing some tests failing with |
|
The failure seems not so serious. It's a failure in a pre-test tidy up routine. The cache is running in a different thread so the two failing tests first of all do a pause to let the cache be emptied properly. I don't know why your changes are suddenly causing it to fail. I've seen this before and solved it by increasing the time allowed to empty the cache (on lines 171 and 196 of the cache tests). That said, it seems a bit suboptimal to keep increasing the test times. I suspect there is something to do with CPU contention on the Travis server, but I don't really know. It could very easily be in that dark and murky domain of multi threading interacting with CPU availability to produce non obvious outcomes. I suspect it's not a bug. I'd be interested to know if the tests run on your local machine... |
|
So if I run the whole test suite, I get 3 failures from
Edit: If I bump the timeouts for all of these up to 1.0s, I'm able to rid myself only of the last failure locally. |
|
hmmm interesting. I'm slightly at a loss. Can you try disabling and reenabling the cache (instead of the pause)? |
|
Me too. 😕 Sorry, not super familiar with the cache, how do I do that? Edit: NVM think I figured it out. |
|
Yeah, I gave enabling/disable the cache a try. No dice. 😞 It's interesting as the Dask tests run before the cache tests do. I wonder if one is effecting the other somehow. 😕 Maybe I'll give switching the order a try. |
|
Yes, I think that probably is happening. If you disable the Dask tests, do the numpy_interface tests run before or after? That would explain why it only appears with the code. |
|
So I've been using If I rename the cache tests to |
Goes ahead and renames the cache interface test module to match the naming of the other interface test modules.
6711375 to
e35440a
Compare
Wrap the existing NumPy interface so that it will integrate nicely with Dask. As Dask currently only supports 1-D FFT functions, simply wrap and provide those for now. In the future Dask will support 2-D and N-D FFT function. This will be updated at that time to provide those too. Also add borrow tests from the NumPy interface to use with the Dask interface. Update it to use the Dask interface, work with Dask Arrays, and drop any tests that deal with mutation or 2-D/N-D FFT functions. Further autdoc all functions in the interface so as to include them in the documentation.
e35440a to
f89c4c7
Compare
|
Ok, I think the problem is due to the ordering, with either the dask or the numpy tests causing the cache to be in an unexpected state. There is only one reference to the cache in any test other than the cache tests, and it's in the numpy interfaces (and now the Dask interfaces) on line 173. I'm minded to try removing that disabling and seeing if it fixes the problem... |
|
What we need is some debugging info on where that thread is from. As a starting point, we can call |
|
The enumerate of the last comment should be done where the tests are failing. |
|
I think Dask and/or Distributed is starting daemon threads. So they won't shutdown until the process (Python interpreter) ends. TBH I don't know if we are going to find a better solution than this workaround. Unless, of course, we run the Dask tests in a totally separate Python process. |
|
My apologies if this has caused some development pain
…On Thu, Mar 30, 2017 at 4:56 PM, Matthew Rocklin ***@***.***> wrote:
Dask is not shy about starting daemon threads
On Thu, Mar 30, 2017 at 4:55 PM, jakirkham ***@***.***>
wrote:
> I think Dask and/or Distributed is starting daemon threads. So they won't
> shutdown until the process ends. TBH I don't know if we are going to find a
> better solution than this workaround. Unless, of course, we run the Dask
> tests in a totally separate Python process.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#154 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AASszJY1byvyOgK910dWzQ_WLhM0T8ATks5rrBa-gaJpZM4Mt1Fb>
> .
>
|
|
Is there another way to shutdown daemon threads that you know of, @mrocklin? |
|
Shutting down threads generally, no.
I'm curious what threads are causing grief. Do you have any information
about them?
…On Thu, Mar 30, 2017 at 4:59 PM, jakirkham ***@***.***> wrote:
Is there another way to shutdown daemon threads that you know of,
@mrocklin <https://github.com/mrocklin>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#154 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszBLZybOdWe7gPPGPa41HDCuxr3suks5rrBfNgaJpZM4Mt1Fb>
.
|
|
It's not that the threads are causing grief per se. Just that they are daemon threads and thus are still around. The caching tests in pyFFTW have a bunch of assertions checking that an exact number of threads are in use at different times. The asserted values are all going to be wrong if these cache tests are run after Dask as they don't factor in the daemon threads may already be present. IMHO there are three possible general fixes.
Right now this PR has included solution 1. If these tests are really flaky (I'm not too familiar with their history), 3 might be reasonable. TBH 2 feels like a lot of work that is a bit out of scope. |
|
This is interesting problem. I think the better strategy is to change the checks in the failing tests to make they only pick up the ones created by pyfftw. I don't know how to do this, but I suspect there is a reasonable way. |
|
Something like the following should detect only the pertinent thread I think: cache_thread_running = False
for each_thread in threading.enumerate()
cache_thread_running = (
cache_thread_running or each_thread._Thread__target == pyfftw.interfaces.cache._Cache._run)
assert not cache_thread_running |
|
TBH I know very little about how the cache works in pyFFTW nor the test suite associated. So I don't feel very comfortable rewriting the whole test suite. While there may be better solutions than the one included here, I don't think I'm the best person to ask to rework the cache's test suite. |
|
Ok, I can revisit this. I'll try to take a look on Sunday. In essence, what needs to be done is the check on the threads in those two test needs to check only those spawned by pyfftw. I'll make a little internal function that does as described above. Can you allow me rights to edit your branch? (like this) |
|
Thanks @hgomersall. Definitely appreciate it. Sure, you should have permissions. Please let me know if you have any issues. |
|
Ok, I've pushed changes that should fix the problem. I'd be interested to know if it does (I think the problem is gone because of the name change, right?). |
…braries load threads.
e634028 to
29adb37
Compare
|
That didn't work. Trying again! |
This reverts commit a0aae55.
|
Thanks very much @hgomersall. If I revert the directory rename locally, the issue appears to go away. Will push that change here so we can see how it does on CIs. |
|
Appears to have worked. |
|
Good news. Are we happy with this now? |
|
Yep, LGTM. Thanks again. |
|
Great, thank you! |
| * :func:`pyfftw.interfaces.numpy_fft.rfft` | ||
| * :func:`pyfftw.interfaces.numpy_fft.irfft` | ||
| * :func:`pyfftw.interfaces.numpy_fft.hfft` | ||
| * :func:`pyfftw.interfaces.numpy_fft.ihfft` |
There was a problem hiding this comment.
This should have been dask_fft instead of numpy_fft. PR ( #166 ) fixes this.
| which this may not be true. | ||
| ''' | ||
|
|
||
| from . import numpy_fft |
There was a problem hiding this comment.
It's probably cleaner to import functions from this interface, wrap them, and overwrite the associate variables with our wrappers. This was we don't accidentally expose this module in our interface. PR ( #165 ) does exactly this.
Fixes #151
Wrap the existing NumPy interface so that it will integrate nicely with Dask. As Dask currently only supports 1-D FFT functions, simply wrap and provide those for now. In the future Dask will support 2-D and N-D FFT function. This will be updated at that time to provide those too. Also add borrow tests from the NumPy interface to use with the Dask interface. Update it to use the Dask interface, work with Dask Arrays, and drop any tests that deal with mutation or 2-D/N-D FFT functions. Further autdoc all functions in the interface so as to include them in the documentation.
Note: The current release of Dask only supports 1-D FFT functions. However, 2-D and N-D FFT functions are supported in
masterand should be available in the next release. We can update this interface as soon as they are available.