Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 30 additions & 36 deletions omeroweb/webclient/controller/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,73 +82,67 @@ def __init__(
**kw,
):
BaseController.__init__(self, conn)

if project is not None:
self.obj_type = "project"
self.project = self.conn.getObject("Project", project)
self.assertNotNone(self.project, project, "Project")
self.assertNotNone(self.project._obj, project, "Project")
self.project = self._getObject("Project", project)
if dataset is not None:
self.obj_type = "dataset"
self.dataset = self.conn.getObject("Dataset", dataset)
self.assertNotNone(self.dataset, dataset, "Dataset")
self.assertNotNone(self.dataset._obj, dataset, "Dataset")
self.dataset = self._getObject("Dataset", dataset)
if screen is not None:
self.obj_type = "screen"
self.screen = self.conn.getObject("Screen", screen)
self.assertNotNone(self.screen, screen, "Screen")
self.assertNotNone(self.screen._obj, screen, "Screen")
self.screen = self._getObject("Screen", screen)
if plate is not None:
self.obj_type = "plate"
self.plate = self.conn.getObject("Plate", plate)
self.assertNotNone(self.plate, plate, "Plate")
self.assertNotNone(self.plate._obj, plate, "Plate")
self.plate = self._getObject("Plate", plate)
if acquisition is not None:
self.obj_type = "acquisition"
self.acquisition = self.conn.getObject("PlateAcquisition", acquisition)
self.assertNotNone(self.acquisition, acquisition, "Plate Acquisition")
self.assertNotNone(self.acquisition._obj, acquisition, "Plate Acquisition")
self.acquisition = self._getObject("PlateAcquisition", acquisition)
if image is not None:
self.obj_type = "image"
self.image = self.conn.getObject("Image", image)
self.assertNotNone(self.image, image, "Image")
self.assertNotNone(self.image._obj, image, "Image")
self.image = self._getObject("Image", image)
if well is not None:
self.obj_type = "well"
self.well = self.conn.getObject("Well", well)
self.assertNotNone(self.well, well, "Well")
self.assertNotNone(self.well._obj, well, "Well")
self.well = self._getObject("Well", well)
if tag is not None:
self.obj_type = "tag"
self.tag = self.conn.getObject("Annotation", tag)
self.assertNotNone(self.tag, tag, "Tag")
self.assertNotNone(self.tag._obj, tag, "Tag")
self.tag = self._getObject("Annotation", tag)
if tagset is not None:
self.obj_type = "tagset"
self.tag = self.conn.getObject("Annotation", tagset)
self.tag = self._getObject("Annotation", tagset)
# We need to check if tagset via hasattr(manager, o_type)
self.tagset = self.tag
self.assertNotNone(self.tag, tagset, "Tag")
self.assertNotNone(self.tag._obj, tagset, "Tag")
if comment is not None:
self.obj_type = "comment"
self.comment = self.conn.getObject("Annotation", comment)
self.assertNotNone(self.comment, comment, "Comment")
self.assertNotNone(self.comment._obj, comment, "Comment")
self.comment = self._getObject("Annotation", comment)
if file is not None:
self.obj_type = "file"
self.file = self.conn.getObject("Annotation", file)
self.assertNotNone(self.file, file, "File")
self.assertNotNone(self.file._obj, file, "File")
self.file = self._getObject("Annotation", file)
if annotation is not None:
self.obj_type = "annotation"
self.annotation = self.conn.getObject("Annotation", annotation)
self.assertNotNone(self.annotation, annotation, "Annotation")
self.assertNotNone(self.annotation._obj, annotation, "Annotation")
self.annotation = self._getObject("Annotation", annotation)
if orphaned:
self.orphaned = True
if index is not None:
self.index = index

def _getObject(self, obj_type, obj_id):
# we wrap conn.getObject() to FIRST set the group context
# since conn.getObject() with group: -1 is slow if user's default group is big
rsp_obj = None
try:
if self.conn.SERVICE_OPTS.getOmeroGroup() == -1:
obj = self.conn.getQueryService().get(
obj_type, int(obj_id), {"group": "-1"}
)
group_id = obj.getDetails().group.id.val
self.conn.SERVICE_OPTS.setOmeroGroup(group_id)
rsp_obj = self.conn.getObject(obj_type, obj_id)
except omero.ValidationException:
pass
self.assertNotNone(rsp_obj, obj_id, obj_type)
return rsp_obj

def assertNotNone(self, obj, obj_id, obj_name):
if obj is None:
raise AttributeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,7 @@ <h1>{% trans "Annotations" %}</h1>
{% if manager.share.isExpired %}
This {{ manager.share.getShareType|lower }} has expired and you no longer can make any comments.
{% else %}
<form id="add_share_comment_form" action="{% url 'annotate_comment' %}" method="post">{% csrf_token %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the relationship between these changes and the proposed performance improvements?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There was a lot of code for loading the objects for form_comment = CommentAnnotationForm(initial=initial) when that add_share_comment_form is not supported any more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Understood, so minimally we are trying to minimize the number of cross-group calls to conn.getObject[s] when loading the right-hand panel, is that correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, correct.

<table>
<tr class="hiddenField"><td>{{ form_comment.share }}</td></tr>
<tr>
<td>{{ form_comment.comment }}</td>
</tr>
<tr>
<td><input type="submit" value="{% trans 'Add Comment' %}" /></td>
</tr>
</table>
</form>
Commenting is no-longer supported.
{% endif %}
</th>
</tr>
Expand Down
51 changes: 0 additions & 51 deletions omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1717,61 +1717,12 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa

context = dict()

# we only expect a single object, but forms can take multiple objects
images = c_type == "image" and list(conn.getObjects("Image", [c_id])) or list()
datasets = (
c_type == "dataset" and list(conn.getObjects("Dataset", [c_id])) or list()
)
projects = (
c_type == "project" and list(conn.getObjects("Project", [c_id])) or list()
)
screens = c_type == "screen" and list(conn.getObjects("Screen", [c_id])) or list()
plates = c_type == "plate" and list(conn.getObjects("Plate", [c_id])) or list()
acquisitions = (
c_type == "acquisition"
and list(conn.getObjects("PlateAcquisition", [c_id]))
or list()
)
shares = (
(c_type == "share" or c_type == "discussion")
and [conn.getShare(c_id)]
or list()
)
wells = c_type == "well" and list(conn.getObjects("Well", [c_id])) or list()

# we simply set up the annotation form, passing the objects to be
# annotated.
selected = {
"images": c_type == "image" and [c_id] or [],
"datasets": c_type == "dataset" and [c_id] or [],
"projects": c_type == "project" and [c_id] or [],
"screens": c_type == "screen" and [c_id] or [],
"plates": c_type == "plate" and [c_id] or [],
"acquisitions": c_type == "acquisition" and [c_id] or [],
"wells": c_type == "well" and [c_id] or [],
"shares": ((c_type == "share" or c_type == "discussion") and [c_id] or []),
}

initial = {
"selected": selected,
"images": images,
"datasets": datasets,
"projects": projects,
"screens": screens,
"plates": plates,
"acquisitions": acquisitions,
"wells": wells,
"shares": shares,
}

form_comment = None
figScripts = None
if c_type in ("share", "discussion"):
template = "webclient/annotations/annotations_share.html"
manager = BaseShare(conn, c_id)
manager.getAllUsers(c_id)
manager.getComments(c_id)
form_comment = CommentAnnotationForm(initial=initial)
else:
try:
manager = BaseContainer(conn, **{str(c_type): int(c_id), "index": index})
Expand All @@ -1792,8 +1743,6 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa
context["insight_ns"] = omero.rtypes.rstring(
omero.constants.metadata.NSINSIGHTTAGSET
).val
if form_comment is not None:
context["form_comment"] = form_comment

context["figScripts"] = figScripts
context["template"] = template
Expand Down
Loading