Page 1 of 1

batch delete

PostPosted: Thu Oct 18, 2012 12:46 pm
by frias
Hi!

I played with the DropBox feature and now have 1500 images imported on accident into omero. How can I delete these images which all appear in orphaned category, but the java application crashes when trying to list and delete them. So how can I delete all orphaned images at once, lets say via command line.

Best,

Sebastian

Re: batch delete

PostPosted: Thu Oct 18, 2012 1:13 pm
by wmoore
You could try the webclient.

Orphaned images are visible in the Tree hierarchy, and are paged at 200 images at a time, so you should be able to delete 200 at a time.

If you haven't deployed web yet, you can use the development version directly via instructions: https://www.openmicroscopy.org/site/sup ... ent-server

Re: batch delete

PostPosted: Thu Oct 18, 2012 2:50 pm
by frias
Hi!

I tried the web interface already without too much success. Actually I forgot a zero, so there are 15000 images to get rid of which takes almost 100 web-pages to click through. Does not sound very convenient to me.

Can't omero delete handle this somehow?

Best,

Sebastian

Re: batch delete

PostPosted: Fri Oct 19, 2012 9:33 am
by wmoore
Hi,

I don't know of a command line option to do what you want. We have a 'delete' command but no query for orphan images on the command line.

One option is to use a small python script:

Code: Select all
from omero.gateway import BlitzGateway

conn = BlitzGateway('will', 'password')
conn.connect()

#print conn.getEventContext()   # if you want to know which group etc you'll be deleting images from
qs = conn.getQueryService()

query = "select obj from Image as obj " \
        "where not exists (select obl from DatasetImageLink as obl where obl.child=obj.id) "\
        "and not exists (select ws from WellSample as ws where ws.image=obj.id)"

imageIds = []

for image in qs.findAllByQuery(query, None):
    print "Deleting :", image.getId().getValue(), image.getName().getValue()
    imageIds.append( image.getId().getValue() )

conn.deleteObjects("Image", imageIds)


Edit this with your own username and password, save this as deleteOrphans.py then:

Code: Select all
$ export PYTHONPATH=$PYTHONPATH:/path/to/omero/lib/python
$ python deleteOrphans.py

Re: batch delete

PostPosted: Mon Oct 22, 2012 12:47 pm
by frias
Very cool! I had to fix up some little things, but now it works!

Just one thing: If I request thousands of images to be deleted, the server crashes with memory problems. I now only delete a couple of thousand images, then stop the script and start over. This works fantastic!

Thank you very much!

Sebastian

Re: batch delete

PostPosted: Fri Oct 26, 2012 10:56 am
by jmoore
Could you provide us the server log from the time of the memory problems? That should definitely not be happening, even for 10s of 1000s of images.

Thanks,
~Josh