You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
io.fits tests fail on Windows as memmap behaviour has changed #5797
if sys.platform.startswith('win'):
# On Windows, all the original data mmaps were closed above.
# However, it's possible that the user still has references to
# the old data which would no longer work (possibly even cause
# a segfault if they try to access it). This replaces the
# buffers used by the original arrays with the buffers of mmap
# arrays created from the new file. This seems to work, but
# it's a flaming hack and carries no guarantees that it won't
# lead to odd behavior in practice. Better to just not keep
# references to data from files that had to be resized upon
# flushing (on Windows--again, this is no problem on Linux).
for idx, mmap, arr in mmaps:
if mmap is not None:
> arr.data = self[idx].data.data
E DeprecationWarning: Assigning the 'data' attribute is an inherently unsafe operation and will be removed in the future.
astropy\io\fits\hdu\hdulist.py:1342: DeprecationWarning
2 failed, 11580 passed, 200 skipped, 79 xfailed, 1 xpassed in 417.46 seconds =
I don't think we can throw an exception -- that would just break things on windows even if users do not have a reference to these files still around. I hope someone with any experience with windows can help here...
Sorry about this inconsistency. In ci-helpers I was waiting for numpy 1.12 to come out on the defaults channel before making it the default stable, but apparently we only have that control built in our travis builds, so appveyor picked up np 1.12 straight after it became available.
ah, that's a nice hack. I always wondered why I had some permission errors when I used memmap after closing a file.
What behaviour is actually useful here? It seems that io.fits on purpose allows memmaps to extend beyond their "expected" lifetime. I can't think of an not-hacky way to deal with that but I'm actually not too familiar with memory maps and file handles.
changed the title [-]Numpy 1.12 fails on appveyor/windows[/-][+]Numpy 1.12 fails io.fits test on appveyor/windows as memmap behaviour is changing[/+]on Feb 17, 2017
I changed the title -- I fear this will need a real fits/memory mapping expert...
I've also raised an issue with numpy -- numpy/numpy#8628 -- just in case somebody there has ideas (and to ensure we don't get caught if writing to data is removed altogether).
I don't know why the numpy folks decided this shouldn't be allowed anymore. I mean yes, it is unsafe in general, but it was done here for a reason. May be necessary to write something in Cython to do it.
changed the title [-]Numpy 1.12 fails io.fits test on appveyor/windows as memmap behaviour is changing[/-][+]io.fits tests fail on appveyor/windows as memmap behaviour has changed[/+]on Apr 25, 2018
@mattip - thanks very much for the suggestion! I tried looking into it in detail again, and think the worry is not about the user having a reference still to hdu, but rather that they have a reference to hdu.data, i.e., the actual array contained in the file. The latter can be a mmap and it is bad form to have that closed under one's feet. In the original code, therefore, the pointer of the array was just changed. It is not clear at all this is better if there are views, etc.
I think a user having a reference to hdu is not as much of a problem, as then getting data might well do the right thing.
Anyway, since we have had no reports at all of problems from this stanza not having worked roughly forever, I'm doing some tests to see if the whole work-around is in fact needed; see #9228.
changed the title [-]io.fits tests fail on appveyor/windows as memmap behaviour has changed[/-][+]io.fits tests fail on Windows as memmap behaviour has changed[/+]on Oct 27, 2023
Activity
mhvk commentedon Feb 10, 2017
git blamegives code created in May 2012 by @embray.mhvk commentedon Feb 10, 2017
OK, it is a numpy update: 1.12 gives these deprecation warnings (see release notes)
pllim commentedon Feb 10, 2017
So, what would be the new behavior? Just throw an exception or something?
mhvk commentedon Feb 10, 2017
I don't think we can throw an exception -- that would just break things on windows even if users do not have a reference to these files still around. I hope someone with any experience with windows can help here...
bsipocz commentedon Feb 11, 2017
Sorry about this inconsistency. In
ci-helpersI was waiting for numpy 1.12 to come out on the defaults channel before making it the default stable, but apparently we only have that control built in our travis builds, so appveyor picked up np 1.12 straight after it became available.bsipocz commentedon Feb 11, 2017
Pinging @MSeifert04 and @mwcraig as I think they have the most experience with windows among us.
[-]Bug found with appveyor[/-][+]Numpy 1.12 fails on appveyor/windows[/+]xfailing tests for np1.12 and windows that are affected by astropy#5797
bsipocz commentedon Feb 11, 2017
I've added a commit in #5642 to temporarily xfail these two tests for numpy 1.12 and windows, so we can still run appveyor while this issue is solved.
xfailing tests for np1.12 and windows that are affected by astropy#5797
MSeifert04 commentedon Feb 11, 2017
ah, that's a nice hack. I always wondered why I had some permission errors when I used memmap after closing a file.
What behaviour is actually useful here? It seems that
io.fitson purpose allows memmaps to extend beyond their "expected" lifetime. I can't think of an not-hacky way to deal with that but I'm actually not too familiar with memory maps and file handles.[-]Numpy 1.12 fails on appveyor/windows[/-][+]Numpy 1.12 fails io.fits test on appveyor/windows as memmap behaviour is changing[/+]mhvk commentedon Feb 17, 2017
I changed the title -- I fear this will need a real fits/memory mapping expert...
I've also raised an issue with numpy -- numpy/numpy#8628 -- just in case somebody there has ideas (and to ensure we don't get caught if writing to
datais removed altogether).embray commentedon Mar 30, 2017
I don't know why the numpy folks decided this shouldn't be allowed anymore. I mean yes, it is unsafe in general, but it was done here for a reason. May be necessary to write something in Cython to do it.
[-]Numpy 1.12 fails io.fits test on appveyor/windows as memmap behaviour is changing[/-][+]io.fits tests fail on appveyor/windows as memmap behaviour has changed[/+]mhvk commentedon Apr 25, 2018
Changed title to reflect that this is a general problem on windows with all recent versions of numpy.
mattip commentedon Aug 28, 2019
A possible fix to this would be to recreate
hdu.data, so changeto
s/hdu.data/hdu/then the lines that are emitting the warning become
mhvk commentedon Sep 14, 2019
@mattip - thanks very much for the suggestion! I tried looking into it in detail again, and think the worry is not about the user having a reference still to
hdu, but rather that they have a reference tohdu.data, i.e., the actual array contained in the file. The latter can be ammapand it is bad form to have that closed under one's feet. In the original code, therefore, the pointer of the array was just changed. It is not clear at all this is better if there are views, etc.I think a user having a reference to
hduis not as much of a problem, as then gettingdatamight well do the right thing.Anyway, since we have had no reports at all of problems from this stanza not having worked roughly forever, I'm doing some tests to see if the whole work-around is in fact needed; see #9228.
mhvk commentedon Sep 14, 2019
#9228 failed, i.e., we still need the work-around for windows: any memory maps need to be closed before resizing the file.
mattip commentedon Sep 14, 2019
That was my intention
[-]io.fits tests fail on appveyor/windows as memmap behaviour has changed[/-][+]io.fits tests fail on Windows as memmap behaviour has changed[/+]