Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #8858 (closed)

Opened 10 years ago

Closed 10 years ago

Blitz getDetails.__init__()

Reported by: wmoore Owned by: cneves
Priority: critical Milestone: OMERO-4.4
Component: OmeroPy Version: n.a.
Keywords: n.a. Cc: python-team@…
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: n.a.
Sprint: 2012-07-03 (18)

Description

I just got a stack trace (see below) when calling getDetails() on a TagAnnotationLinkWrapper? because the wrapper had been passed a Tag instead of conn in it's constructor. #8828.

This is easily fixed! However, it illustrated unnecessary loading of details.owner when calling getDetails().

I call getDetails().getPermissions().canDelete() OR canAnnotate() OR canEdit() etc many times with the new permissions rules and to do this, I DON'T need to load the owner or group of the details in order to do this, so the DetailsWrapper? doesn't need to load them:

    def __init__ (self, *args, **kwargs):
        super(DetailsWrapper, self).__init__ (*args, **kwargs)
        owner = self._obj.getOwner()
        group = self._obj.getGroup()
        self._owner = owner and ExperimenterWrapper(self._conn, self._obj.getOwner()) or None
        self._group = group and ExperimenterGroupWrapper(self._conn, self._obj.getGroup()) or None 

I *could* fix my initial bug by commenting out the line # self._owner = ... since I can call getDetails().getPermissions().canDelete() without needing the details._owner.

Is it possible to leave these unloaded during DetailsWrapper?.init() and only load them if we need them?

My original stack trace below:

Traceback:
File "/Users/will/Desktop/OMERO/dist/lib/python/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/decorators.py" in wrapped
  311.             retval = f(request, *args, **kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/decorators.py" in wrapper
  345.             context = f(request, *args, **kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webclient/views.py" in manage_action_containers
  1386.         manager.remove(parent)            
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webclient/controller/container.py" in remove
  873.                 print "al", al.canDelete()
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in canDelete
  513.         return self.getDetails().getPermissions().canDelete()
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in getDetails
  311.             return omero.gateway.DetailsWrapper (self._conn, self._obj.getDetails())
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in __init__
  4348.         self._owner = owner and ExperimenterWrapper(self._conn, self._obj.getOwner()) or None
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in __init__
  166.                 self._obj = self._conn.getQueryService().get(self._obj.__class__.__name__, self._oid, self._conn.CONFIG['SERVICE_OPTS'])
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in __getattr__
  1102.         raise AttributeError("'%s' object has no attribute '%s'" % (self._obj.__class__.__name__, attr))

Exception Type: AttributeError at /webclient/action/remove/tag/104/
Exception Value: 'TagAnnotationI' object has no attribute 'getQueryService'

Change History (7)

comment:1 Changed 10 years ago by wmoore

Another example of this problem:

This code:

g = conn.getObject("ExperimenterGroup", 1)
print g.isPrivate()

causes the DetailsWrapper? to be created 4 times, each time loading the Experimenter and Group from the server. ie 8 iQuery calls!

When I add a print out in the Blitz Object Wrapper init

            if not self._obj.loaded:
                print "BlitzObject __init__ loading...", self._obj.__class__.__name__, self._oid
                self._obj = self._conn.getQueryService().get(self._obj.__class__.__name__, self._oid, self._conn.CONFIG['SERVICE_OPTS'])

I see this printed when running the code above:

DetailsWrapper init
BlitzObject __init__ loading... ExperimenterI 0
BlitzObject __init__ loading... ExperimenterGroupI 0
DetailsWrapper init
BlitzObject __init__ loading... ExperimenterI 0
BlitzObject __init__ loading... ExperimenterGroupI 0
DetailsWrapper init
BlitzObject __init__ loading... ExperimenterI 0
BlitzObject __init__ loading... ExperimenterGroupI 0
DetailsWrapper init
BlitzObject __init__ loading... ExperimenterI 0
BlitzObject __init__ loading... ExperimenterGroupI 0
True

comment:2 Changed 10 years ago by jmoore

  • Priority changed from major to critical

comment:3 Changed 10 years ago by jmoore

  • Cc python-team@… added; atarkowska cxallan removed
  • Sprint set to 2012-06-19 (17)

comment:4 Changed 10 years ago by atarkowska

Referring to the conversation on devteam chat about #8988.

File "/home/omero/slave/workspace/OMERO-merge-green/src/dist/lib/python/omero/gateway/__init__.py", line 1148, in getOwner
    return self.getDetails().getOwner()

AttributeError: 'NoneType' object has no attribute 'getOwner'

There is a chance that client side proxy object might not exist in database any more, but reference is still in place (like deleted image still kept in share). In that edge case object look like:

object #0 (::omero::model::Image)
{
    _id = object #1 (::omero::RLong)
    {
        _val = 107
    }
    _details = <nil>
    _loaded = False
    _version = <nil>
    ...
}

As there is no such object any more, because exception is valid. That could be potentially fixed by throwing different exception like ObjectDoesNotExist?.

comment:5 Changed 10 years ago by jburel

  • Sprint changed from 2012-06-19 (17) to 2012-07-03 (18)

Moved from sprint 2012-06-19 (17)

comment:6 Changed 10 years ago by wmoore

Josh:

re: the recent slowness on loading web, I know I have a crazy number of groups but

~/git/dist $ grep -E "2012-06-29 10:0[789]" var/log/Blitz-0.log | grep -E "(Meth|Rslt)" | cut -f4 -d: | sort | uniq -c
7331     interface ome.api.IQuery.findByQuery
58617     interface ome.api.IQuery.get
29309     ome.model.meta.Experimenter
36638     ome.model.meta.ExperimenterGroup
In the last 3 minutes, over 60K "IQuery.get" calls on Experimenters and ExperimenterGroups.

comment:7 Changed 10 years ago by cxallan

  • Resolution set to fixed
  • Status changed from new to closed

Closed by various upstream commits on sprint18-bugfixes.

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.68095 sec.)

We're Hiring!