ome / omero-blitz

Gradle project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
0 stars 15 forks source link

copyWellSamples() throws UnloadedCollectionException #149

Open Rdornier opened 4 months ago

Rdornier commented 4 months ago

Hello @jburel , @dominikl

I have an issue with the copyWellSamples() method in the Image.java class. When I run this command

List<WellSample> wellSampleList = user_client.getGateway().getFacility(BrowseFacility.class).getImage(ctx, id).asImage().copyWellSamples()

with id the id of an image coming from a plate, I get the following error and I don't understand why because the image seems to be fully loaded as I use the BrowseFacility class.

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.ImageI.throwNullCollectionException(ImageI.java:40)
    at omero.model.ImageI.copyWellSamples(ImageI.java:698)
    at omero.model.Image.copyWellSamples(Image.java:240)
    at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
    at New_.run(New_.groovy:52)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:331)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:161)
    at org.scijava.plugins.scripting.groovy.GroovyScriptLanguage$1.eval(GroovyScriptLanguage.java:97)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
    at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

I tried to get the wellSamples using a query and it works correctly.

List<IObject> wellSamplesObjects = user_client.getGateway()..getQueryService(ctx).findAllByQuery("select ws from WellSample ws where image=" + id, null);

   List<WellSample> wellSampleList = wellSamplesObjects.stream()
            .map(WellSample.class::cast)
            .collect(Collectors.toList())

Do you have an idea of what's going wrong ?

I added @ppouchin to this issue because ImageWrapper.getWells(client), and similar methods for plates and screens, are calling the same copyWellSamples() method

Thanks, Rémy.

joshmoore commented 4 months ago

Rémy,

Internally all API methods are using queries as well. If those do not join the necessary information, then the collection is unloaded and you will get this exception if you try to access it.

~Josh

dominikl commented 4 months ago

Yes, I don't think the getImage method will load the wellsamples. You could use the getWell method, but you'd need the well Id for that.

Rdornier commented 4 months ago

Hi @joshmoore and @dominikl,

Thanks for your answers. So, if I understand correctly, the wellSamples are not accessible from an ImageData object, even if we get the Image object. This is because the getImage() method from the browseFacility doesn't load them.

The method getWell does indeed retrieve the wellSamples but the well Id is necessary. With only an image Id, is there another method to retrieve the wellSamples, different from submitting a query ?

Rémy.

ppouchin commented 4 months ago

Hi!

Does it work sometimes or never? Because the automated tests I run do manage to get the WellSamples as far as I know. The Image is systematically reloaded before calling copyWellSamples() though (but similarly to the code you gave).

I'm wondering why I did not notice this. Is this new?

Rdornier commented 4 months ago

Here is a small groovy script that I have (it is a part of larger one) to test basic stuff on the server. I run the script on Fiji (with simple-omero-client-5.18.0 and omero-ij.5.8.4-all as dependencies)

minimal_test.zip

When I tried to get the well, plate and screen from the image coming from a plate, I get a Failed message, and the e.printStackTrace() prints the error I've pasted in my first post.

ppouchin commented 4 months ago

It's weird, it does work for me:

<<<<<<<<<<<< Retrieve hierarchy >>>>>>>>>>>>
--------- Image from screen ----------
Image name : screen1.fake [screen1] (id: 879545)
Well_name : Well A-1 / id : 305
Plate_name : screen1.fake / id : 214
Screen_name : Beads / id : 761
***** SUCCESS : retrieve the correct screen ******

Do I use it wrong?

Rdornier commented 4 months ago

Do I use it wrong?

Surely not ! This is exactly the output I was expected to get.

I made different tests and I found out that it fails to retrieve the screens on our 2 servers, but I succeed in getting the screen from my local docker install.

So, it may be due to a config that goes wrong on the servers. We did different stuff on those servers

Rémy.

ppouchin commented 4 months ago

Since WellSamples are not directly referenced in the image table in the database, maybe the wellSamplesSeq is somehow empty because of the desynchronization? I'm not sure when and how it is computed...

gaelrayot-epfl commented 4 months ago

maybe the wellSamplesSeq is somehow empty because of the desynchronization?

Looking at the database, we can, from a wellsample, get the IDs of the images (as the image IDs are set and not null). I do not understand what you mean by wellSampleSeq though. Is it a column of a table? How could we check it?

Also, is there a way (other than omero admin cleanse) to force the synchronization (or at least, a way to know if there is a de-synchronization).

Thank you.

ppouchin commented 4 months ago

Looking at the database, we can, from a wellsample, get the IDs of the images (as the image IDs are set and not null). I do not understand what you mean by wellSampleSeq though. Is it a column of a table? How could we check it?

The copyWellSamples method mentions that the WellSamplesSeq collection is null. If the wellsample references the image, that means that somewhere along the way, the collection is not properly computed, somehow. Or at least, the "loaded" property is not properly set... I suppose?

Rdornier commented 4 months ago

Hi,

We've just tested to get the WellSamplesSeq. On the production server (the one that works properly), the wellSamplesSeq is a list with the retrieved well samples

<<<<<<<<<<<< Retrieve hierarchy >>>>>>>>>>>>
--------- Image from screen ----------
Image name : Index.idx.xml [Well B01, Field 1] (id: 611335)
[omero.model.WellSampleI@45a7c671]
Well_name : Well B-1 / id : 34993
Plate_name : Index.idx.xml / id : 1579
Screen_name : testScreenError / id : 1513

On the server which doesn't work, indeed, wellSamplesSeq is an emtpy list.

<<<<<<<<<<<< Retrieve hierarchy >>>>>>>>>>>>
--------- Image from screen ----------
Image name : Index.idx.xml [Well A01, Field 1] (id: 3251)
[]
******* FAILED to read the well ********
******* FAILED to read the plate ********
******* FAILED to read the screen ********

So, I think this is the issue but I don't know how to get rid of this. Is there some configs that might not be set properly at the time we re-install the backup ?

Rémy

gaelrayot-epfl commented 4 months ago

By the way, when uploading the images, we have a log in the managed repo which contains some warns and errors:

2024-06-07 11:14:55,564 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterID(Experimenter:0, 0(                                                                                                                                                     
2024-06-07 11:14:55,565 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterEmail(null, 0(                                                                                                                                                            
2024-06-07 11:14:55,565 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterFirstName(null, 0(                                                                                                                                                        
2024-06-07 11:14:55,565 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterInstitution(null, 0(                                                                                                                                                      
2024-06-07 11:14:55,565 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterLastName(BIOPanalyst, 0(                                                                                                                                                  
2024-06-07 11:14:55,565 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterMiddleName(null, 0(                                                                                                                                                       
2024-06-07 11:14:55,565 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unsupported in OMERO. Ignoring setExperimenterUserName(null, 0(                                                                                                                                                         
2024-06-07 11:14:55,568 INFO  [    ome.security.basic.BasicEventContext] (l.Server-8)  cctx:    group=53                                                                                                                                                                                                      
2024-06-07 11:14:55,569 INFO  [         ome.security.basic.EventHandler] (l.Server-8)  Auth:    user=152,group=53,event=null(User),sess=c5141696-3c21-4996-814e-bd6f53a6f143                                                                                                                                  
2024-06-07 11:14:55,573 INFO  [                 org.perf4j.TimingLogger] (l.Server-8) start[1717751695567] time[5] tag[omero.call.success.ome.logic.QueryImpl.findAll]                                                                                                                                        
2024-06-07 11:14:55,582 INFO  [    ome.security.basic.BasicEventContext] (.Server-11)  cctx:    group=53                                                                                                                                                                                                      
2024-06-07 11:14:55,584 INFO  [         ome.security.basic.EventHandler] (.Server-11)  Auth:    user=152,group=53,event=null(User),sess=c5141696-3c21-4996-814e-bd6f53a6f143                                                                                                                                  
2024-06-07 11:14:55,585 INFO  [                 org.perf4j.TimingLogger] (.Server-11) start[1717751695582] time[3] tag[omero.call.success.ome.logic.QueryImpl.findAll]                                                                                                                                        
2024-06-07 11:14:55,588 INFO  [    ome.security.basic.BasicEventContext] (.Server-10)  cctx:    group=53                                                                                                                                                                                                      
2024-06-07 11:14:55,589 INFO  [         ome.security.basic.EventHandler] (.Server-10)  Auth:    user=152,group=53,event=null(User),sess=c5141696-3c21-4996-814e-bd6f53a6f143                                                                                                                                  
2024-06-07 11:14:55,591 INFO  [                 org.perf4j.TimingLogger] (.Server-10) start[1717751695588] time[3] tag[omero.call.success.ome.logic.QueryImpl.findAll]                                                                                                                                        
2024-06-07 11:14:55,597 INFO  [    ome.security.basic.BasicEventContext] (l.Server-8)  cctx:    group=53                                                                                                                                                                                                      
2024-06-07 11:14:55,598 INFO  [         ome.security.basic.EventHandler] (l.Server-8)  Auth:    user=152,group=53,event=null(User),sess=c5141696-3c21-4996-814e-bd6f53a6f143                                                                                                                                  
2024-06-07 11:14:55,599 INFO  [                 org.perf4j.TimingLogger] (l.Server-8) start[1717751695596] time[2] tag[omero.call.success.ome.logic.QueryImpl.findAll]                                                                                                                                        
2024-06-07 11:14:55,601 INFO  [    ome.security.basic.BasicEventContext] (.Server-11)  cctx:    group=53                                                                                                                                                                                                      
2024-06-07 11:14:55,602 INFO  [         ome.security.basic.EventHandler] (.Server-11)  Auth:    user=152,group=53,event=null(User),sess=c5141696-3c21-4996-814e-bd6f53a6f143                                                                                                                                  
2024-06-07 11:14:55,605 INFO  [                 org.perf4j.TimingLogger] (.Server-11) start[1717751695601] time[3] tag[omero.call.success.ome.logic.QueryImpl.findAll]                                                                                                                                        
2024-06-07 11:14:55,608 INFO  [    ome.security.basic.BasicEventContext] (.Server-10)  cctx:    group=53                                                                                                                                                                                                      
2024-06-07 11:14:55,608 INFO  [         ome.security.basic.EventHandler] (.Server-10)  Auth:    user=152,group=53,event=null(User),sess=c5141696-3c21-4996-814e-bd6f53a6f143                                                                                                                                  
2024-06-07 11:14:55,610 INFO  [                 org.perf4j.TimingLogger] (.Server-10) start[1717751695607] time[3] tag[omero.call.success.ome.logic.QueryImpl.findAll]                                                                                                                                        
2024-06-07 11:14:55,652 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setPlateFieldIndex(null, 0(                                                                                                                                                                 
2024-06-07 11:14:55,655 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(0, 0, 0, 0(                                                                                                                                                              
2024-06-07 11:14:55,655 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(1, 0, 0, 1(                                                                                                                                                              
2024-06-07 11:14:55,655 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(2, 0, 0, 2(                                                                                                                                                              
2024-06-07 11:14:55,655 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(3, 0, 0, 3(                                                                                                                                                              
2024-06-07 11:14:55,656 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(4, 0, 1, 0(                                                                                                                                                              
2024-06-07 11:14:55,656 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(5, 0, 1, 1(
2024-06-07 11:14:55,656 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(6, 0, 1, 2(
2024-06-07 11:14:55,657 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(7, 0, 1, 3(
2024-06-07 11:14:55,657 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(8, 0, 2, 0(
2024-06-07 11:14:55,657 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(9, 0, 2, 1(
2024-06-07 11:14:55,658 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(10, 0, 2, 2(
2024-06-07 11:14:55,658 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(11, 0, 2, 3(
2024-06-07 11:14:55,658 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(12, 0, 3, 0(
2024-06-07 11:14:55,658 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(13, 0, 3, 1(
2024-06-07 11:14:55,659 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(14, 0, 3, 2(
2024-06-07 11:14:55,659 WARN  [    ome.formats.OMEROMetadataStoreClient] (2-thread-3) Unneeded in OMERO. Ignoring setWellSampleIndex(15, 0, 3, 3(
2024-06-07 11:14:55,790 DEBUG [                   loci.formats.Memoizer] (2-thread-3) saved to temp file: /omero/data/BioFormatsCache/omero/data/ManagedRepository/dornier_152/2024-06/07/11-14-43.000/Screen_test/.Index.idx.xml.bfmemo14133059000726758105
2024-06-07 11:14:55,791 DEBUG [                   loci.formats.Memoizer] (2-thread-3) start[1717751695699] time[91] tag[loci.formats.Memoizer.saveMemo] 
2024-06-07 11:14:55,793 DEBUG [                   loci.formats.Memoizer] (2-thread-3) saved memo file: /omero/data/BioFormatsCache/omero/data/ManagedRepository/dornier_152/2024-06/07/11-14-43.000/Screen_test/.Index.idx.xml.bfmemo (63030 bytes)

But those warns and errors also exists on our prod server which managed to get the WellSamplesSeq so I don't think it's related. I just do not know where to look to find more clues.

gaelrayot-epfl commented 4 months ago

Ok, so I look more into our OMERO configuration and spotted an interesting one: omero.policy.binary_access Seems that if you allow your users to access their plates (setting the var to +read,+write,+image,+plate), then using the code provided by @Rdornier will fail.

I've reset the var to its default value and now the wellSamplesSeq get filled with data.

So I guess a new ticket should be created.

Rdornier commented 4 months ago

Yes, now it works again

<<<<<<<<<<<< Retrieve hierarchy >>>>>>>>>>>>
--------- Image from screen ----------
Image name : Index.idx.xml [Well A01, Field 1] (id: 3251)
[omero.model.WellSampleI@7f4342d9]
Well_name : Well A-1 / id : 603
Plate_name : Index.idx.xml / id : 551
Screen_name : newTestAfterConfigChange / id : 551

So, it wasn't a desynchronisation issue but a config issue. That being said, I'm not sure this is the expected behavior of having +plate in that config.

Thanks @gaelrayot-epfl for your great troubleshooting ! And thank you all for your inputs.

Rémy.