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

Fix bug #543 #599

Merged
merged 4 commits into from
Sep 26, 2024
Merged

Fix bug #543 #599

merged 4 commits into from
Sep 26, 2024

Conversation

msdemlei
Copy link
Contributor

Upfront for the record, there is a possible API change here: iter_datalink would have returned [None] rather than [] when it did not find datalink-returnable things. But this seems (a) insane and (b) it couldn't happen because pyVO would crash before it did this.

Having said that, this is a (possible) fix for bug #543. The code in (2) in the bug now runs but yields no datalinks; that is the correct behaviour in this case because the media type is not datalink's.

There is in addition quite a bit of new heuristics in here to recognise possible pairs of product urls and media types. I'm afraid these kinds of heuristics are the best we can do.

Also in here are testing utilities, which currently are undocumented; I'd first like to see whether they are actually useful. Their purpose is to make it as simple as possible to produce DALResult-s for tests, which should allow to reduce the amount of test data in our repo.

@msdemlei msdemlei force-pushed the fix-bug-543 branch 4 times, most recently from 9c4b61a to 3218a09 Compare September 17, 2024 11:35
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 94.87179% with 4 lines in your changes missing coverage. Please review.

Project coverage is 81.68%. Comparing base (aad09be) to head (0fcf7e7).
Report is 125 commits behind head on main.

Files with missing lines Patch % Lines
pyvo/dal/adhoc.py 96.49% 2 Missing ⚠️
pyvo/utils/testing.py 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #599      +/-   ##
==========================================
+ Coverage   81.62%   81.68%   +0.06%     
==========================================
  Files          69       69              
  Lines        7103     7089      -14     
==========================================
- Hits         5798     5791       -7     
+ Misses       1305     1298       -7     

☔ 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 can confirm that this indeed fixes the exception raised in #543; and the PR looks good to me, however I'm not fully confident that I know enough about datalinks to catch any nuances.

My only comments are whether the new methods could be private so would not populate as prominently the user API.

👍 on the testing utilities.

@@ -169,6 +169,109 @@ class DatalinkResultsMixin(AdhocServiceResultsMixin):
"""
Mixin for datalink functionallity for results classes.
"""
def iter_datalinks_from_dlblock(self, datalink_service):
Copy link
Member

Choose a reason for hiding this comment

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

I would think both of these new methods could be prepended with _, unless you envision them to be used by the end users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. While I see the merits of invoking only this method (the other one seems more adhoc - hence the best efforts that are needed here), for the regular user it's just an implementation detail and it shouldn't crop up into the API.

@bsipocz
Copy link
Member

bsipocz commented Sep 24, 2024

@andamian - could you please have a quick look at this?

@andamian
Copy link
Contributor

This looks good to me. I'm not sure about the usefulness of utype and ucd heuristics since the field names are defined in ObsCore but I guess it leaves the door open for future data formats to use different names.
I like the proposed test utils.

So far, it contains helper methods to halfway conventiently create
VOTables and DALResults.
To do that, we split the original iter_datalinks in the two cases; one
where the datalinks come from a table via a datalink meta RESOURCE, and the
other where we believe there's datalink products in the table.

In the second case (the one that was broken before), we try the name access_format as attribute and column name, and then a utype and two UCDs
(generic and SIA1) each.  We could add SSAP UCDs, but I'll only do that
if someone is asking for it.
This also now compares utypes case-insensitively in getbyutype as
required by the SSAP standard.

All this is ugly VO legacy, but I am rather confident that one of these
days we will be glad we have these heuristics in.
@msdemlei
Copy link
Contributor Author

msdemlei commented Sep 25, 2024 via email

@msdemlei
Copy link
Contributor Author

msdemlei commented Sep 25, 2024 via email

@andamian
Copy link
Contributor

Aha. It makes sense now. However I wasn't able to track down all those UTYPEs and UCDs. It looks like SIAv1 refers to UCDs (the VOX... ones). Where do "obscore:access.format" and "obscore:access.reference" come from? I also couldn't find any reference of "meta.code.mime" but maybe they are specified in other documents. But it looks good otherwise.

@msdemlei
Copy link
Contributor Author

msdemlei commented Sep 26, 2024 via email

@andamian andamian merged commit 4e86bf3 into astropy:main Sep 26, 2024
13 checks passed
@andamian
Copy link
Contributor

Thank you for the contribution @msdemlei

@bsipocz bsipocz modified the milestones: v1.6, v1.5.3 Oct 14, 2024
bsipocz pushed a commit that referenced this pull request Oct 15, 2024
bsipocz pushed a commit that referenced this pull request Oct 15, 2024
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