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
Implement high-level table and image SAMP routines #1920
Conversation
Yes, that would be really good! Instead of new methods could we re-use |
@taldcroft - this is another option, though I'm not sure if the current infrastructure would support it since I think we may have assumed there is always at least one argument passed. I'll look into it. |
@taldcroft - for information, I just made this into a pull request. See the new 'Getting started' section here: http://astrofrog-debug.readthedocs.org/en/latest/vo/samp/index.html The NDData functionality is incomplete since it relies on having FITS readers/writers for NDData (which are not yet implemented but which I just implemented in #2063. This is just an idea so far, and I'm open to suggestions if you think there is a better way to do this. |
I am not familiar with SAMP but this looks pretty neat! |
:func:`~astropy.vo.samp.high_level.send` and | ||
:func:`~astropy.vo.samp.high_level.receive` functions in | ||
`astropy.vo.samp`, but the following sections describe in detail how | ||
to do with using the various classes from the object-oriented API. |
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.
I think the content of the note needs to begin on the next line and be intended. This looks funny in the generated output.
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.
Fixed
…', 'aladin', and 'topcat' destinations.
…ctionary. Added new 'Getting started' section for documentation.
astropy/vo/samp/high_level.py
Outdated
while not (hasattr(object, 'received') and object.received): | ||
time.sleep(step) | ||
if timeout is not None and time.time() - start_time > timeout: | ||
raise AttributeError("Timeout while waiting for message to be received") |
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.
I see how this is waiting on a received
attribute to show up, but raising an AttributeError
here wouldn't be appropriate either. It should maybe be some type of IOError
or other EnvironmentError
subtype.
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.
Maybe a TimeoutError
?
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.
Fixed
This looks pretty neat... I'm not clear on the limits of this, though: can I use this to do many various things with e.g., DS9, along the lines of what XPA allows? Or only sending images? |
@eteq - this is for sending data objects, specifically tables and images. I haven't explored everything that SAMP allows yet, so I'm not sure how much more interaction can be done via SAMP. |
SAMP is a general purpose RPC mechanism, so what you can do depends on the RPC calls ("MTypes" in SAMP terminology) exposed by individual clients. There is a shortish list of the most commonly-used MTypes at http://wiki.ivoa.net/twiki/bin/view/IVOA/SampMTypes; this PR uses a couple of those to make it very easy to do a couple of commonly required things (send table and image). Using the lower level SAMP API you can do whatever clients allow. In the case of ds9, yes this does let you do all the things you can do from XPA, using the custom
to select the "Heat" colour map. This is documented in the ds9 manual. With that in mind - although this new functionality is very nice for doing what it does, it might be nice to add a short note in the documentation indicating that SAMP can do more things than send/receive tables and images. The current description looks a bit like sending tables and images is what it's for, and you can either do it the easy way or the masochistic way. If you'd like me to draft or review a comment to that effect I can do. |
@mbtaylor - if you could write a small paragraph that I can insert at the start of the documentation, that would be great! |
Here is a stab at a paragraph giving some wider context (though it might make more after the send/receive documentation rather than before it):
The actual URL for the MType list is currently http://wiki.ivoa.net/twiki/bin/view/IVOA/SampMTypes; I've given a URL one level up from there in this text because it's shorter, and it should be permanent, while the wiki one is subject to change if the wiki hosting arrangements change. Also: In the section "Using a SAMP client to communicate with other clients" the details of the arguments you have to supply look a bit like magic. To explain where this all comes from, it might be a good idea to provide pointers to two things:
|
I tried sending an image from ds9 and got the following. It was a slice from a data cube, not sure if that matters.
|
@keflavich - ah yes, this is due to the fact I'm relying on an NDData reader to be present :) (see #2063). Receiving tables should work though, and I can always modify the code here to just use |
@keflavich - try again, it should work now! |
@mbtaylor - thanks! I've added the text you suggested and some extra details about MTypes in the 'communicating with other clients' section. |
@taldcroft - just pinging you in case you hadn't seen this yet since maybe you would be interested in this from the @keflavich - can you confirm that it all works now? Any other comments or objections to merging? |
@taldcroft @mbtaylor @astrofrog : I'm fine with requiring the destination be specified, or with using the So I'm fine with forcing users to specify a destination, as I don't think it'll be a shock to a user that they have to tell their interface somewhere that they're connecting to ds9. But anything that includes non-inuitive bits like I agree this isn't something to be done in general, if there's not a standard, but I think it's fair to include some convenience functionality for something like ds9 which is sort of a defacto standard because of how many people use it. |
@eteq - I didn't mean to imply the destination is always required, just that it shouldn't be auto-inferred. If not supplied then the message will be broadcast for any listeners of that MType. In general I would think users would be comfortable with providing a destination like I completely agree that this high-level interface should shield the user from the details of SAMP. At the same time I think it would be good if it actually has the flexibility to allow taking full advantage of documented SAMP interfaces like http://ds9.si.edu/doc/ref/samp.html. That's why I like the suggestion of putting in some logic internally to do the connections and decide between notify vs. call_and_wait. At first glance that seems like it would require some hardwiring, e.g. to know that |
Just to add to what's been said already - this is a proposed high-level API, but all the basic OO API for SAMP will still be there. So it's just a matter of making the documentation clear so both impatient users and developers can make use of what they need. I'm +1 on @mbtaylor's idea of:
and then I'm also wondering whether we should consider switching |
@astrofrog's suggestion seems good to me - I agree that having both So @taldcroft, was your suggestion of logic to decide between notify vs. call_and_wait a suggestion you want to incorporate inside |
By the way, we can also work on simplifying the lower-level API to make it more accessible to users. For example, you could imagine:
If that worked, maybe a higher-level API wouldn't be needed there? It would also avoid repeated connect/disconnect. I still like EDIT: although the 'nice' way of specifying the destination doesn't exist in the lower API. |
I meant as part of But looking more closely at MessageSender I think I now understand the original suggestion better. The
|
I'll try to address some of the points mentioned in the last few messages. Unpythonic methods: Specifying whether a response is required or not: Instead of (variation on) my original suggestion of
an alternative would be to indicate the difference with different method names. Following the usual SAMP terminology (optional) you could instead have:
Note also that "response" here covers error conditions as well as return values. If you use the notify delivery pattern, you have no way of knowing what, if anything, happened at the other end. If you use call, you get (apart from any other return value payload) a status response indicating whether the receiving client processed the message successfully. It would make sense for a medium- or high-level python method to present error responses by raising exceptions (and indicate success by not raising an exception). "Nice" way of specifying the destination: If you want to specify a target client by name ("ds9") rather than by opaque client ID ("cli#4") you have to do more than rearrange the arguments. Essentially it's necessary to query the hub for the available clients and their metadata and examine each
If you are sending multiple messages to the same recipient, you then don't need to do the ID determination multiple times. Note the |
BTW the source code for MessageSender might help with understanding the logic and how to implement it: https://github.com/mbtaylor/jsamp/blob/master/src/java/org/astrogrid/samp/test/MessageSender.java. |
This allows external clients to get a URL for one of the tables currently loaded into topcat. This functionality was suggested by @taldcroft in the discussion astropy/astropy#1920. The MType (table.get.stil) resembles the existing table.load.stil. Possibly there should be a table.get.votable etc, but that should probably be decided with consultation from the SAMP community. The machinery is present to add those - it would be a one-liner.
This requires some more work, so I'm going to re-schedule for 1.0 |
This allows external clients to get a URL for one of the tables currently loaded into topcat. This functionality was suggested by @taldcroft in the discussion astropy/astropy#1920. The MType (table.get.stil) resembles the existing table.load.stil. Possibly there should be a table.get.votable etc, but that should probably be decided with consultation from the SAMP community. The machinery is present to add those - it would be a one-liner.
Removing milestone since I haven't had time to work on it for 1.0. |
This is conflicts galore now. Should we close this? |
Hi humans 👋 - this pull request hasn't had any new commits for approximately 3 years. I plan to close this in a month if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please close this and open an issue instead to revisit in the future. Maintainers may also choose to add If you believe I commented on this issue incorrectly, please report this here. |
⏰ Time's up! ⏰ I'm going to close this pull request as per my previous message. If you think what is being added/fixed here is still important, please remember to open an issue to keep track of it. Thanks! If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here. |
Once #1907 is merged, it would be worth writing simple functions that can take a filename, a
Table
, or anNDData
object and send them over SAMP (optionally to a specific client).@taldcroft - one idea I had would be to add two methods to Table:
would make the table appear e.g. in TOPCAT or DS9, and:
would be a class method that would 'hang' until a table is received via SAMP. The same could be done for NDData.
cc @cdeil @keflavich