Page 1 of 1

Create WellSample in Python throws error

PostPosted: Wed Mar 06, 2019 1:47 pm
by andersla
I have created a Screen, Plate, Well and Image OK.

Trying to create a WellSample and linking it to the Image and Well throws error (below)

Code: Select all
def createWellSample(wellID, imageID):
  conn = getOmeroConn()
  wellSample = omero.model.WellSampleI()
 
  image = conn.getObject("Image", imageID)
  wellSample.setImage(omero.model.ImageI(imageID, False))
 
  well = conn.getObject("Well", wellID)
  wellSample.setWell(omero.model.WellI(well.getId(), False))

  wellSample = conn.getUpdateService().saveAndReturnObject(wellSample)
  obj_id = wellSample.id.getValue()
  conn.close()
  return obj_id


The error is:

13:42:21,798 WARNING [__init__.py:4654] InternalException on <class 'omero.gateway.OmeroGatewaySafeCallWrapper'> to <fb9310e5-5061-4cf2-8ccd-4311e1da563fomero.api.IUpdate> saveAndReturnObject((object #0 (::omero::model::WellSample)
{
_id = <nil>
_details = object #1 (::omero::model::Details)
{
_owner = <nil>
_group = <nil>
_creationEvent = <nil>
_updateEvent = <nil>
_permissions = <nil>
_externalInfo = <nil>
_call = {}
_event = <nil>
}
_loaded = True
_version = <nil>
_posX = <nil>
_posY = <nil>
_timepoint = <nil>
_plateAcquisition = <nil>
_well = object #2 (::omero::model::Well)
{
_id = object #3 (::omero::RLong)
{
_val = 1
}
_details = <nil>
_loaded = False
_version = <nil>
_status = <nil>
_column = <nil>
_row = <nil>
_red = <nil>
_green = <nil>
_blue = <nil>
_alpha = <nil>
_reagentLinksSeq = {}
_reagentLinksLoaded = False
_reagentLinksCountPerOwner = {}
_externalDescription = <nil>
_externalIdentifier = <nil>
_type = <nil>
_wellSamplesSeq = {}
_wellSamplesLoaded = False
_plate = <nil>
_annotationLinksSeq = {}
_annotationLinksLoaded = False
_annotationLinksCountPerOwner = {}
}
_image = object #4 (::omero::model::Image)
{
_id = object #5 (::omero::RLong)
{
_val = 1
}
_details = <nil>
_loaded = False
_version = <nil>
_series = <nil>
_acquisitionDate = <nil>
_archived = <nil>
_partial = <nil>
_format = <nil>
_imagingEnvironment = <nil>
_objectiveSettings = <nil>
_instrument = <nil>
_stageLabel = <nil>
_experiment = <nil>
_pixelsSeq = {}
_pixelsLoaded = False
_wellSamplesSeq = {}
_wellSamplesLoaded = False
_roisSeq = {}
_roisLoaded = False
_datasetLinksSeq = {}
_datasetLinksLoaded = False
_datasetLinksCountPerOwner = {}
_folderLinksSeq = {}
_folderLinksLoaded = False
_folderLinksCountPerOwner = {}
_fileset = <nil>
_annotationLinksSeq = {}
_annotationLinksLoaded = False
_annotationLinksCountPerOwner = {}
_name = <nil>
_description = <nil>
}
},), {})
Traceback (most recent call last):
File "/opt/omero/server/OMERO.server/lib/python/omero/gateway/__init__.py", line 4672, in __call__
return self.f(*args, **kwargs)
File "/opt/omero/server/OMERO.server/lib/python/omero_api_IUpdate_ice.py", line 163, in saveAndReturnObject
return _M_omero.api.IUpdate._op_saveAndReturnObject.invoke(self, ((obj, ), _ctx))
InternalException: exception ::omero::InternalException
{
serverStackTrace = ome.conditions.InternalException: Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException):
Exception occurred inside getter of ome.model.screen.Well.wellSamples; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of ome.model.screen.Well.wellSamples
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:117)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at ome.tools.hibernate.ProxyCleanupFilter$Interceptor.invoke(ProxyCleanupFilter.java:249)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at ome.services.util.ServiceHandler.invoke(ServiceHandler.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy89.saveAndReturnObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor579.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at ome.security.basic.BasicSecurityWiring.invoke(BasicSecurityWiring.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at ome.services.blitz.fire.AopContextInitializer.invoke(AopContextInitializer.java:43)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy89.saveAndReturnObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor600.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ome.services.blitz.util.IceMethodInvoker.invoke(IceMethodInvoker.java:172)
at ome.services.throttling.Callback.run(Callback.java:56)
at ome.services.throttling.InThreadThrottlingStrategy.callInvokerOnRawArgs(InThreadThrottlingStrategy.java:56)
at ome.services.blitz.impl.AbstractAmdServant.callInvokerOnRawArgs(AbstractAmdServant.java:140)
at ome.services.blitz.impl.UpdateI.saveAndReturnObject_async(UpdateI.java:62)
at sun.reflect.GeneratedMethodAccessor599.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at omero.cmd.CallContext.invoke(CallContext.java:78)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy90.saveAndReturnObject_async(Unknown Source)
at omero.api._IUpdateTie.saveAndReturnObject_async(_IUpdateTie.java:92)
at omero.api._IUpdateDisp.___saveAndReturnObject(_IUpdateDisp.java:227)
at omero.api._IUpdateDisp.__dispatch(_IUpdateDisp.java:422)
at IceInternal.Incoming.invoke(Incoming.java:221)
at Ice.ConnectionI.invokeAll(ConnectionI.java:2536)
at Ice.ConnectionI.dispatch(ConnectionI.java:1145)
at Ice.ConnectionI.message(ConnectionI.java:1056)
at IceInternal.ThreadPool.run(ThreadPool.java:395)
at IceInternal.ThreadPool.access$300(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:832)
at java.lang.Thread.run(Thread.java:748)

serverExceptionClass = ome.conditions.InternalException
message = Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException):
Exception occurred inside getter of ome.model.screen.Well.wellSamples; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of ome.model.screen.Well.wellSamples
}
13:42:21,799 INFO [import-cli-version3.py:404] Done script
Traceback (most recent call last):
File "/scripts/import-cli-version3.py", line 400, in <module>
uploadImageUnique(filepath)
File "/scripts/import-cli-version3.py", line 370, in uploadImageUnique
wellSampleID = createWellSample(wellID, imageID)
File "/scripts/import-cli-version3.py", line 246, in createWellSample
wellSample = conn.getUpdateService().saveAndReturnObject(wellSample)
File "/opt/omero/server/OMERO.server/lib/python/omero/gateway/__init__.py", line 4675, in __call__
return self.handle_exception(e, *args, **kwargs)
File "/opt/omero/server/OMERO.server/lib/python/omero/gateway/__init__.py", line 4672, in __call__
return self.f(*args, **kwargs)
File "/opt/omero/server/OMERO.server/lib/python/omero_api_IUpdate_ice.py", line 163, in saveAndReturnObject
return _M_omero.api.IUpdate._op_saveAndReturnObject.invoke(self, ((obj, ), _ctx))
omero.InternalException: exception ::omero::InternalException
{
serverStackTrace = ome.conditions.InternalException: Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException):
Exception occurred inside getter of ome.model.screen.Well.wellSamples; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of ome.model.screen.Well.wellSamples
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:117)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at ome.tools.hibernate.ProxyCleanupFilter$Interceptor.invoke(ProxyCleanupFilter.java:249)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at ome.services.util.ServiceHandler.invoke(ServiceHandler.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy89.saveAndReturnObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor579.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at ome.security.basic.BasicSecurityWiring.invoke(BasicSecurityWiring.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at ome.services.blitz.fire.AopContextInitializer.invoke(AopContextInitializer.java:43)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy89.saveAndReturnObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor600.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ome.services.blitz.util.IceMethodInvoker.invoke(IceMethodInvoker.java:172)
at ome.services.throttling.Callback.run(Callback.java:56)
at ome.services.throttling.InThreadThrottlingStrategy.callInvokerOnRawArgs(InThreadThrottlingStrategy.java:56)
at ome.services.blitz.impl.AbstractAmdServant.callInvokerOnRawArgs(AbstractAmdServant.java:140)
at ome.services.blitz.impl.UpdateI.saveAndReturnObject_async(UpdateI.java:62)
at sun.reflect.GeneratedMethodAccessor599.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at omero.cmd.CallContext.invoke(CallContext.java:78)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy90.saveAndReturnObject_async(Unknown Source)
at omero.api._IUpdateTie.saveAndReturnObject_async(_IUpdateTie.java:92)
at omero.api._IUpdateDisp.___saveAndReturnObject(_IUpdateDisp.java:227)
at omero.api._IUpdateDisp.__dispatch(_IUpdateDisp.java:422)
at IceInternal.Incoming.invoke(Incoming.java:221)
at Ice.ConnectionI.invokeAll(ConnectionI.java:2536)
at Ice.ConnectionI.dispatch(ConnectionI.java:1145)
at Ice.ConnectionI.message(ConnectionI.java:1056)
at IceInternal.ThreadPool.run(ThreadPool.java:395)
at IceInternal.ThreadPool.access$300(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:832)
at java.lang.Thread.run(Thread.java:748)

serverExceptionClass = ome.conditions.InternalException
message = Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException):
Exception occurred inside getter of ome.model.screen.Well.wellSamples; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of ome.model.screen.Well.wellSamples
}

Re: Create WellSample in Python throws error

PostPosted: Thu Mar 07, 2019 9:22 am
by wmoore
Hi,

I think you want to do:

Code: Select all
well.addWellSample(wellSample)


instead of:

Code: Select all
wellSample.setWell(omero.model.WellI(well.getId(), False))


There is a complete working example of this at https://github.com/dsudar/OMEROscripts/ ... ate.py#L71

If that doesn't work, let us know.
Regards,

Will.

Re: Create WellSample in Python throws error

PostPosted: Thu Mar 07, 2019 10:09 am
by andersla
Thank you so much! That pointed me in the right direction!

Just out of curiosity, If I want to load the wellSamples that are part of the well object, how do I do that?
I tried searching for well object but, the wellSamples of that object are still unloaded?
How do I "..Please refresh this object in order to update this collection.." (as said in error message

e.g.
Code: Select all
IObject well = qs.findByQuery("from Well as w where w.id=:findID", params);
well.addWellSample(wellSample);


throws error:
omero.UnloadedCollectionException: Error updating collection:wellSamplesSeq
Collection is currently null. This can be seen
by testing "wellSamplesSeqLoaded". This implies
that this collection was unloaded. Please refresh this object
in order to update this collection.

omero.UnloadedCollectionException: Error updating collection:wellSamplesSeq
Collection is currently null. This can be seen
by testing "wellSamplesSeqLoaded". This implies
that this collection was unloaded. Please refresh this object
in order to update this collection.

at omero.model.WellI.throwNullCollectionException(WellI.java:35)
at omero.model.WellI.addWellSample(WellI.java:694)
at omero.model.Well.addWellSample(Well.java:136)
at com.example.SimpleConnection.createWellSample(SimpleConnection.java:176)
at com.example.SimpleConnection.main(SimpleConnection.java:265)

All the very best,
Anders

Re: Create WellSample in Python throws error

PostPosted: Fri Mar 08, 2019 11:29 am
by mtbc
Dear Anders,

You need to join the collections that you want to work with. In your,
Code: Select all
... from Well as w where ...
try adjusting to,
Code: Select all
... from Well as w join fetch w.wellSamples where ...

If you need to join a whole nested tree of collections then, just as your well is "w", you could name the well samples "ws" or whatever and further join fetch from that.

Cheers,
Mark