Remove achived files, keep OMERO version
Posted:
Tue Nov 22, 2011 12:45 pm
by a.herbert
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
Re: Remove achived files, keep OMERO version
Posted:
Wed Nov 23, 2011 9:22 am
by jmoore
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.
Re: Remove achived files, keep OMERO version
Posted:
Wed Nov 23, 2011 10:15 am
by jmoore
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.
Re: Remove achived files, keep OMERO version
Posted:
Wed Nov 23, 2011 10:28 am
by a.herbert
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