Skip to content

fixing astroquery.MAST remote unit tests#2174

Merged
bsipocz merged 16 commits into
astropy:mainfrom
jaymedina:mast-unit-tests-fix
Nov 13, 2021
Merged

fixing astroquery.MAST remote unit tests#2174
bsipocz merged 16 commits into
astropy:mainfrom
jaymedina:mast-unit-tests-fix

Conversation

@jaymedina

@jaymedina jaymedina commented Oct 7, 2021

Copy link
Copy Markdown
Contributor

Closes #2172

@codecov

codecov Bot commented Oct 7, 2021

Copy link
Copy Markdown

Codecov Report

Merging #2174 (4bbcd45) into main (bc722c9) will decrease coverage by 4.31%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2174      +/-   ##
==========================================
- Coverage   66.11%   61.80%   -4.32%     
==========================================
  Files         418      129     -289     
  Lines       28180    16287   -11893     
==========================================
- Hits        18631    10066    -8565     
+ Misses       9549     6221    -3328     
Impacted Files Coverage Δ
astroquery/alma/core.py 36.65% <0.00%> (-0.14%) ⬇️
astroquery/mast/tests/test_mast_remote.py
...ry/open_exoplanet_catalogue/tests/setup_package.py
astroquery/_astropy_init.py
astroquery/solarsystem/mpc/__init__.py
astroquery/utils/tap/xmlparser/tests/__init__.py
astroquery/solarsystem/jpl/__init__.py
astroquery/jplspec/setup_package.py
astroquery/ukidss/__init__.py
astroquery/utils/tap/model/tests/test_job.py
... and 280 more

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 bc722c9...4bbcd45. Read the comment docs.

Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py
@eerovaher

Copy link
Copy Markdown
Member

Linked issue here: #2172

If you wish to link an issue to your pull request then you need to use a keyword GitHub recognizes. See here: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

@bsipocz bsipocz added this to the v0.4.4 milestone Oct 7, 2021
@jaymedina jaymedina changed the title fixing astroquery.MAST remote unit tests [WIP] fixing astroquery.MAST remote unit tests Oct 7, 2021
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
@bsipocz bsipocz marked this pull request as draft October 7, 2021 19:49
@bsipocz

bsipocz commented Oct 7, 2021

Copy link
Copy Markdown
Member

Given you added WIP in the title, I converted it to a draft PR. I'm unsubscribing now, please do ping when it's ready for review.

@jaymedina

Copy link
Copy Markdown
Contributor Author

Sounds good @bsipocz

@pep8speaks

pep8speaks commented Oct 7, 2021

Copy link
Copy Markdown

Hello @jaymedina! 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 2021-11-13 00:32:40 UTC

@jaymedina

jaymedina commented Oct 14, 2021

Copy link
Copy Markdown
Contributor Author

This is almost ready to go @bsipocz . I have a question regarding some of the unit tests in Tesscut and Zcut. There are some unit tests that are intentionally trying to retrieve a table with no results, but pytest crashes on these unit tests with a NoResultsWarning. I tried adding a pytest decorator pytest.mark.filterwarnings to remedy this, but it didn't recognize the NoResultsWarning exception.

Do you know of another workaround for this or should I just remove these tests?

Edit: Some unit tests are unintentionally breaking with the NoResultsWarning, namely the ones for Zcut. I think I know why some of this data is disappearing but I'll talk to some internal folks to verify.

@eerovaher

Copy link
Copy Markdown
Member

In the tests that intentionally trigger a warning it would be best to use the pytest.warns context manager, which will cause the test to fail if the expected warning is not triggered. Here is an example:

with pytest.warns(UserWarning, match='search cone radius'):
a = core.Skybot.cone_search((100, 20), 100, 2451200,
get_query_payload=True)

@jaymedina

Copy link
Copy Markdown
Contributor Author

That worked, thanks!

@jaymedina jaymedina changed the title [WIP] fixing astroquery.MAST remote unit tests fixing astroquery.MAST remote unit tests Oct 14, 2021
@jaymedina

jaymedina commented Oct 14, 2021

Copy link
Copy Markdown
Contributor Author

All tests are now passing and the PR is ready for review + merge @bsipocz . There's one test that's creating a bottleneck, I'm assuming this has always been the case. It's probably one of the download ones. If it's a concern, I can look into it.

test_mast_remote.py .....................................                                                                                          [100%]

============================================================ 37 passed in 2471.04s (0:41:11) =============================================================

cc: @tomdonaldson

Comment thread astroquery/mast/tests/test_mast_remote.py
Comment thread astroquery/mast/tests/test_mast_remote.py
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
@bsipocz

bsipocz commented Oct 14, 2021

Copy link
Copy Markdown
Member

You you fix the style breakage to make sure CI is running on this? Locally this should come back without any issues: pycodestyle astroquery --count

Also, please rebase as there shouldn't be any merge commits in there. I'll do the review once we have a passing CI.

@bsipocz

bsipocz commented Oct 15, 2021

Copy link
Copy Markdown
Member

@jaymedina - something went very wrong with the rebase, could you ask someone at ST to walk you through it (basically no pulls should be done, and absolutely no unrelated commits should be in the PR).

Also, the test failure is genuine, running tests locally should pass with and without --remote-data otherwise CI will certainly fail.

@jaymedina jaymedina force-pushed the mast-unit-tests-fix branch from 16eb567 to 5a05168 Compare October 15, 2021 19:29
@jaymedina

Copy link
Copy Markdown
Contributor Author

Fixed it @bsipocz - the issue was instead of running git push --force like what the documentation instructs I tried to remedy the error from just git push with a pull from origin [my branch]. Working with @tomdonaldson right now and he helped me get this sorted. Once CI tests pass this should be ready to go. Thanks!

@bsipocz bsipocz marked this pull request as ready for review November 12, 2021 22:30

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two remaining tests are failing due to undefined variables used, but the rest looks OK, with minor nitpicks.


def test_observations_download_file(self, tmpdir):
test_obs_id = '2003600312'
test_obs_id = OBSID

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same NameError here


def test_observations_download_products(self, tmpdir):
test_obs_id = '2003600312'
test_obs_id = OBSID

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This produces a NameError. Did you plan to have OBSID as a test parameter, or reuse something from another test?

result = mast.Catalogs.query_region("158.47924 -7.30962",
radius=in_radius,
catalog="Gaia")
row = np.where(result['source_id'] == '3774902350511581696')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick, but it's good practice to use more descriptive variable names, those are helpful when someone comes back to this code, it's enough to reach fewer lines to get the context, so e.g. here it's not a row object, but a row index.
(We're not very good with this practice in the package, I think there are still a few single-letter variables, so as I said this is very much a nitpick only :) )

Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
Comment thread astroquery/mast/tests/test_mast_remote.py Outdated
@bsipocz

bsipocz commented Nov 12, 2021

Copy link
Copy Markdown
Member

This could use some stashing to reduce the number of commits to logical chunks, but otherwise I've switched the PRs status as it fixes all but two tests.

I'll go ahead apply my comments and do some stashing of the pep8 stuff before merging.

@bsipocz bsipocz force-pushed the mast-unit-tests-fix branch from e0fe77f to 4bbcd45 Compare November 13, 2021 00:32
assert isinstance(result, Table)
assert len(result) == sum(products['productType'] == "SCIENCE")

# test downloads 150+ files, 50MB+, TODO: revise OBSID to query only a few, small files for download

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code snippet from this test takes an awfully long time, I've cancelled it after many minutes, when it already downloaded 150+ files, and 50MB+. I'll open a separate issue as a reminder that the test needs to be fixed in a way that only a very small data download should happen at test time.

@bsipocz

bsipocz commented Nov 13, 2021

Copy link
Copy Markdown
Member

Thanks @jaymedina! and @eerovaher for helping with the review!

@bsipocz bsipocz merged commit 9862845 into astropy:main Nov 13, 2021
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.

astroquery.mast remote data unit tests breaking

4 participants