Skip to content

Python gateway: ExternalInfo getter regression #481

@sbesson

Description

@sbesson

In OMERO.py 5.21.0, #453 introduced a new getExternalInfo API allowing to lazy-load ExternalInfo objects available from the details of various OMERO model objects.

The addition of this API caused some regression that can be demonstrated in the following example:

import omero.gateway
conn = omero.gateway.BlitzGateway(host=host,username=username,passwd=password)
try:
    conn.connect()
    image = conn.getObject("Image", iamge_idid)
    ext_info = image.getDetails().getExternalInfo()
finally:
    conn.close()

With OMERO.py 5.20.0 executing the above against a running server and valid image ID works but with OMERO.py 5.21.0 or 5.21.1 it will fail with the following stack trace

Traceback (most recent call last):
  File "/Users/sbesson/Documents/GitHub/omero-py/test.py", line 7, in <module>
    ext_info = image.getDetails().getExternalInfo()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sbesson/Documents/GitHub/omero-py/venv/lib/python3.12/site-packages/omero/gateway/__init__.py", line 1355, in getExternalInfo
    extinfo = self.getDetails()._externalInfo
              ^^^^^^^^^^^^^^^^^
  File "/Users/sbesson/Documents/GitHub/omero-py/venv/lib/python3.12/site-packages/omero/gateway/__init__.py", line 472, in getDetails
    if self._obj.loaded:
       ^^^^^^^^^^^^^^^^
  File "/Users/sbesson/Documents/GitHub/omero-py/venv/lib/python3.12/site-packages/omero_model_DetailsI.py", line 106, in __getattr__
    raise AttributeError(attr)
AttributeError: loaded

The underlying issue is that getExternalInfo API was defined at the BlitzObjectWrapper level and is inherited by all instance wrappers. This includes DetailsWrapper and overrides the previous getter which was either returning None or a BlitzObjectWrapper object depending on the use case.

One way to fix this is to override getExternalInfo again in DetailsWrapper restoring the previous behavior. @will-moore do you know if there is a better option to limit the getExternalInfo API to the relevant wrappers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions