-
-
Notifications
You must be signed in to change notification settings - Fork 405
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
TST: fix warnings and stop ignoring them #2520
Conversation
a87296b
to
4bbe3c2
Compare
4bbe3c2
to
6eb4d9d
Compare
6eb4d9d
to
2849403
Compare
Codecov Report
@@ Coverage Diff @@
## main #2520 +/- ##
==========================================
+ Coverage 63.61% 63.63% +0.02%
==========================================
Files 132 132
Lines 17074 17092 +18
==========================================
+ Hits 10861 10876 +15
- Misses 6213 6216 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
2849403
to
05e9f4c
Compare
e8cb103
to
d42bdb7
Compare
d42bdb7
to
15a9cf5
Compare
814c433
to
b8ae02d
Compare
29e18aa
to
31ff9a4
Compare
71f9df4
to
ee3ef4d
Compare
@pllim and/or @ceb8 - would you mind to give this a quick review? As you see from the cross-links there have been quite a few things discovered, I fixed some of them already, worked around a few, and currently produced more remote-tests failures than before this PR. |
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.
Great clean-up! Just minor comments from drive-by review. Feel free to ignore if they are no applicable.
else: | ||
file_obj = filename | ||
yield file_obj | ||
yield file_obj |
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.
Can we just yield filename
here and not bother with the extra file_obj = filename
? 🤔
output_file=output_file)#'my_observations.xml') | ||
# assert output_file.exists() |
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.
Remove commented code. Otherwise, please leave a comment on why they are commented.
output_file=output_file)#'my_observations.xml') | |
# assert output_file.exists() | |
output_file=output_file) |
results = cadc.exec_sync( | ||
"SELECT o.observationID, intent FROM caom2.Observation o JOIN " | ||
"tap_upload.test_upload tu ON o.observationID=tu.observationID", | ||
uploads={'test_upload': output_file})#'my_observations.xml'}) |
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.
Remove commented code. Otherwise, please leave a comment on why they are commented. (Won't let me insert suggestion here, not sure why.)
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.
Thanks for spotting, these are debug remains indeed
@@ -406,7 +407,7 @@ def test_get_images(): | |||
Mock(side_effect=lambda x, y, z: ['https://some.url'])) | |||
def test_get_images_async(): | |||
with patch('astroquery.utils.commons.get_readable_fileobj', autospec=True) as readable_fobj_mock: | |||
readable_fobj_mock.return_value = open(data_path('query_images.fits'), 'rb') | |||
readable_fobj_mock.return_value = Path(data_path('query_images.fits')) |
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 am not familiar with the mock stuff here nor know Path very well. Is Path object interchangeable as an open file handler?
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.
Apparently it is. And this mocking really bothers me, this change was necessary as a test in the remote file was failing without this, so there is some fundamental problems with the approach. I might have opened an issue for it and we'll try to remember to check when I get in the office.
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.
hmm, not exactly interchangeable as it turns out here: #2541, but I think it's close enough to be OK. Something is fundamentally wrong with these in-place patches for cadc, but I won't have time to investigate.
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.
Worth a bug ticket?
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.
There have been a few genuine bugs smoked out for the module, and I'm not sure it's worth adding the noise, this only affects the testing and the only effect I saw is the appearance of unclosed file warnings in the skipped remote tests.
I would expect that if there is a real issue with the code, we would be able to catch it with e.g. switching to use ptytest-randomly.
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.
(in short: the only effect I saw is the open file warnings, which is annoying but I doubt would actually affecting users)
@@ -293,3 +293,20 @@ def test_list_jobs(self): | |||
if len(jobs) > 5: | |||
jobs_subset = cadc.list_async_jobs(last=5) | |||
assert len(jobs_subset) == 5 | |||
|
|||
@pytest.mark.xfail(reason='https://github.com/astropy/astroquery/issues/2538') |
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.
Why not use @pytest.mark.filterwarnings
here like the other test?
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.
Eventually, I want these to be cleaned up, and we won't notice if it's a filterwarning.
with open(data_path(DATA_FILES['image']), 'rb') as infile: | ||
yield infile |
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 guess it is okay to have a context manager inside a context manager, though such is not used in the official example usage at https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager . 🤷
with open(data_path(DATA_FILES['image']), 'rb') as infile: | |
yield infile | |
infile = open(data_path(DATA_FILES['image']), 'rb') | |
try: | |
yield infile | |
finally: | |
infile.close() |
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 recall I've seen it somewhere, maybe in the pytest or mock docs or a very similar SO problem. I would rather keep it than switch to try/finally and manual close.
astroquery/sdss/core.py
Outdated
warnings.filterwarnings("ignore", category=AstropyWarning, | ||
message=r'OverflowError converting to IntType in column.*') | ||
arr = Table.read(response.text, format='ascii.csv', comment="#") | ||
for id_column in ['objid', 'specobjid']: |
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.
Nitpicky nitpick.
for id_column in ['objid', 'specobjid']: | |
for id_column in ('objid', 'specobjid'): |
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.
LGTM
ee3ef4d
to
c19f188
Compare
Hmm, so this smoked out a lot of issues on windows, we have 127 remote-test failures there. Some are trivial, but I expect to find a few actual bugs, too. |
Log is here, in case anyone cares to dive in: https://github.com/astropy/astroquery/actions/runs/3171737942/jobs/5165493118#step:5:26037 |
I think it is from astropy-helpers . |
I didn't mean to post a line link, but all the 127 failures, most of which are due to warnings. Updated the link about to point to a better line. |
So some definitely are bugs because the code failed to account for Windows path using Things like ResourceWarning can probably be ignored for now. ... And this one is really weird:
When I copy-pasted http://hst.esac.esa.int/ehst-sl-server/servlet/data-action?OBSERVATION_ID=J6FL25S4Q&USERNAME=ehst-astroquery&CALIBRATION_LEVEL=RAW on my Chrome browser on Windows, a tab popped up but then immediately closed. Might be a server-side problem. |
And there is also this:
Are some servers purposely blocking requests from Windows? Cert issue? |
This one might be worth investigating in case it is
|
A lot of the ESA 500 got fixed upstream yesterday, so those are red herrings. But the sdss ones e.g. real, and is due to the usual large numbers get casted to str on 32bit. Some of it got worked around to manually convert bach, but apparently I missed a few. |
Some of the errors might be due to Windows endline vs *NIX endline (since I don't see any path problem in the traceback) but I am not 100% sure. |
Oh, that's interesting. If that's the case that's an upstream bug for WHITESPACE_NORMALIZE? |
Re: #2520 (comment) Not sure. Will need someone to investigate. I was thinking more like maybe the query is malformed in the backend... 💭 |
Some of these warnings were masking over real issues, e.g. missing test dependencies or ignored pytest markers. Not everything is fixed yet, but locally I'm down to <20, and now pushing a draft PR to check whether anything comes back up when running the tests in different setup scenarios.
This works towards #2057 fixes #2053