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

getGridSize() handles plates with no Wells #398

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Feb 14, 2024

Fixes error from QA: https://www.openmicroscopy.org/qa2/qa/feedback/41352/

{"message": "'NoneType' object has no attribute 'val'", "stacktrace": "Traceback (most recent call last):
File \"/opt/omero/web/venv3/lib64/python3.9/site-packages/omeroweb/webgateway/views.py\", line 1500, in wrap
 rv = f(request, *args, **kwargs)
 File \"/opt/omero/web/venv3/lib64/python3.9/site-packages/omeroweb/webgateway/views.py\", line 1708, in plateGrid_json
 rv = plateGrid.metadata
 File \"/opt/omero/web/venv3/lib64/python3.9/site-packages/omeroweb/webgateway/plategrid.py\", line 71, in metadata
self.plate.setGridSizeConstraints(8, 12)
 File \"/opt/omero/web/venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py\", line 6637, in setGridSizeConstraints
 gs = self.getGridSize()\n File \"/opt/omero/web/venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py\", line 6659, in getGridSize
 self._gridSize = {'rows': row.val+1, 'columns': col.val+1}
AttributeError: 'NoneType' object has no attribute 'val'
"}

To test, create a Plate with no Wells:

$ omero obj new Plate name=empty

Browse in webclient:

Screenshot 2024-02-14 at 15 56 17

@@ -6656,7 +6656,10 @@ def getGridSize(self):
"where plate.id = :id"
res = q.projection(query, params, self._conn.SERVICE_OPTS)
(row, col) = res[0]
self._gridSize = {'rows': row.val+1, 'columns': col.val+1}
if row is None or col is None:
self._gridSize = {'rows': 0, 'columns': 0}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handling makes sense. An alternative would be to store and return self._gridSize = None. In case the wells are being added in between calls, this would allow subsequent calls to self.getGridSize() to retry the plate query. I do not know enough about consumers of this API and how a None return value would be handled.

Either way, it's probably good practice to update the docstring and document the expectation in case the plate has no wells.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbesson - apologies for the delay...
I think the expectation is not to return None - Returning sizes of 0 is more consistent and doesn't need special handling of None by consumers.
Docstring updated.

@jburel jburel merged commit 2864126 into ome:master Apr 24, 2024
8 checks passed
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 this pull request may close these issues.

3 participants