We're Hiring!

Remove achived files, keep OMERO version

General user discussion about using the OMERO platform to its fullest. Please ask new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Remove achived files, keep OMERO version

Postby a.herbert » Tue Nov 22, 2011 12:45 pm

Hi,

Is there a way to delete the archived original file from an OMERO file?

We have a store of over 2 TB of archived files. If we could delete the archive for unnecessary images then it would significantly reduce disk space requirements.

The alternative of exporting and then reimporting would lose any tags and comments.

Thanks,

Alex
a.herbert
 
Posts: 53
Joined: Tue Jan 11, 2011 1:35 pm

Re: Remove achived files, keep OMERO version

Postby jmoore » Wed Nov 23, 2011 9:22 am

Hi Alex,

there's not a way to do what you're looking for from the UIs. Was a script/command-line tool do what you need?
Code: Select all
import sys
import omero
from omero.rtypes import unwrap

c = omero.client("localhost")
s = c.createSession("root","ome")

args = [long(x) for x in sys.argv[1:]]
if not args:
    print "Nothing to do"
    sys.exit(0)

try:
    q = s.getQueryService()
    d = s.getDeleteService()
    u = s.getUpdateService()

    params = omero.sys.ParametersI()
    params.addIds(args)

    file_ids = unwrap(q.projection("""
        select m.id, parent.id
        from PixelsOriginalFileMap m
        where m.child.image.id in (:ids)
    """, params))

    for link, fid in file_ids:
        print "Handling: link:%s file:%s" % (link, fid)
        u.deleteObject(omero.model.PixelsOriginalFileMapI(link, False)) # See #7300
        print "Deleted link %s" % link

        callback = None
        try:
            cmds = [omero.api.delete.DeleteCommand("/OriginalFile", long(fid), None)]
            handle = d.queueDelete(cmds)
            callback = omero.callbacks.DeleteCallbackI(c, handle)
            report = callback.loop(50, 100)
            errs = handle.errors()
            if errs:
                print "Failed to delete file %s" % fid
                print report
            else:
                print "Deleted file %s" % fid
        finally:
            if callback:
                callback.close()

finally:
    c.closeSession()


Cheers,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Remove achived files, keep OMERO version

Postby jmoore » Wed Nov 23, 2011 10:15 am

A quick follow-up, Alex: Jean-Marie's pointed out that the "archived" flag also needs to be set to False. We'll look into providing a single solution for unlinking and removing the original files, so you may want to hold off on using this script.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Remove achived files, keep OMERO version

Postby a.herbert » Wed Nov 23, 2011 10:28 am

Hi Josh,

I would be happy with a command-line tool. Thanks for the effort. I will wait to see if you can generate a script that will not have unexepected consequences to my DB.

Regards,

Alex
a.herbert
 
Posts: 53
Joined: Tue Jan 11, 2011 1:35 pm


Return to User Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron