Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
|
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 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). |
|
A few flake8 errors to fix for travis. |
There was a problem hiding this comment.
You don't need this loop, you can simply do {{ annotationCounts.TagAnnotation }}.
atarkowska
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
could you please use constant omero.constants.metadata.NSINSIGHTRATING
There was a problem hiding this comment.
could you please use constant omero.constants.metadata.NSINSIGHTRATING
There was a problem hiding this comment.
please do not use object as a var, just obj
There was a problem hiding this comment.
no need to loop. just({{ annotationCounts.CommentAnnotation }})
There was a problem hiding this comment.
no need to loop. ({{ annotationCounts.FileAnnotation }})
There was a problem hiding this comment.
no need to loop. ({{ annotationCounts.MapAnnotation }})
There was a problem hiding this comment.
no need to loop. ({{ annotationCounts.OtherAnnotation }})
There was a problem hiding this comment.
no need to loop. ({{ annotationCounts.LongAnnotation }})
There was a problem hiding this comment.
no need to loop. ({{ annotationCounts.TagAnnotation }})
There was a problem hiding this comment.
we are repeating the same code, could you move them to helpers please?
There was a problem hiding this comment.
I should move these methods somewhere else. Where's a good place for utilility/helper methods @aleksandra-tarkowska ?
|
Web error reported at |
|
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/ |
|
could you please add gateway tests? |
atarkowska
left a comment
There was a problem hiding this comment.
thanks for the changes. still few suggestions
There was a problem hiding this comment.
This could be named countAnnotations, but up to you. I would also expect ns as a param to match listAnnotations
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
How about moving https://github.com/dominikl/openmicroscopy/blob/c99b0e5c0e7535326d947cc4f0e04666cf938234/components/tools/OmeroWeb/omeroweb/webclient/webclient_gateway.py#L2040 down to gateway then. no need for 2
There was a problem hiding this comment.
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
There was a problem hiding this comment.
why not return self._get_object().getAnnotationCount()
There was a problem hiding this comment.
sorry for being picky, why that has to be a list of strings type-id? In the views.batch_annotate you have a dict objs of real objects https://github.com/dominikl/openmicroscopy/blob/c99b0e5c0e7535326d947cc4f0e04666cf938234/components/tools/OmeroWeb/omeroweb/webclient/views.py#L1969.
There was a problem hiding this comment.
So you could use objtype=o.OMERO_CLASS directly without a need of getAnnotationLinkTableName
There was a problem hiding this comment.
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
There was a problem hiding this comment.
empty dict in python is declared as mydict = {} see https://docs.python.org/2/library/stdtypes.html
This will throw exception in a loop
There was a problem hiding this comment.
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
There was a problem hiding this comment.
interesting, is that passing flake8? I think q = q + " and an.ns in (:ns)"
There was a problem hiding this comment.
how about to replace that long conditional statement with obj_type.title().replace("Plateacquisition", "PlateAcquisition")
There was a problem hiding this comment.
is that really an optional arg?
There was a problem hiding this comment.
if you declare as a list you don't need that bit
There was a problem hiding this comment.
How shall I use isinstance to check if the type of the annotation is part of the dictionary atypes?
There was a problem hiding this comment.
isinstance(al._child, tuple(atypes.keys())) https://docs.python.org/2/library/functions.html#isinstance
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
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 |
f7fe051 to
2765016
Compare
|
|
||
| ctx = self.SERVICE_OPTS.copy() | ||
| ctx.setOmeroGroup(self.group) | ||
| ctx.setOmeroGroup(None) |
|
Working fine across different groups now. |
|
|
||
| for r in queryResult: | ||
| ur = unwrap(r) | ||
| if ur[3] == '/basic/num/long/': |
There was a problem hiding this comment.
#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) |
There was a problem hiding this comment.
same code as above (line 190). A helper method will be better
There was a problem hiding this comment.
Thanks. Yes, forgot to remove the old code (line 190+).
|
--depends-on #5139 |
|
Thanks for removing the code. |
|
Yes, @will-moore suggested a follow-up PR for that problem, too #5023 (comment) |
|
@dominikl so I missed it in the long thread. I will add a card |

What this PR does
Show the number of annotations available in the right hand side panel.
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