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

remove call to system-wide gunzip. Use python version instead. #1613

Merged
merged 8 commits into from
Apr 16, 2020

Conversation

erwanp
Copy link
Contributor

@erwanp erwanp commented Jan 9, 2020

Fixes #1538

@pep8speaks
Copy link

pep8speaks commented Jan 9, 2020

Hello @erwanp! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-04-16 06:06:23 UTC

@astropy-bot astropy-bot bot added the utils label Jan 9, 2020
@erwanp
Copy link
Contributor Author

erwanp commented Jan 11, 2020

@keflavich you may want to have a look!

@keflavich
Copy link
Contributor

Looks good at a glance. Do we have any tests for this? If not, are there any tests you could add?

Thanks!

@erwanp
Copy link
Contributor Author

erwanp commented Jan 11, 2020

The gunzip utility is only used by the eso module. Could you tag anyone from there that could provide test files?

@keflavich
Copy link
Contributor

I'm not sure we have any regular contributors to the ESO package at the moment, but that's a good thought. Maybe we can at least make some sort of round-trip test to create, zip, and unzip a file... otherwise we need to come up with some example from ESO that returns a zip. I don't know of any off the top of my head.

@codecov
Copy link

codecov bot commented Jan 13, 2020

Codecov Report

Merging #1613 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1613      +/-   ##
==========================================
+ Coverage   62.45%   62.47%   +0.02%     
==========================================
  Files         187      187              
  Lines       15036    15025      -11     
==========================================
- Hits         9390     9387       -3     
+ Misses       5646     5638       -8     
Impacted Files Coverage Δ
astroquery/utils/system_tools.py 54.16% <100.00%> (+8.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa9a34b...df3475a. Read the comment docs.

@erwanp
Copy link
Contributor Author

erwanp commented Jan 13, 2020

  • I ran the ESO tests locally but I didn't get any zipped file there.
  • I added a test_system_tools.py file that does a round-trip test with a dummy file
  • I don't know if there is a dedicated way in pytest to remove dummy files, so I did it with the usual os/os.path functions

Copy link
Contributor

@keflavich keflavich left a comment

Choose a reason for hiding this comment

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

Looks good. The best way to deal with files like this is to use tempfile, which handles file creation/deletion for you in a system-independent way (I think, anyway... at least, it should find a directory where you have write access)

from ..system_tools import gunzip

def test_gunzip():
filename = 'test_system_tools.txt.gz'
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use tempfile instead, e.g.:

filehandle = tempfile.NamedTemporaryFile(suffix='.txt.gz')
filename = filehandle.name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ty, done!

@keflavich
Copy link
Contributor

We just have some minor style fixes (see #1613 (comment) above, which was edited for your last PR) to get travis to go green, then I'll merge

@keflavich
Copy link
Contributor

OK this is weird - @bsipocz , could you have a look? pep8speaks reports no errors, but travis is reporting:
astroquery/utils/system_tools.py:14:1: E302 expected 2 blank lines, found 1

Is this a bug in our configurations, i.e., is pep8 ignoring something that travis isn't?

@keflavich
Copy link
Contributor

There's a travis failure that appears unrelated to this PR. I think this is good to merge, but let's hear from @bsipocz first to see if she has any ideas about the travis install failure

@bsipocz bsipocz added this to the v0.4 milestone Jan 23, 2020
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

A changelog entry wouldn't hurt. I also have minor comments. I'll address them straight away, so I'll get closer to get that next 0.4 tag out.

import shutil
import gzip

# @EP 09/01/20: system-wide 'gzip' was removed, Python gzip used instead.
Copy link
Member

Choose a reason for hiding this comment

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

no need to date/sign comments. The git history/blame is more reliable to trace things back.

"""

# STDLIB
import gzip
Copy link
Member

Choose a reason for hiding this comment

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

A bit bike shedding, but now that gzip is assumed to be optional, we need to make sure to skip the test if it's not available.

import tempfile

# THIRD-PARTY
import pytest
Copy link
Member

Choose a reason for hiding this comment

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

unused import.

@bsipocz
Copy link
Member

bsipocz commented Jan 23, 2020

I'm now a bit confused. Is the python gzip is available on all platforms? This seems to assume it's not.

@bsipocz
Copy link
Member

bsipocz commented Jan 23, 2020

The travis failure was unrelated. The one remaining failure will be addressed by #1607

Also, my commit might not be neccessary, but if we revert it, then the imports also need to be moved up to the top of the file, and some more comments removed, too.

@bsipocz bsipocz force-pushed the fix_gzip_not_found branch from 8c2eb21 to 5a1d7a9 Compare January 23, 2020 04:06
@bsipocz
Copy link
Member

bsipocz commented Jan 23, 2020

The windows test failure is related, maybe @pllim has some insights.

@pllim
Copy link
Member

pllim commented Jan 23, 2020

Re: Windows -- I think it is the same issue that @astrofrog encountered (and fixed) in astropy/astropy#9874

@bsipocz bsipocz modified the milestones: v0.4, v0.4.1 Feb 3, 2020
@erwanp
Copy link
Contributor Author

erwanp commented Apr 6, 2020

Re: Windows -- I think it is the same issue that @astrofrog encountered (and fixed) in astropy/astropy#9874

The error is a Permission error on the Windows version of Travis so it doesn't seem related to astropy/astropy#9874 (which was pytest related). Details:

PermissionError: [Errno 13] Permission denied: 'C:\Users\travis\AppData\Local\Temp\tmp0yd2zq3f.txt.gz'

I looked up for Permissions + Windows Travis-cI for for about 40min with no luck. However, I found another ocurrence of tempfile in test_utils/test_filecontainer_save() where a temp folder is used instead of a tempfile, and that seems to be executed with no problem.

I re-wrote our test here to use a tempfolder, we'll see if that helps.

@erwanp
Copy link
Contributor Author

erwanp commented Apr 8, 2020

Ended up with a KeyError: 'independent_celestial_slices' error that does not seem related to this Issue. I tried to merge the latest changes (will clean the commits at the end) but that didn't help neither. On hold until further notice.

@astrofrog
Copy link
Member

The KeyError: 'independent_celestial_slices' error comes from reproject and should be fixed in reproject 0.7

@bsipocz
Copy link
Member

bsipocz commented Apr 8, 2020

@erwanp - could you please rebase? That would get rid of the merge commit, and retrigger CI. (I'm still not certain why the old version of reproject is picked up, rather than the new 0.7)

@erwanp erwanp force-pushed the fix_gzip_not_found branch from 3af92b9 to 69f2dc2 Compare April 8, 2020 22:05
@erwanp
Copy link
Contributor Author

erwanp commented Apr 8, 2020

Done, still get the reproject error.

@bsipocz bsipocz force-pushed the fix_gzip_not_found branch from 69f2dc2 to df3475a Compare April 16, 2020 06:06
@bsipocz
Copy link
Member

bsipocz commented Apr 16, 2020

Thank you @erwanp!

@bsipocz bsipocz merged commit 815d2e5 into astropy:master Apr 16, 2020
@saimn
Copy link
Contributor

saimn commented Sep 7, 2020

While looking at reading .fits.Z with astropy (astropy/astropy#10714) I remembered about this and was curious to see how astroquery managed those files.

@bsipocz
Copy link
Member

bsipocz commented Sep 9, 2020

thanks for checking @saimn! Would you mind opening an issue about it?

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.

gzip was not found on your system!
7 participants