Skip to content

Fix_issue_2239: Nasa Exoplanet Archive query_object method suddenly produces InvalidTableError#2264

Merged
bsipocz merged 15 commits into
astropy:mainfrom
rickynilsson:fix_issue_2239
Mar 4, 2022
Merged

Fix_issue_2239: Nasa Exoplanet Archive query_object method suddenly produces InvalidTableError#2264
bsipocz merged 15 commits into
astropy:mainfrom
rickynilsson:fix_issue_2239

Conversation

@rickynilsson

Copy link
Copy Markdown
Contributor

Fix query_aliases(). Now using aliaslookup service instead of deprecated aliastable.

@pep8speaks

pep8speaks commented Jan 27, 2022

Copy link
Copy Markdown

Hello @rickynilsson! 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 2022-03-04 00:40:02 UTC

@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.

I'm pretty sure that the test failure is coming from the URL assumption in the mock setup, if you test it locally it should fail there, too, not just for old versions.


@class_or_instance
def query_aliases(self, object_name, *, cache=None):
def query_aliases(self, object_name):

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.

why remove cache? If remove, clear out the docstring, too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wasn't thinking, will add it back.

Comment thread astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py Outdated
@codecov

codecov Bot commented Jan 28, 2022

Copy link
Copy Markdown

Codecov Report

Merging #2264 (8732c6d) into main (4e35238) will decrease coverage by 0.11%.
The diff coverage is 74.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2264      +/-   ##
==========================================
- Coverage   63.10%   62.98%   -0.12%     
==========================================
  Files         131      131              
  Lines       17040    17059      +19     
==========================================
- Hits        10753    10745       -8     
- Misses       6287     6314      +27     
Impacted Files Coverage Δ
...roquery/ipac/nexsci/nasa_exoplanet_archive/core.py 60.76% <74.07%> (-8.12%) ⬇️

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 4e35238...8732c6d. Read the comment docs.

@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.

This fix needs to be mentioned in the changelog as the bug was reported by users. (And also add a mention of the API change for the removed keyword).

Other than the minor comments I left in the review, there is one remote test failing, maybe we could test not for the exact number of aliases but that there are e.g. more than 10?
And if you run the remote test, they would also reveal some docs example inconsistencies. For some of those, e.g. where we expect changes as the upstream database grows, I would suggest to use # doctest: +IGNORE_OUTPUT.

"aliastable", objname=object_name.strip(), cache=cache, format="csv"
)["aliasdis"]
)
url = requests.get("https://exoplanetarchive.ipac.caltech.edu/cgi-bin/Lookup/nph-aliaslookup.py?objname="+object_name)

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.

As you added the base URL for the lookup to the config, please us it from there.


def test_regularize_object_name(patch_get):
NasaExoplanetArchiveMock = NasaExoplanetArchiveClass()
# def test_regularize_object_name(patch_get):

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.

Please either uncomment or if the regularize keyword is removed, then remove this test, too.

@deprecated(since="v0.4.1", alternative="query_object")
@deprecated_renamed_argument(["show_progress", "table_path"],
[None, None], "v0.4.1", arg_in_kwargs=True)
def query_star(self, host_name, cache=None, regularize=True, **criteria):

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 API change needs to be mentioned in the changelog

@rickynilsson

Copy link
Copy Markdown
Contributor Author

@bsipocz - I fixed up the testing and other things you mentioned, but seems codecov isn't happy. Any suggested tests I could add? I actually am not quite sure why the coverage isn't higher -- the tests should be running most of the added code.

@bsipocz

bsipocz commented Jan 28, 2022

Copy link
Copy Markdown
Member

@rickynilsson - I'll need to look into this more carefully to suggest actual code changes, but at first glance, it seems that the mock testing is not actually running anything from the real method from the module, but only the mock function defined in the test, and that triggers the decrease in the coverage number.

@bsipocz

bsipocz commented Mar 1, 2022

Copy link
Copy Markdown
Member

@rickynilsson - do you plan to add some extra test coverage here as part of the PR, or we should rather go ahead and merge and add more tests in a follow-up?

Before merging: doc examples should be fixed (if you run python setup.py -P ipac.nexsci -R it picks up the docs file, too), and a rebase should fix the changelog conflict.

@rickynilsson

Copy link
Copy Markdown
Contributor Author

I should probably just make a final push on this to get the necessary mock tests in place. I'll set off some time to do this tomorrow.

@rickynilsson

Copy link
Copy Markdown
Contributor Author

@bsipocz - something is obviously wrong in the mock test I added but I can't figure out exactly what. Any hints? The monkey patching stuff is a bit confusing to me.

@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.

There is a super nice 92% coverage, with and another nice 83% remote only coverage, so I'm fairly certain we got the majority of use cases under control :)

@bsipocz
bsipocz merged commit 3342888 into astropy:main Mar 4, 2022
@bsipocz

bsipocz commented Mar 4, 2022

Copy link
Copy Markdown
Member

Thank you @rickynilsson!

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.

3 participants