ome / omero-server

Gradle project containing main server logic for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
4 stars 14 forks source link

binary_access `+plate` config throws UnloadedCollectionException for wellSamples #179

Open Rdornier opened 3 weeks ago

Rdornier commented 3 weeks ago

Hello,

Jumping from this issue, it seems that the omero.policy.binary_access configuration, if set to +read +write +image +plate, prevents the loading of wellSamples from the API (UnloadedCollectionException) at the ImageData level.

If this config is set to default, the wellSamples are loaded correctly. A minimal script is available in the above mentioned issue to test.

It seems to be a side effect of this config which, according to what I understand from the doc, should give the access to the binary files and allow the download of the plates from the webclient

Rémy cc @gaelrayot-epfl

dominikl commented 3 weeks ago

This is an odd error, binary_access should only affect download of images, plates, etc. But indeed, I can replicate the problem:

Plain, clean OMERO.server installation, no config changes, only one plate imported. Running:

...
BrowseFacility bf = gw.getFacility(BrowseFacility.class);
List<WellSample> samples = bf.getImage(ctx, 1).asImage().copyWellSamples();
System.out.println(samples.size());

gives:

1

Then changing server setting:

omero config set omero.policy.binary_access "+read,+write,+image,+plate"

Run above code again, now gives:

Exception in thread "main" 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)
dominikl commented 3 weeks ago

Same with Python API.

Default binary_access:

> python test.py
1

With +plate:

> python test.py
Traceback (most recent call last):
...
  File "/Users/dom/micromamba/envs/idr/lib/python3.10/site-packages/omero_model_ImageI.py", line 98, in throwNullCollectionException
    raise _omero.UnloadedEntityException(""+
omero.UnloadedEntityException: 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.

Script:

with omero.cli.cli_login() as c:
     conn = BlitzGateway(client_obj=c.get_client())
     img = conn.getObject("Image", 1)
     print(len(img._obj.copyWellSamples()))