We're Hiring!

Error linking a file as an annotation

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.

Error linking a file as an annotation

Postby austinMLB » Mon Feb 25, 2019 11:26 pm

Hi, all,
I expect I'm just overlooking something simple on this, but I'm trying to attach a log file to a dataset. This is in a python script. Everything other than the attachment has been working fairly reliably. But, whenever I add the attachment, I start getting an error when I set the output from the script. The code that sets the attachments, my output, and my error the code are below. The "ds" object in the code below later gets set in the "client.setOutput(resName, robject(ds))". Without the "linkAnnotation" line, I don't see any errors. Anything obvious I'm doing wrong here.
(As a side note, thanks for all the previous help. I am trying to clean up my code enough to put it on GitHub, but I'm not there, yet.)
Thanks,
Michael

First the code:
Code: Select all
for f in logs:
        print "Log: "+ f
        f_a = conn.createFileAnnfromLocalFile(f, mimetype="text/plain", ns=omero.constants.namespaces.NSCOMPANIONFILE, desc="Image creation logs")
        print "Attaching annotation " + str(f_a.getId())
        print "Annotation of type " +str(type(f_a))
        for ds in datasets:
            print "Attaching logs to DataSet "+ str(ds.getId())
            print "Dataset of type "+ str(type(ds))
            ds.linkAnnotation(f_a)         


Second the output:
Code: Select all
Log: /media/gsn/omero_test/InPlaceData/deconvolved_image_2019-02-25-17-19-30/logs/deconvolution_batch_2305.stderr
Attaching annotation 35
Annotation of type <class 'omero.gateway.FileAnnotationWrapper'>
Attaching logs to DataSet object #0 (::omero::RLong)
{
    _val = 1175
}
Dataset of type <class 'omero.model.DatasetI'>
The return type is <type 'list'>)

Third the error:
Code: Select all
Traceback (most recent call last):
  File "./script", line 244, in <module>
    run_script()
  File "./script", line 234, in run_script
    client.setOutput(resName, robject(ds))
  File "/home/omero/OMERO.server-5.4.9-ice36-b101/lib/python/omero/clients.py", line 1105, in setOutput
    self._env(False, "setOutput", key, value)
  File "/home/omero/OMERO.server-5.4.9-ice36-b101/lib/python/omero/clients.py", line 1074, in _env
    rv = apply(m, (u,)+args)
  File "/home/omero/OMERO.server-5.4.9-ice36-b101/lib/python/omero_api_ISession_ice.py", line 816, in setOutput
    return _M_omero.api.ISession._op_setOutput.invoke(self, ((sess, key, value), _ctx))
ValueError: invalid value for ::omero::model::DatasetAnnotationLink member `_child'
!! 02/25/19 17:10:55.987 error: communicator not destroyed during global destruction.
austinMLB
 
Posts: 19
Joined: Wed Jul 25, 2018 3:26 pm

Re: Error linking a file as an annotation

Postby wmoore » Tue Feb 26, 2019 12:52 pm

Hi,

Apologies for the confusion between omero.model objects and the Blitz Gateway wrapper objects.
Thanks for the debugging output. It has the solution:

Code: Select all
Dataset of type <class 'omero.model.DatasetI'>


This should be a "DatasetWrapper" class that you can get via

Code: Select all
dataset = conn.getObject("Dataset", ds.id.val)


You'll also need to 'unwrap' the DatasetWrapper when you pass it to robject

Code: Select all
client.setOutput(resName, robject(dataset._obj))


Hope that helps,

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 1 guest