Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_repr_html throws error for mapAnnotation object #428

Open
jo-mueller opened this issue Sep 6, 2024 · 0 comments · May be fixed by #429
Open

_repr_html throws error for mapAnnotation object #428

jo-mueller opened this issue Sep 6, 2024 · 0 comments · May be fixed by #429

Comments

@jo-mueller
Copy link
Contributor

jo-mueller commented Sep 6, 2024

Hi OME-Team,

this is a follow-up to PR #393, which introduced a nice rendering for ImageWrapper objects in Jupyter notebooks (for instance). I just ran into an issue which I think is caused by this new feature.

The repr_html method is introduced for the BlitzObjectWrapper class and the ImageWrapper class then derives from it. The problem is now: a MapAnnotationWrapper object also inherits the same overwritten _repr_html method from the BlitzObjectWrapper class, but it lacks quite a few attributes and hence throws an error upon just printing the object in a Jupyter notebook:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
c:\Users\johamuel\AppData\Local\mambaforge\envs\stress\lib\site-packages\omero\gateway\__init__.py in ?(self)
    249         """
    250         Returns an HTML representation of the object. This is used by the
    251         IPython notebook to display the object in a cell.
    252         """
--> 253         return image_to_html(self)

c:\Users\johamuel\AppData\Local\mambaforge\envs\stress\lib\site-packages\omero\gateway\utils.py in ?(image)
    267     <table>
    268         <tr><th></th><th>ID</th><th>Name</th></tr>
    269         {obj_html(image, 'Image')}
    270         {obj_html(image.getParent(), 'Dataset')}
--> 271         {obj_html(image.getProject(), 'Project')}
    272     </table>
    273     """
    274 

c:\Users\johamuel\AppData\Local\mambaforge\envs\stress\lib\site-packages\omero\gateway\__init__.py in ?(self, attr)
   1307                             rv = rv.decode('utf8')
   1308                         except:
   1309                             pass
   1310             return rv
-> 1311         raise AttributeError(
   1312             "'%s' object has no attribute '%s'"
   1313             % (self._obj.__class__.__name__, attr))

AttributeError: 'MapAnnotationI' object has no attribute 'getProject'

The solution for this would be to simply move the repr_html to the dervied class. And potentially introduce a specific _repr_html for MapAnnotation objects down the road, but that'd be for a separate PR. I'll try to send a PR today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant