Skip to content

Instantly share code, notes, and snippets.

@will-moore
Last active March 10, 2016 14:31
Show Gist options
  • Save will-moore/33dc5d021a428b161bae to your computer and use it in GitHub Desktop.
Save will-moore/33dc5d021a428b161bae to your computer and use it in GitHub Desktop.

This is how I tested the performance of OMERO.webclient paths_to_object, handling pagination of the object when in a Dataset or Orphaned collection of many images, as described ome/openmicroscopy#4511

First, I added print statements to components/tools/OmeroWeb/omeroweb/webclient/views.py to print the time that paths_to_object takes to return:

+    n = time()
     paths = paths_to_object(conn, experimenter_id, project_id, dataset_id,
                             image_id, screen_id, plate_id, acquisition_id,
                             well_id, group_id)
+    print time() - n

Now, for a given image you can test the speed by visiting

webclient/api/paths_to_object/?image=559

Then I created 10000 orphaned images called "pagination":

$ bin/omero shell --login
In [1]: update = client.sf.getUpdateService()
In [2]: i = omero.model.ImageI()
In [3]: i.name = omero.rtypes.rstring("pagination")
In [4]: update.saveObject(i)
In [5]: for c in range(10000):
   ...:     i = omero.model.ImageI()
   ...:     i.name = omero.rtypes.rstring("pagination")
   ...:     update.saveObject(i)

In webclient I browsed the Orphaned images to pick an image ID and test speed of paths_to_object as above.

Then I created a Dataset in webclient and added all the 'pagination' images to the Dataset with a small script:

import omero
from omero.gateway import BlitzGateway
conn = BlitzGateway("will", "ome", host="localhost", port=4064)
conn.connect()
update = conn.getUpdateService()

for i in conn.getObjects("Image", attributes={'name': 'pagination'}):
    print i.id
    link = omero.model.DatasetImageLinkI()
    link.setParent(omero.model.DatasetI(11731, False))
    link.setChild(omero.model.ImageI(i.id, False))
    try:
        update.saveObject(link)
    except:
        pass

Now I could test the speed of paths_to_objects with the image being in a large Dataset. Then I removed 5000 images from the Dataset with another script:

import omero
from omero.gateway import BlitzGateway
conn = BlitzGateway("will", "ome", host="localhost", port=4064)
conn.connect()

update = conn.getUpdateService()
params = omero.sys.ParametersI()
params.page(0, 1048)
q = "select l from DatasetImageLink as l where l.parent.id=11731"
links = conn.getQueryService().findAllByQuery(q, params)
for l in links:
    print l.id.val
    update.deleteObject(l)

Now I had a Dataset with 5000 images and also 5000 orphaned images, testing paths_to_object speed for both as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment