Skip to content

Annotation count web#5023

Merged
jburel merged 27 commits intoome:developfrom
dominikl:annotation_count_web
Mar 2, 2017
Merged

Annotation count web#5023
jburel merged 27 commits intoome:developfrom
dominikl:annotation_count_web

Conversation

@dominikl
Copy link
Copy Markdown
Member

@dominikl dominikl commented Jan 11, 2017

What this PR does

Show the number of annotations available in the right hand side panel.

screen shot 2017-01-11 at 11 03 18

Testing this PR

Annotate different objects (Images, Datasets, etc.). Select these objects (also some non-annotated objects) and make sure the annotation count shown is correct. Test with single as well as multi (batch) selection.

Related reading

Trello - RFE: Indication of number of annotations on an image in brackets (5) on accordion tabs in right hand pane.

/cc @will-moore

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.

You'll need a 3rd argument here so that the group context is right
findAllByQuery(q, params, self.conn.SERVICE_OPTS)
otherwise I think it will only query your default group.

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.

Minor point: I think you shouldn't need the fetch for parent as you don't need to retrieve parent for anything (just need join for the query itself).

@will-moore
Copy link
Copy Markdown
Member

Here you're counting annotation 'links' rather than the annotations themselves. E.g. if 2 users add the same Tag, this will show up as (2) which is different from what Insight is doing.

However, it is consistent with the way webclient displays Tags in the single-object right panel (each tag is shown once for every time it is linked) but not in batch-annotate panel (all links for each tag are collapsed into single tag).
If we want the number to match the number of Tags shown in each panel, then we'd need to count them differently for batch vv single object.
Probably better to always count Annotations rather than links, and we can consider changing the display of Tags for single object later. I know @jburel has been advocating this for some time!

@will-moore
Copy link
Copy Markdown
Member

A few flake8 errors to fix for travis.

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.

You don't need this loop, you can simply do {{ annotationCounts.TagAnnotation }}.

Copy link
Copy Markdown
Member

@atarkowska atarkowska left a comment

Choose a reason for hiding this comment

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

Thank for tackling the card. Some comments in the code.

BlitzObjectWrapper offers listAnnotations https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroPy/src/omero/gateway/__init__.py#L949. Why not add countAnnotations there? To me looks like it should to to gateway

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.

could you please use constant omero.constants.metadata.NSINSIGHTRATING

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.

could you please use constant omero.constants.metadata.NSINSIGHTRATING

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.

please do not use object as a var, just obj

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.

no need to loop. just({{ annotationCounts.CommentAnnotation }})

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.

no need to loop. ({{ annotationCounts.FileAnnotation }})

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.

no need to loop. ({{ annotationCounts.MapAnnotation }})

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.

no need to loop. ({{ annotationCounts.OtherAnnotation }})

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.

no need to loop. ({{ annotationCounts.LongAnnotation }})

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.

no need to loop. ({{ annotationCounts.TagAnnotation }})

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.

we are repeating the same code, could you move them to helpers please?

@jburel jburel added the develop label Jan 12, 2017
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.

I should move these methods somewhere else. Where's a good place for utilility/helper methods @aleksandra-tarkowska ?

@will-moore
Copy link
Copy Markdown
Member

Web error reported at
/webclient/metadata_details/acquisition/160/

 serverStackTrace = ome.services.query.QueryException: Illegal query
None is not mapped [
           select al from None al
           left outer join al.parent as pa
           left outer join fetch al.child as an
           where pa.id = :id
           ]

@will-moore
Copy link
Copy Markdown
Member

That error was also causing 'Run' right panel to fail in a bunch of robot tests https://ci.openmicroscopy.org/view/Failing/job/OMERO-DEV-merge-robotframework/497/robot/

@atarkowska
Copy link
Copy Markdown
Member

could you please add gateway tests?

Copy link
Copy Markdown
Member

@atarkowska atarkowska left a comment

Choose a reason for hiding this comment

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

thanks for the changes. still few suggestions

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 12, 2017

Choose a reason for hiding this comment

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

This could be named countAnnotations, but up to you. I would also expect ns as a param to match listAnnotations

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.

Couldn't use countAnnotations because it's also defined in https://github.com/dominikl/openmicroscopy/blob/c99b0e5c0e7535326d947cc4f0e04666cf938234/components/tools/OmeroWeb/omeroweb/webclient/webclient_gateway.py#L2040 . I'll rename both methods to getAnnotationCounts to be consistent.

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.

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.

So I think we do not want to move self.annotation_counter but the method could be unified in the main gateway so we don't need to deprecate anything. Happy to chat

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.

why not return self._get_object().getAnnotationCount()

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 12, 2017

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 12, 2017

Choose a reason for hiding this comment

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

So you could use objtype=o.OMERO_CLASS directly without a need of getAnnotationLinkTableName

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 12, 2017

Choose a reason for hiding this comment

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

why do you need getAnnotationLinkTableName?
How about

q = """select al from %sAnnotationLinks al
            left outer join al.parent as pa
            left outer join fetch al.child as an
            where pa.id = :id
    """ % self.OMERO_CLASS

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 13, 2017

Choose a reason for hiding this comment

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

empty dict in python is declared as mydict = {} see https://docs.python.org/2/library/stdtypes.html

This will throw exception in a loop

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 13, 2017

Choose a reason for hiding this comment

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

as Annotation are in the same table I would assume they shouldn't have the same id regardless of type, so unique list could be constructed from the annotationlinks.

Then you could just do: uniqueIds = set([al._child._id._val for al in annotationlinks])

if you need per type maybe just use dict {'type': [ id, ...]} rather then parse string

just a suggestion

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 13, 2017

Choose a reason for hiding this comment

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

interesting, is that passing flake8? I think q = q + " and an.ns in (:ns)"

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 13, 2017

Choose a reason for hiding this comment

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

how about to replace that long conditional statement with obj_type.title().replace("Plateacquisition", "PlateAcquisition")

@dominikl dominikl closed this Jan 13, 2017
@dominikl dominikl reopened this Jan 13, 2017
@dominikl dominikl closed this Jan 13, 2017
@dominikl dominikl reopened this Jan 13, 2017
@dominikl dominikl closed this Jan 16, 2017
@dominikl dominikl reopened this Jan 16, 2017
@dominikl dominikl closed this Jan 16, 2017
@dominikl dominikl reopened this Jan 16, 2017
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.

is that really an optional arg?

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.

if you declare as a list you don't need that bit

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.

isinstance please

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.

How shall I use isinstance to check if the type of the annotation is part of the dictionary atypes?

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 20, 2017

Choose a reason for hiding this comment

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

isinstance(al._child, tuple(atypes.keys())) https://docs.python.org/2/library/functions.html#isinstance

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.

Ideally if you could load atypes from the registry of abstract class. https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroPy/src/omero/gateway/__init__.py#L4599
Maybe look at this later as an improvement step

Copy link
Copy Markdown
Member

@atarkowska atarkowska Jan 16, 2017

Choose a reason for hiding this comment

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

this is inconvenient, accordion is now configurable https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/settings.py#L663, would you like to take it to the account? How about other way around, building dict of types from annotationlinks

@atarkowska
Copy link
Copy Markdown
Member

I am guessing https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/settings.py#L663 could be taken to the account in HQL query as well

@dominikl dominikl force-pushed the annotation_count_web branch from f7fe051 to 2765016 Compare February 27, 2017 16:16
@dominikl dominikl closed this Feb 27, 2017
@dominikl dominikl reopened this Feb 27, 2017
@dominikl dominikl closed this Feb 27, 2017
@dominikl dominikl reopened this Feb 27, 2017
@dominikl dominikl closed this Feb 27, 2017
@dominikl dominikl reopened this Feb 27, 2017

ctx = self.SERVICE_OPTS.copy()
ctx.setOmeroGroup(self.group)
ctx.setOmeroGroup(None)
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.

I found that when you are querying in a group that is NOT your default group, you actually need to use ctx.setOmeroGroup(-1) here, otherwise you don't see anything:

screen shot 2017-02-28 at 14 56 40

@will-moore
Copy link
Copy Markdown
Member

Working fine across different groups now.
Good to merge.


for r in queryResult:
ur = unwrap(r)
if ur[3] == '/basic/num/long/':
Copy link
Copy Markdown
Member

@atarkowska atarkowska Mar 1, 2017

Choose a reason for hiding this comment

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

#5056 was merged, is there anything stopping you from using type(an.class)?

queryResult = self.getQueryService().projection(q, params, ctx)

for r in queryResult:
ur = unwrap(r)
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.

same code as above (line 190). A helper method will be better

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.

I think @dominikl just forgot to remove the old method when moving it into the Gateway in b39c5f6

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.

Thanks. Yes, forgot to remove the old code (line 190+).

@dominikl dominikl closed this Mar 1, 2017
@dominikl dominikl reopened this Mar 1, 2017
@dominikl
Copy link
Copy Markdown
Member Author

dominikl commented Mar 1, 2017

--depends-on #5139

@dominikl dominikl closed this Mar 1, 2017
@dominikl dominikl reopened this Mar 1, 2017
@dominikl dominikl closed this Mar 1, 2017
@dominikl dominikl reopened this Mar 1, 2017
@jburel
Copy link
Copy Markdown
Member

jburel commented Mar 2, 2017

Thanks for removing the code.
When I add a tag for example, the tag is added but I was expected to be reflected in the count.
This is not the case until I reload the right hand panel
This could be an RFE done in another PR (not 5.3.0) since this PR is getting long

@dominikl
Copy link
Copy Markdown
Member Author

dominikl commented Mar 2, 2017

Yes, @will-moore suggested a follow-up PR for that problem, too #5023 (comment)

@jburel
Copy link
Copy Markdown
Member

jburel commented Mar 2, 2017

@dominikl so I missed it in the long thread. I will add a card

@jburel
Copy link
Copy Markdown
Member

jburel commented Mar 2, 2017

@jburel jburel merged commit 7fd4d89 into ome:develop Mar 2, 2017
@jburel jburel added this to the 5.3.0 milestone Mar 29, 2017
@dominikl dominikl deleted the annotation_count_web branch May 3, 2017 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants