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

Refactor astroquery.heasarc to use VO protocols #2997

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

zoghbi-a
Copy link
Contributor

@zoghbi-a zoghbi-a commented Apr 25, 2024

This a major refactor of the heasarc module to use the VO interface to the archive. The main motivation is:

  • Allow for complex region and table queries.
  • Expose the TAP service.
  • Cleanup the tests.
  • Since the VO interface is the main archive interface, the archive will be able to support this module more.

The main changes inlcude:

  • The old class has been renamed HeasarcClass -> HeasarcBrowseClass. The initialized instance is also rename Heasarc -> HeasarcBrowse. The same for the test files.
  • The old HeasarcClass has been removed, and its main methods are included in the class with a deprecation message.
  • The new HeasarcClass class uses an interface similar to those used in other modules e.g. ipac.irsa.
  • A deprecation message has been added to the methods used for querying the tables and columns.
  • Added the ability to download data from the main heasarc servers, Sciserver and from the cloud.

@pep8speaks
Copy link

pep8speaks commented Apr 25, 2024

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

Line 24:1: E302 expected 2 blank lines, found 1
Line 97:13: W503 line break before binary operator
Line 118:13: W503 line break before binary operator
Line 485:17: W503 line break before binary operator
Line 505:13: W503 line break before binary operator

Comment last updated at 2024-10-21 02:03:21 UTC

@zoghbi-a zoghbi-a force-pushed the heasarc-refactor branch 2 times, most recently from 43e9fe4 to 7f74228 Compare April 25, 2024 20:42
@zoghbi-a zoghbi-a marked this pull request as ready for review April 25, 2024 20:52
@bsipocz bsipocz added this to the v0.4.8 milestone May 10, 2024
@bsipocz
Copy link
Member

bsipocz commented May 10, 2024

The old class has been renamed HeasarcClass -> HeasarcBrowseClass. The initialized instance is also renamed Heasarc -> HeasarcBrowse. The same for the test files.

What is the motivation for this? Are there any datasets that are only accessible using the webform, but not the VO backends?

(If the only motivation is to keep what has been here, then it's not necessary, removing everything as part of the refactor is totally fine. Ideally, the old user codes should keep working, but with such a large backend restructure we also have precedence for breaking those)

Doing a proper review may take me until I'm back from the interop.

@zoghbi-a
Copy link
Contributor Author

All the tables should available through the new API, so it is kept in case some people are using it. If it is ok to remove the old class, I don't see a stopper.

@bsipocz
Copy link
Member

bsipocz commented May 10, 2024

so it is kept in case some people are using it

A rename doesn't really solve this scenario, as the continued support would have only worked if the name was kept the same, maybe with a deprecation warning.

So, before diving into a review, I would suggest cleaning up the old class. Maybe try to keep as much of the test examples/docs examples working as possible, or maybe working with a deprecation warning (e.g. in case some of the keywords need to be dropped, or renamed).

@zoghbi-a
Copy link
Contributor Author

The new class implements most of the useful methods of the old class with a deprecation warning. I will then delete the old class and keep the methods and warnings in the new class.

@zoghbi-a zoghbi-a force-pushed the heasarc-refactor branch 2 times, most recently from 354384f to baf95ed Compare May 15, 2024 14:58
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.

I only leave a WIP review for now, that focuses only on the API, and will try to come back and look into the code itself later, hopefully later this week or next week. I was thinking it's useful to leave what I have for now, than hold it back until I have the time to do the full review.

astroquery/heasarc/__init__.py Outdated Show resolved Hide resolved
CHANGES.rst Outdated Show resolved Hide resolved
astroquery/heasarc/core.py Outdated Show resolved Hide resolved
astroquery/heasarc/core.py Show resolved Hide resolved
astroquery/heasarc/core.py Outdated Show resolved Hide resolved
astroquery/heasarc/core.py Outdated Show resolved Hide resolved
astroquery/heasarc/core.py Show resolved Hide resolved
astroquery/heasarc/core.py Show resolved Hide resolved
astroquery/heasarc/core.py Show resolved Hide resolved
astroquery/heasarc/tests/setup_package.py Show resolved Hide resolved
@zoghbi-a
Copy link
Contributor Author

@bsipocz, is there a timeline for completing the review?

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 50.39062% with 127 lines in your changes missing coverage. Please review.

Project coverage is 67.20%. Comparing base (58f8692) to head (afa7ba2).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
astroquery/heasarc/core.py 49.80% 127 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2997      +/-   ##
==========================================
- Coverage   67.49%   67.20%   -0.29%     
==========================================
  Files         233      233              
  Lines       18413    18528     +115     
==========================================
+ Hits        12428    12452      +24     
- Misses       5985     6076      +91     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

I did an airport review, thus couldn't run the remote tests and their coverage.
Neither was building the documentation, but what I have noticed that it is full of both code and text typos, so please have a careful look at it.

The module itself looks reasonably good, my primary comments are the same I already left in the summer, namely it would be great if methods and arg names could be more similar to those already existing in some of the modules (e.g. avoid using table as a kwarg as it leads to either confusion or code mistakes.


@async_to_sync
Copy link
Member

Choose a reason for hiding this comment

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

As this is practically a new module, no need to do this. (I'll clean these up in the upcoming astroquery work, but it's even better if it's not added).

We have started to talk about to ditch the duplication of methods and implement actual async methods (#2598)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed!

from ..exceptions import InvalidQueryError, NoResultsWarning
from . import conf

__all__ = ['Heasarc', 'HeasarcClass']
Copy link
Member

Choose a reason for hiding this comment

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

Please don't remove this, we don't want to expose all of the above imports, etc in the public namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spotting this. I think it was removed by mistake.

Comment on lines 27 to 28
Example Usage:
...
Copy link
Member

Choose a reason for hiding this comment

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

Either add an example here or preferably remove these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed!


@async_to_sync
class HeasarcClass(BaseVOQuery, BaseQuery):
"""Class for accessing HEASARC data using XAMIN.
Copy link
Member

Choose a reason for hiding this comment

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

what is XAMIN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The VO backend. Changed to clarify

Comment on lines +33 to +35
VO_URL = conf.VO_URL
TAR_URL = conf.TAR_URL
S3_BUCKET = conf.S3_BUCKET
Copy link
Member

Choose a reason for hiding this comment

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

Do we need these here, or the properties could pick them up? (like we do in alma or the other modules that use pyvo based tap?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting that these should not be configurable but rather as fixed variables?

NGC_3783 60902005 174.7571 -37.7385

To query a region around some position, specifying the search radius,
we use `~astropy.units`:
Copy link
Member

Choose a reason for hiding this comment

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

don't refer to the module, but the classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed.


If no radius value is given, a default that is appropriate
for each table is used. You can see the value of the default
radius values by calling `~~astroquery.heasarc.HeasarcClass._get_default_radius`,
Copy link
Member

Choose a reason for hiding this comment

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

This is a private function, don't refer to it in the narrative documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this method can be useful to the user, and that is why it is documented. It was initially public, and changed it to private after the first set of comments. I leaning towards making it public again and then referenced it here.

The list of returned columns can also be given as a comma-separated string to
`~~astroquery.heasarc.HeasarcClass.query_region`:

.. doctest-skip::
Copy link
Member

Choose a reason for hiding this comment

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

Why do we skip this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

>>> from astroquery.heasarc import Heasarc
>>> heasarc = Heasarc()
>>> table = heasarc.query_object(object_name, mission='rosmaster', radius='120 arcmin')
>>> from astroquery.heasarc import Heasac
Copy link
Member

Choose a reason for hiding this comment

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

typo

Suggested change
>>> from astroquery.heasarc import Heasac
>>> from astroquery.heasarc import Heasarc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed here and in other places in the rst document.

or a string that can be parsed into one (e.g., '1 degree' or 1*u.degree). The
following are equivalent:
Multiple keywords that are separated by space are joined with **AND**, so the
following find all tables that have both 'xmm' and 'chandra' keyworkds:
Copy link
Member

Choose a reason for hiding this comment

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

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants