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

Adding support for DALI example continuation properties. #483

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

msdemlei
Copy link
Contributor

While this is a DALI feature, for now we only support examples in TAP, so that's where where this happens.

Supporting continuations is desirable now that TOPCAT shows them, too.

This thing makes we wonder whether the way we're exposing examples is
actually useful -- these TAPQuery objects are, I think, fairly unwieldy;
how are users expect to deal with them?

Frankly, I wonder whether we shouldn't simply have a method open_examples
that would simple do a webbrowser.open for the examples URI.

If we want to parse them out, I'd say we should have a way to expose the documentation, too, and perhaps somehow reflect the hierarchical structure of the continuations; I think TOPCAT does this fairly nicely (point a recent TOPCAT at http://dc.g-vo.org/tap); but again, perhaps there's very little utility parsing examples for interactive use in the first place.

@msdemlei msdemlei force-pushed the support-continuation-examples branch from 18f74ab to 89e04c4 Compare August 28, 2023 14:27
@bsipocz bsipocz added this to the v1.5 milestone Aug 28, 2023
@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Merging #483 (89e04c4) into main (6405cb4) will decrease coverage by 0.08%.
The diff coverage is 70.00%.

❗ Current head 89e04c4 differs from pull request most recent head ac1366f. Consider uploading reports for the commit ac1366f to get more accurate results

@@            Coverage Diff             @@
##             main     #483      +/-   ##
==========================================
- Coverage   80.07%   80.00%   -0.08%     
==========================================
  Files          52       52              
  Lines        6059     6042      -17     
==========================================
- Hits         4852     4834      -18     
- Misses       1207     1208       +1     
Files Coverage Δ
pyvo/dal/tap.py 73.44% <70.00%> (+0.21%) ⬆️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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 a few very generic comments, and I do apologise about them as they don't really comment on new code, but were there forever and the lines just got moved around in this diff.

As for actual behaviour about examples, I don't have strong opinions either and would refer it to be decided by the others. However I suppose that could be done independently of this PR.

pyvo/dal/tap.py Outdated
@@ -149,6 +149,38 @@ def tables(self):
vosi.parse_tables(response.raw.read), tables_url)
return self._tables

def _parse_examples(self, examples_uri, /, depth=0):
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 you make examples_uri positional only? I don't see any downside in spelling out argument names, and in cases of optional kwargs I in fact prefer them to be always spelt out.

pyvo/dal/tap.py Outdated
"""returns the TAP queries from a DALI examples URI.
"""
if depth > 5:
raise Exception("Suspecting endless recursion when"
Copy link
Member

Choose a reason for hiding this comment

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

Please us a more specific Exception. Is this e.g. a ValueError, or maybe just a warning?

root = xml.etree.ElementTree.parse(
io.BytesIO(response.content)).getroot()
exampleElements = root.findall('.//*[@property="query"]')
except Exception as ex:
Copy link
Member

Choose a reason for hiding this comment

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

can we be more specific about what exceptions we expect?

@msdemlei
Copy link
Contributor Author

msdemlei commented Aug 30, 2023 via email

While this is a DALI feature, for now we only support examples in TAP,
so that's where where this happens.

Supporting continuations is desirable now that TOPCAT shows them, too.
@msdemlei msdemlei force-pushed the support-continuation-examples branch from eedaab0 to ac1366f Compare October 18, 2023 11:35
@bsipocz
Copy link
Member

bsipocz commented Oct 18, 2023

The devtest failure is unrelated and has been fixed in main already.

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.

This looks all right to me, but would prefer to have someone knowing more about TAP examples leave an approval, too.

@zoghbi-a
Copy link
Contributor

zoghbi-a commented Oct 18, 2023

I had a quick look at this PR. I think this is useful.
As a user, I often find myself trying to find examples to use.

I wonder if it is more useful to return some description (from property="name" for instance) and the query as a text rather than a TAPQuery. I find this more useful because:
1- The user rarely wants to use the exact query, and more often they want to modify it before submitting it.
2- Some examples will fail anyway if they require uploads for instance.

I think this will be more consistent with the way TOPCAT does it, where you see a description (from property=name) and when selected, it just give you the query text so you can edit it.

@msdemlei
Copy link
Contributor Author

msdemlei commented Oct 19, 2023 via email

Copy link
Contributor

@tomdonaldson tomdonaldson left a comment

Choose a reason for hiding this comment

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

This seems like a nice improvement to me. As mentioned in the discussion, there are other improvements possible, but I'm satisfied to have those addressed in future PRs.

@andamian
Copy link
Contributor

All the comments are good points worth considering but this PR fills a gap in the existing functionality so it's a good addition.

@bsipocz
Copy link
Member

bsipocz commented Oct 19, 2023

With the approach of not letting the perfect be the enemy of the good, I go ahead and merge this, and welcome follow-up PRs with further improvements.

@bsipocz bsipocz merged commit d564bc4 into astropy:main Oct 19, 2023
9 of 10 checks passed
@bsipocz
Copy link
Member

bsipocz commented Oct 19, 2023

Thank you @msdemlei!

@msdemlei msdemlei deleted the support-continuation-examples branch December 5, 2023 08:02
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