-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
ENH: adding minimalist BaseVOQuery baseclass #2836
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2836 +/- ##
==========================================
+ Coverage 66.49% 66.51% +0.02%
==========================================
Files 235 235
Lines 18081 18096 +15
==========================================
+ Hits 12023 12037 +14
- Misses 6058 6059 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Excellent idea. Glad to see the third VO usage in here. The @bsipocz - there are a few |
Yes, I'm all for adding all other useful VO related functionality to this base class, but first really just wanted to cut out the clutter as e.g. having all the cache-related things there is more confusing than useful. |
As for |
@andamian - So, as I see, the main question here is whether you see any problems with passing the session from the instances onto pyvo rather than defaulting it using a new one. |
I would have to review both |
But that's the same |
Is it? The session auth is set in |
Indeed, I'll need to double-check the inheritance hierarchy then, and add a test for it. The intention was to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I cannot request changes on my own PR 😭
astroquery/query.py
Outdated
""" | ||
def __init__(self): | ||
super().__init__() | ||
self._session = requests.Session() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I suppose putting this into a conditional should be sufficient to address the issue @andamian pointed out.
But it all needs thorough testing.
Maybe It's confusing to have all these sessions flying around- which one is auth, which ones was created externally, etc? So it's nice to have one set in the base class and shared by the implementations. But is that practical? Can one session be shared in a multithread environment (multiple downloads for ex)? It's not very clear whether It would be useful I think to add a factory |
f13444f
to
1482981
Compare
Made this a little bit more robust, and now I believe it's good to go. As for the bigger picture question:
I don't have a good answer for this, but the current inconsistency feels more ad-hoc than on purpose, and definitely not consistent over astroquery or even within pyvo, so if we switch over from having one shared version we need to do it purposefully and as consistently as possible (and preferably we should leave some doc trail about it ;) ) |
else: | ||
user_agents = [f"astroquery/{version.version} pyVO/{pyvo.__version__} " | ||
f"Python/{platform.python_version()} ({platform.system()})"] + user_agents | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not potentially repeating the Python version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially yes, but it's already the case in the current main
, I just made sure that we don't do this if we (==astroquery or pyvo) already modified the user-agent. The one corner case that I haven't covered if the session is somehow made in pyvo, and thus only have the pyvo version listed, but I don't think that will ever be the case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PyVO
might be used to create auth sessions if that is going to be standardized eventually. It already has authsession.AuthSession
although that is a bit outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I see correctly, then authsession.AuthSession doesn't modify the headers. Though yes, I suppose the above logic should better be fixed in case it would modify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit should cover the case when PyVO already modified the user-agent.
Some other tools might have already added the python and platform specifics, too, but I think we should just roll with that and add our own, too, and thus duplicate if that's the case.
Inheriting a lot of unused methods, properties, etc from
BaseQuery
makes little sense for modules that rely fully on pyvo rather than making their own GET/POST queries.This PR also ensures that the session set in the class is being passed onto TAPServcie rather than using a new one from pyvo.
cadc
is basically doing this already, the PR also adds the same approach toalma
,nexsci
andirsa
.To merge this, I would like to see approvals or thumbs-ups from the affected modules:
alma
andnexsci
cc @andamian @rickynilsson