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

Gaia: Define new constant USE_NAMES_OVER_IDS that gives preference to name over ID attributes of columns as the names of columns in the astropy.table.Table instance. #2967

Conversation

cosmoJFH
Copy link

@cosmoJFH cosmoJFH commented Mar 15, 2024

In issue #2911 it was shown that the function Gaia.launch_job returns the upper case column name DESIGNATION.

This came from that fact that IDs are used instead of the names in the votable at the time the astropy.table.Table is built.

Recently, the votables returned by the gaia archive has been updated in order to include the datalink "Service Descriptors", and they contain a few new IDs, where their corresponding values are capitalized. Therefore, this implies that the column names in the astropy.table.Table instances will be changed: they would be shown as uppercase names. This is an example:

>>> job = gaia.launch_job("select top 1 solution_id,source_id,designation from gaiadr3.gaia_source order by source_id")
>>> print(job.get_results())
    solution_id          SOURCE_ID              DESIGNATION         
------------------- ------------------- ----------------------------
1636148068921376768 4111834567779557376 Gaia DR3 4111834567779557376

We need to build astropy tables that contains column names based on the names and not on the IDs.

We have defined a new constant USE_NAMES_OVER_IDS=true in the GaiaClass. Its meaning is the same as in https://docs.astropy.org/en/stable/io/votable/index.html. The changes do not affect those projects that don't need to change the original built of the astropy.table.Table instances where IDs are used instead of names.




In this PR we have also fixed the function search_async_jobs in the class TapPlus. Making use of the present implementation an error is raised when it is used with a filter:

from astroquery.gaia import GaiaClass
>>> import astroquery as astroquery
>>> astroquery.__version__
'0.4.7'

from astroquery.utils.tap.model.filter import Filter

jobfilter = Filter()
jobfilter.limit=10


jobs = gaia.search_async_jobs(jobfilter=jobfilter, verbose=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jfernandez/anaconda3/lib/python3.10/site-packages/astroquery/utils/tap/core.py", line 1337, in search_async_jobs
    data = jobfilter.createUrlRequest()
AttributeError: 'Filter' object has no attribute 'createUrlRequest'



New tests have been made.



cc @esdc-esac-esa-int



Jira: GAIAPCR-1313

@pep8speaks
Copy link

pep8speaks commented Mar 15, 2024

Hello @cosmoJFH! 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 2024-05-01 08:28:06 UTC

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 53.94737% with 70 lines in your changes are missing coverage. Please review.

Project coverage is 66.85%. Comparing base (886817e) to head (c2fb611).
Report is 61 commits behind head on main.

❗ Current head c2fb611 differs from pull request most recent head 65a00ad. Consider uploading reports for the commit 65a00ad to get more accurate results

Files Patch % Lines
astroquery/utils/tap/core.py 46.01% 61 Missing ⚠️
astroquery/gaia/core.py 75.00% 5 Missing ⚠️
astroquery/utils/tap/model/job.py 71.42% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2967      +/-   ##
==========================================
+ Coverage   66.83%   66.85%   +0.02%     
==========================================
  Files         237      237              
  Lines       18327    18304      -23     
==========================================
- Hits        12248    12237      -11     
+ Misses       6079     6067      -12     

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

@cosmoJFH cosmoJFH changed the title Gaia Define new constant USE_NAMES_OVER_IDS that gives preference to name over ID attributes of columns as the names of columns in the astropy.table.Table instance. Gaia: Define new constant USE_NAMES_OVER_IDS that gives preference to name over ID attributes of columns as the names of columns in the astropy.table.Table instance. Mar 15, 2024
@bsipocz bsipocz added the gaia label Mar 18, 2024
@bsipocz bsipocz added this to the v0.4.8 milestone Mar 18, 2024
@hectorcanovas
Copy link
Contributor

Dear Astropy/Astroquery team: From the message above ("Some checks were not successful") we see that there issues to be solved, but we do not understand if we (ESA/ESDC) should take care of them, or if the issues will be fixed by you (Astropy/Astroquery team) - thanks in advance for your answer.

@keflavich
Copy link
Contributor

@hectorcanovas In general, these are items you should deal with if they are related to changes you made. Ideally, you should only see messages related to those.

However, we often have problems that crop up that are related to changes in upstream packages that do not indicate an issue with changes you've made. That applies in this case. The warnings on readthedocs are:

/home/docs/checkouts/readthedocs.org/user_builds/astroquery/envs/2967/lib/python3.10/site-packages/astroquery/alma/core.py:docstring of astroquery.alma.core.AlmaClass.query_sia:25: WARNING: py:obj reference target not found: pyvo.dam.obscore.POLARIZATION_STATES
/home/docs/checkouts/readthedocs.org/user_builds/astroquery/envs/2967/lib/python3.10/site-packages/astroquery/alma/core.py:docstring of astroquery.alma.core.AlmaClass.query_sia:66: WARNING: py:obj reference target not found: pyvo.dam.obscore.CALIBRATION_LEVELS
/home/docs/checkouts/readthedocs.org/user_builds/astroquery/envs/2967/lib/python3.10/site-packages/astroquery/ipac/irsa/core.py:docstring of astroquery.ipac.irsa.core.IrsaClass.query_sia:25: WARNING: py:obj reference target not found: pyvo.dam.obscore.POLARIZATION_STATES
/home/docs/checkouts/readthedocs.org/user_builds/astroquery/envs/2967/lib/python3.10/site-packages/astroquery/ipac/irsa/core.py:docstring of astroquery.ipac.irsa.core.IrsaClass.query_sia:66: WARNING: py:obj reference target not found: pyvo.dam.obscore.CALIBRATION_LEVELS

i.e., none of them are related to changes you made here.

The code coverage, on the other hand, is related to your changes:
https://github.com/astropy/astroquery/pull/2967/checks?check_run_id=22802134007
It shows that you've added several lines that are not covered by any tests. We'd prefer that you write tests to cover this new code, but in some cases (and I haven't reviewed so I'm not sure this is one of them), we decide the tests are too difficult to write or just not worth the effort, and say it's OK to merge anyway.

@keflavich
Copy link
Contributor

Alright, after a quick review, the main changes that codecov is hitting are in TAP, which we aren't too worried about. @bsipocz has final say here, though.

@cosmoJFH
Copy link
Author

cosmoJFH commented Apr 27, 2024

Fixed the conflicts in the file CHANGE.rst. All checks passed.

@bsipocz bsipocz force-pushed the ESA_gaia_read_votables_columns_based_on_names_GAIAPCR-1313 branch from 33e3d32 to 852e621 Compare May 1, 2024 08:27
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 have rebased this to pick up the recently merged changes, and in fact that highlighted a new regression.

I added a quick patch for it, so tests now pass but also see the comment. I'm happy going ahead with the merge as is, or if you want to double check the if all cases are covered in the conditional at the comment.

Comment on lines 64 to 68

elif output_format == 'ecsv':
result = APTable.read(data, format=astropy_format)
else:
result = APTable.read(data, format=astropy_format, use_names_over_ids=use_names_over_ids)
Copy link
Member

Choose a reason for hiding this comment

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

The handling of the ecsv case needed to be added due to the merging of #2983, however this made me wonder whether it's not the votable case that should be handled as special and fall back on not specifying use_names_over_ids to handle fits and ecsv, etc.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @bsipocz for your time reviewing the PR. I agree with you that the parameter use_names_over_ids must be used only for the format votable. We have updated the source code and include more tests in test_xmlparser.py to test this fact.

@bsipocz bsipocz force-pushed the ESA_gaia_read_votables_columns_based_on_names_GAIAPCR-1313 branch from 13c8ba6 to 48f272e Compare May 3, 2024 01:38
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.

All looks good, and I added a fix for the windows int issue and rebased. Merging if all CI jobs come back passing.

@bsipocz bsipocz force-pushed the ESA_gaia_read_votables_columns_based_on_names_GAIAPCR-1313 branch from 48f272e to 6be10bb Compare May 3, 2024 01:45
@bsipocz bsipocz force-pushed the ESA_gaia_read_votables_columns_based_on_names_GAIAPCR-1313 branch from 6be10bb to 65a00ad Compare May 3, 2024 02:01
@bsipocz bsipocz merged commit d77dad2 into astropy:main May 3, 2024
8 checks passed
@bsipocz
Copy link
Member

bsipocz commented May 3, 2024

Thank you @cosmoJFH!

@bsipocz
Copy link
Member

bsipocz commented May 3, 2024

I've pushed a dev version to pypi that includes this fix, so pip install -U --pre astroquery should be able to pick it up.

@cosmoJFH
Copy link
Author

cosmoJFH commented May 3, 2024

Thank you!! We really appreciate 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.

None yet

5 participants