Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #4368 (closed)

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

Python code in one place?

Reported by: wmoore Owned by: wmoore
Priority: major Milestone: OMERO-Beta4.3
Component: OmeroPy Version: n.a.
Keywords: n.a. Cc: cneves, atarkowska, jamoore
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: n.a.
Sprint: n.a.

Description

Currently, Python client developers have a number of options to connect to OMERO and a number of places to look for the functionality they require (E.g. script_utils.py).

Ideally we should provide and document a single method and place to access all functionality, or if this is not best practice then provide documentation on what is best.

E.g.

  • Python scripts get client from scripting service
    client = scripts.client()
    session = client.getSession()
    

Should users create a blitzcon and use that for all future work?

  • Are there any situations when users would NOT want to use blitzcon?
  • Should some script_utils methods be moved to blitz gateway? E.g. downloadPlane()

e-mail below illustrates current confusing situation:

      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?
 
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. However, since I first looked at the 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.
 
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)

Thanks,
Adam

Change History (7)

comment:1 Changed 13 years ago by wmoore

  • Component changed from General to OmeroPy

comment:2 Changed 13 years ago by wmoore

  • Sprint 2011-02-24 (6) deleted

Referencing ticket #4278 has changed sprint.

comment:3 Changed 13 years ago by wmoore

  • Resolution set to fixed
  • Status changed from new to closed

The above functionality is largely covered by other tickets: #4376, #4979, #4237

comment:4 Changed 13 years ago by wmoore

Added method to script_utils (in python-gateway branch) for creating an image from a numpy generator (to be used with the pixelsWrapper.getPlanes() method - like this):

import omero
from omero import client_wrapper
from omero.rtypes import *
from omero.util import script_utils

user = 'root'
pw = 'omero'
host = 'localhost'
imageId = 4197

conn = client_wrapper(user, pw, host=host, port=4064)
conn.connect()

original = conn.getObject("Image", 2)
sizeZ = original.z_count()
sizeC = original.c_count()
sizeT = original.t_count()

newSizeZ = 3
newSizeC = 1
newSizeT = 2

zctList = []
for z in range(newSizeZ):
    for c in range(newSizeC):
        for t in range(newSizeT):
            zctList.append( (z,c,t) )
print zctList

def croppedPlaneGen():
    y = 90
    y2 = 200
    x = 50
    x2 = 320
    planeGen = original.getPrimaryPixels().getPlanes(zctList)
    for p in planeGen:
        yield p[y:y2, x:x2]

serviceFactory = conn.c.sf  # make sure that script_utils creates a NEW rawPixelsStore
i = script_utils.imageFromNumpySeq(serviceFactory, croppedPlaneGen(), "testCropImage", sizeZ=newSizeZ, sizeC=newSizeC, sizeT=newSizeT)

comment:5 Changed 13 years ago by Will Moore <will@…>

(In [f35a8a383cf591f6e8d3724ba8bfa0cd3fe7acef/ome.git] on branch develop) gatewaytest for FileAnnotationWrapper?.fromLocalFile() See #4368

comment:6 Changed 13 years ago by Will Moore <will@…>

(In [bb16cb56c60ed09ebc3eca1aa278ceffec98708f/ome.git] on branch develop) Create imgaeFromNumpySeq() method in script_utils. Move to blitz later? See #4368

comment:7 Changed 13 years ago by Will Moore <will@…>

(In [2ae92885feca1ec310f74959733cf4244a807134/ome.git] on branch develop) Merge branch 'python-gateway' into develop

  • python-gateway: (23 commits) Create imgaeFromNumpySeq() method in script_utils. Move to blitz later? See #4368 Changing all instances of listParents into either getParents or getParent, as appropriate (close #3802) Splitting listParents into 2 new methods; getParents and getParent (see #3802) Getting softclose on BlitzGateway?.seppuku working again (see #3478) gatewaytest of getPlanes() uses zctList argument. See 4979 Blitz pixelWrapper.getPlanes() takes zctList parameter. See 4979 Adding gatewaytest for pixelsWrapper.getPlane(). Closes 4979 Adding getPlane() short-cut to blitz gateway PixelsWrapper?. See 4979 Adding tests for blitz PixelsWrapper?.getPlanes(). See 4979 Adding getPlanes() to blitz gateway PixelsWrapper?. See 4979 Display of exposure times in web metadata panel. Closes #4820 gatewaytest for PixelsWrapper?. See #4820 ImageWrapper?.getPrimaryPixels() returns PixelsWrapper?. See #4820 Adding test for getObject() throws if >1 result. Closes 4908 Blitz getObject() throws exception if >1 result returned. See 4908 Fixing display of tags in web metadata panel. See #4590 Adding gatewaytest for deleteObjects(Annotation,[id]). See 4773 Removing deleteAnnotation() and simpleDelete() from blitz gateway. See 4773 Removing use of deleteProject() deleteDataset() deleteScreen() deletePlate() from webclient. See 4773 Removing deleteScreen() deletePlate() deleteProject() deleteDataset() from blitz gateway. See 4773 ...
Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.75230 sec.)

We're Hiring!