[ome-devel] connecting to omero via python

Josh Moore josh at glencoesoftware.com
Thu Feb 10 07:19:04 GMT 2011


On Feb 9, 2011, at 9:26 PM, Adam Fraser wrote:

>> 
>>      c = blitzcon.c
>>      s = c.sf
>> 
> 
> lol, yup that's pretty much exactly the thing that I was trying to find.
> Will pointed me to the BlitzGateway as well and showed me how to do what I
> wanted with some other tricks. One was to use
> omero.util.script_utils.downloadPlane(RawPixelsStore,
> pixels, z,c,t)
> 
> Given what you just told me I see that I could do this instead:
> blitzcon.c.sf.createGateway().getPlane(pixels_id, z, c, t, _ctx=None)
> 
> Sadly, I have no clue what the difference between the two options is except
> that I don't need to create a RawPixelsStore object in the latter case. Any
> sagely advice for me here?

getPlane is creating a RawPixelStore server-side for you. It will be cleaned
up when you close the Gateway. (Speaking of which, be sure to close any
services which have a close method when you are done with them)

Again, though, this is an issue of our needing to unify our Python API
landscape.

>> But do note that we are in the process of refactoring BlitzGateway to unify
>> its methods with those in Insight so this API should be considered internal for
>> the moment. If you have suggestions, we'd love to hear them.
>> 
> 
> Ah, this came up before but I think I misunderstood and thought the
> reference was to the other omero.gateway thing (session.createGateway()).
> This is definitely very concerning as I don't want to write something that
> becomes instantly useless. Should I do what I was doing before with
> omero.client(...) and client.createSession(...)?
> 
> A few suggestions:
> 
>   - Retain as much backwards compatibility as possible.
>   - If BlitzGateway is the thing that programmers should use for 90% of
>   their needs, then make that obvious in the documentation/wiki somehow.
>   - From my perspective, getting images and image metadata is the most
>   important thing. So the easier (and faster) that is, the happier I am.
> 
> The wiki has been very useful so far, particularly
> omeropy/gateway<http://trac.openmicroscopy.org.uk/omero/wiki/OmeroPy/Gateway>.
> However,
> since I first looked at the
> omeropy<http://trac.openmicroscopy.org.uk/omero/wiki/OmeroPy> page,
> I got the impression that I should be getting at everything from:
>>>> c = omero.client(host)
>>>> s = c.createSession(user, pw)
> So the first thing I did was start digging:
>>>> help(c)
>>>> help(s)
> ...and even now I'm still conflicted as to whether I should just be using
> this as opposed to BlitzGateway, I suppose the decision would be easier if
> BlitzGateway wasn't in a state of flux.
> 
> In the future I'll be wanting to write data back to the database, so I'm
> sure I'll have more comments when I cross that bridge.

Sounds good.

>> Very likely, as soon as the client is inactive for 10 minutes or so. You
>> can
>> start by using the "omero.keep_alive" property
>> 
> 
> I just discovered I that I can get at all the properties through
> blitzcon.c.getPropertyMap(). This is very useful. I don't see a setProperty
> function at that level, but could I do something like this?
> blitzcon.c.getProperties().setProperty('omero.keep_alive', 123456)

Using setProperty wouldn't start a keep alive thread until the next session:

  c.getProperties().setProperty()
  c.closeSession()
  c.createSession()

Since properties are primarily used on session creation and are not polled
regularly.

  c.enableKeepAlive(60)

will start a keep alive thread right away.

> Thanks,
> Adam

Cheers,
~Josh


More information about the ome-devel mailing list