API proposal#66
Conversation
|
Can you add this information:
|
There was a problem hiding this comment.
Doing the login on the module will only allow one login per Python interpreter, right?
Whereas doing the login on a class would allow multiple connections.
Do we need multiple logins.
Can you add some words about multiple simultaneous queries?
Wouldn't it be useful to be able to run queries in parallel?
If so, can you give an API example?
There was a problem hiding this comment.
I considered the multiple logins issue. Yes, there could be use cases for that... we could do a class-based approach, or have that as a
"special case". In general, I don't think multiple logins should be a common use case.
Multiple simultaneous queries is possible... I think even implemented within UKIDSS. It can serve as a workaround to bandwidth limits imposed by servers. However, I think we should hide that functionality if we add it, since the servers probably have those per-process limits in place for a reason.
|
I need to dig out my notes on astropy.surveys from the coordination meeting - there was a preliminary API discussion about this (including asynchronous access). |
|
To clarify, I'm thinking that each tool will have classes for querying, but by default the user will only be exposed to instances of the classes. i.e.: But if a user wanted multiple parallel queries with different parameters for whatever reason, they could do: |
|
@keflavich How about a function Also see @eteq's comments on module organization: Basically astroquery does it wrong everywhere at the moment, i.e. it has Maybe we can do all the renaming now? |
|
Argh, yes, we should probably do all the As for class vs. function, though - I wanted classes so that we could associate function-specific things (i.e., request URL, regexp for extracting links) with the "function" that would be using them. It allows for more flexibility in the future. Also, as shown in this PR, we can have a parent class with a |
|
In your example Consider this: and this: i.e. you can't make a query class return results like tables or images or filenames or ... That's why I proposed to use a function instead of a class. |
|
It would be more like the latter: is my intent: the class instances would be declared in the files. The real point is basically to have functions, but functions which can do this: Of course, the same functionality could be achieved with keyword arguments: which might be preferable; arguments either way? |
|
If I understand correctly in your example above you meant instead of I think I don't like that I'm not sure what class API, I think the choices are:
But I think that every query should have a function wrapper which basically does: or @keflavich I think it would help if you write down your preferred solution in the API document and then illustrate it with a simple and complex example (login, multiple parallel queries). |
|
@cdeil I like your ideas; why not separate the wrapper function from the class? However, I also think |
|
A question: is the intent to allow some sort of "magic" coordinates parsing when you need to give coordinates? Or will it always be a |
|
I am strongly in favor of "magic" for the wrapper functions: as an end But rather: However, the classes should probably require a The real trouble with requiring a Coordinate object at any stage, though, @eteq, can you identify reasons to require a |
|
Ahh, In the name case, I definitely agree. I was thinking of the case of I more middling case is |
|
This is a good point... I think for systems where there's a possibility that the remote server would try to parse an ambiguous coordinate like I think it would be best to allow any service to take that would ignore the |
|
Yes, the plan is now to support something just like that (@keflavich's approach above using More generally, I'm rather worried about having So if you really think there are some problems with how Also, 👍 on the
|
|
I'm disappointed that github doesn't support the What you're saying all makes sense. It does mean that a minimal session must be I guess that's not really a problem. I can't really justify it except by laziness, but I would really like a |
|
Yeah, I tried It's certainly possible to revisit this topic later, because the |
There was a problem hiding this comment.
Is the login cookie stored at the sub-module level? Or should we consider representing each service by a class, which would also allow some sub-classing of common functionality to all services or similar types of services?
There was a problem hiding this comment.
Ah I see below that the functions are just provided as a convenience, but that the main functionality is in the modules.
|
Related to my comment above, one can make a method behave like both a static or an instance method: which means the user can do: for simple queries, or if e.g. log-in is required. This then avoids the need to duplicate all methods as wrapper functions. (one can do something similar with class vs instance methods if the class is needed) |
|
👍 that is a clever approach; I like it. |
|
👍 from me on @astrofrog's idea, too. It should be mentioned in the docs pretty clearly what's going on here, though (in a "note" or other offset section). I would imagine a fair number of novices will be using |
…pi_proposal Conflicts: docs/astroquery/api.rst
|
Related to the possibility of using these mixed static/instance methods, what do you think about not having the user worry about the sub-packages, i.e. since each sub-package defines a single class, one could just do: of course the code can still live in astroquery, but what do you think about the idea of importing the classes to the top-level? This needs to be finalized before GSoC kicks off, so shall we plan a 1hr telecon to finalize this? |
|
|
There is one tricky bit if you try to use the "class or instance" approach: if you treat it as a classmethod, the I think this is somewhat unclear in the current document: the current API, as suggested, will have a unique class instance for each query. This differs from most of the current implementations, which build the queries as HTTP post objects in the various This approach still allows top-level imports, but (using @astrofrog's previous example) |
|
Merging this so that it gets built on rtfd. Discussion can continue here, but after the telecon we'll have a new PR. Also, I'd like people to be able to implement suggested changes as PRs onto master. |
A place to discuss a proposed uniform API. Please join in the conversation. It's barebones as of this commit, but we'll bulk it up as the conversation progresses.
@cdeil, @astrofrog - you'll probably both be interested in this.