Hi,
This is quite common behavior.
All the 'Figure' scripts E.g. 'Thumbnail Figure' save their output as attachments to E.g Image or Dataset.
In fact, you can do it with a single call: scriptUtil.uploadAndAttachFile(), documented here
http://hudson.openmicroscopy.org.uk/job ... AttachFileBelow is some sample code from Thumbnail Figure script. See
http://trac.openmicroscopy.org.uk/omero ... _Figure.py- Code: Select all
import omero.util.script_utils as scriptUtil
format = "image/png"
parent = gateway.getDataset(Id, False) # parent can be omero.model.ImageI or DatasetI or ProjectI
output = "thumbnailFigure.png"
figure.save(output, "PNG") # simply writes to a file in the current directory
# uploads the file to the server, attaching it to the 'parent' Project/Dataset as an OriginalFile annotation,
# with the figLegend as the description. Returns the fileAnnotation object
fileAnnotation = scriptUtil.uploadAndAttachFile(queryService, updateService, rawFileStore, parent, output, format, figLegend)
client.setOutput("File_Annotation", robject(fileAnnotation))
If you want to be able to identify the file uniquely E.g. from your second script, you could give the file a meaningful namespace. E.g. 'omero.constants.metadata.NSMOVIE' (see the method docs above).
To download the file again, you can use the downloadFile(), also from the script_utils package.
http://hudson.openmicroscopy.org.uk/job ... wnloadFileBut you first need to retrieve your file - probably using the queryservice.
I just cobbled together this example, so I'm not sure it works - but hopefully you should be able to work the rest out for yourself.
- Code: Select all
dal = queryService.findByQuery("select dal from DatasetAnnotationLink as dal " \
"join fetch dal.child as fileAnn " \
"join dal.parent as dataset " \
"where dataset.id = %s and " \
"fileAnn.ns = %s" % (datasetId, yourNameSpace) , None)
originalFile = dal.child.file
for file in dataset.
filePath = scriptUtil.downloadFile(rawFileStore, originalFile)
print "Saved file at:", filePath
f = open(filePath)
Hope that helps,
Will