Skip to content

Regression

OmeroWeb.test.integration.test_tree.TestTree.test_marshal_images_share (from pytest)

Failing for the past 1 build (Since #158 )
Took 5.6 sec.

Error Message

TypeError: list indices must be integers or slices, not str

Stacktrace

self = <test_tree.TestTree object at 0x7faf24ae9a60>
userA = (<omero.clients.BaseClient object at 0x7fafa495f1c0>, object #0 (::omero::model::Experimenter)
{
    _id = object #1 (...nnotationLinksSeq = 
    {
    }
    _annotationLinksLoaded = False
    _annotationLinksCountPerOwner = 
    {
    }
})
shares_userA_owned = [object #0 (::omero::model::Share)
{
    _id = object #1 (::omero::RLong)
    {
        _val = 10109
    }
    _detail... 2
        [398] = 5
        [399] = 0
        [400] = 0
        [401] = 0
        [402] = 0
        [403] = 0
    }
}]
images_userA_groupA = [object #0 (::omero::model::Image)
{
    _id = object #1 (::omero::RLong)
    {
        _val = 7378
    }
    _details...   {
    }
    _name = object #55 (::omero::RString)
    {
        _val = Neon
    }
    _description = <object #14>
}]

    def test_marshal_images_share(self, userA, shares_userA_owned,
                                  images_userA_groupA):
        """
        Test marshalling images for shareA
        """
        conn = get_connection(userA)
        share = shares_userA_owned[0]
        images = images_userA_groupA
        expected = expected_images(userA, images,
                                   extraValues={'shareId': share.id.val})
>       marshaled = marshal_images(conn=conn,
                                   share_id=share.id.val)

test/integration/test_tree.py:1894: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

conn = <omeroweb.webclient.webclient_gateway.OmeroWebGateway object at 0x7fafac0ed6a0>
dataset_id = None, orphaned = False, share_id = 10109, load_pixels = False
group_id = -1, experimenter_id = -1, page = 1, date = False
thumb_version = False, limit = 200

    def marshal_images(
        conn,
        dataset_id=None,
        orphaned=False,
        share_id=None,
        load_pixels=False,
        group_id=-1,
        experimenter_id=-1,
        page=1,
        date=False,
        thumb_version=False,
        limit=settings.PAGE,
    ):
        """Marshals images
    
        @param conn OMERO gateway.
        @type conn L{omero.gateway.BlitzGateway}
        @param dataset_id The Dataset ID to filter by or `None` to
        not filter by a specific dataset.
        defaults to `None`
        @type dataset_id L{long}
        @param orphaned If this is to filter by orphaned data. Overridden
        by dataset_id.
        defaults to False
        @type orphaned Boolean
        @param share_id The Share ID to filter by or `None` to
        not filter by a specific share.
        defaults to `None`
        @type share_id L{long}
        @param load_pixels Whether to load the X,Y,Z dimensions
        @type load_pixels Boolean
        @param group_id The Group ID to filter by or -1 for all groups,
        defaults to -1
        @type group_id L{long}
        @param experimenter_id The Experimenter (user) ID to filter by
        or -1 for all experimenters
        @type experimenter_id L{long}
        @param page Page number of results to get. `None` or 0 for no paging
        defaults to 1
        @type page L{long}
        @param limit The limit of results per page to get
        defaults to the value set in settings.PAGE
        @type page L{long}
    
        """
        images = []
        params = omero.sys.ParametersI()
        service_opts = deepcopy(conn.SERVICE_OPTS)
    
        # Set the desired group context
        if group_id is None:
            group_id = -1
        service_opts.setOmeroGroup(group_id)
    
        # Paging
        if page is not None and page > 0:
            params.page((page - 1) * limit, limit)
    
        from_join_clauses = []
        where_clause = []
        if experimenter_id is not None and experimenter_id != -1:
            params.addId(experimenter_id)
            where_clause.append("image.details.owner.id = :id")
        qs = conn.getQueryService()
    
        extraValues = ""
        if load_pixels:
            extraValues = """
                 ,
                 pix.sizeX as sizeX,
                 pix.sizeY as sizeY,
                 pix.sizeT as sizeT,
                 pix.sizeZ as sizeZ
                 """
    
        if date:
            extraValues += """,
                image.details.creationEvent.time as date,
                image.acquisitionDate as acqDate
                """
    
        q = (
            """
            select new map(image.id as id,
                   image.archived as archived,
                   image.name as name,
                   image.details.owner.id as ownerId,
                   image as image_details_permissions,
                   image.fileset.id as filesetId %s)
            """
            % extraValues
        )
    
        from_join_clauses.append("Image image")
    
        if load_pixels:
            # We use 'left outer join', since we still want images if no pixels
            from_join_clauses.append("left outer join image.pixels pix")
    
        # If this is a query to get images from a parent dataset
        if dataset_id is not None:
            params.add("did", rlong(dataset_id))
            from_join_clauses.append("join image.datasetLinks dlink")
            where_clause.append("dlink.parent.id = :did")
    
        # If this is a query to get images with no parent datasets (orphans)
        # At the moment the implementation assumes that a cross-linked
        # object is not an orphan. We may need to change that so that a user
        # see all the data that belongs to them that is not assigned to a container
        # that they own.
        elif orphaned:
            orphan_where = """
                            not exists (
                                select dilink from DatasetImageLink as dilink
                                where dilink.child = image.id
    
                            """
            # This is what is necessary if an orphan means that it has no
            # container that belongs to the image owner. This corresponds
            # to marshal_orphaned as well because of the child count
            # if experimenter_id is not None and experimenter_id != -1:
            #     orphan_where += ' and dilink.parent.details.owner.id = :id '
    
            orphan_where += ") "
            where_clause.append(orphan_where)
    
            # Also discount any images which are part of a screen. No need to
            # take owner into account on this because we don't want them in
            # orphans either way
            where_clause.append(
                """
                not exists (
                    select ws from WellSample ws
                    where ws.image.id = image.id
                )
                """
            )
    
        # If this is a query to get images in a share
        if share_id is not None:
            # Get the contents of the blob which contains the images in the share
            # Would be nice to do this without the ShareService, preferably as part
            # of the single query
            image_rids = [
                image_rid.getId().val
                for image_rid in conn.getShareService().getContents(share_id)
                if isinstance(image_rid, omero.model.ImageI)
            ]
    
            # If there are no images in the share, don't bother querying
            if not image_rids:
                return images
    
            params.add("iids", wrap([rlong(id) for id in image_rids]))
            where_clause.append("image.id in (:iids)")
    
        q += """
            %s %s
            order by lower(image.name), image.id
            """ % (
            " from " + " ".join(from_join_clauses),
            build_clause(where_clause, "where", "and"),
        )
    
        for e in qs.projection(q, params, service_opts):
            data = unwrap(e)[0]
            kwargs = {}
            if date:
                kwargs["acqDate"] = data["acqDate"]
                kwargs["date"] = data["date"]
    
            # While marshalling the images, determine if there are any
            # images mentioned in shares that are not in the results
            # because they have been deleted
            if share_id is not None and image_rids and data["id"] in image_rids:
>               image_rids.remove(e["id"])
E               TypeError: list indices must be integers or slices, not str

../../../../.venv3/lib64/python3.9/site-packages/omeroweb/webclient/tree.py:817: TypeError