Stack Trace
self = <test.integration.gatewaytest.test_get_objects.TestGetObject object at 0x7fb460f46550>
gatewaywrapper = <omero.gateway.pytest_fixtures.GatewayWrapper object at 0x7fb475fda590>
author_testimg_tiny = <_ImageWrapper id=5744>
def testGetAnnotations(self, gatewaywrapper, author_testimg_tiny):
obj = author_testimg_tiny
dataset = gatewaywrapper.getTestDataset()
ns = "omero.gateway.test.get_objects.test_get_annotations_comment"
ns_tag = "omero.gateway.test.get_objects.test_get_annotations_tag"
# create Comment
ann = omero.gateway.CommentAnnotationWrapper(gatewaywrapper.gateway)
ann.setNs(ns)
ann.setValue("Test Comment")
ann = obj.linkAnnotation(ann)
# create Tag
tag = omero.gateway.TagAnnotationWrapper(gatewaywrapper.gateway)
tag.setNs(ns_tag)
tag.setValue("Test Tag")
tag = obj.linkAnnotation(tag)
dataset.linkAnnotation(tag)
# also link the Tag to the Comment
ann.linkAnnotation(tag)
# get the Comment
annotation = gatewaywrapper.gateway.getObject(
"CommentAnnotation", ann.id)
assert "Test Comment" == annotation.textValue
assert ann.OMERO_TYPE == annotation.OMERO_TYPE
# test getObject throws exception if more than 1 returned
threw = True
try:
gatewaywrapper.gateway.getObject("Annotation")
threw = False
except Exception:
threw = True
assert threw, "getObject() didn't throw exception with >1 result"
# get the Comment and Tag
annGen = gatewaywrapper.gateway.getObjects(
"Annotation", [ann.id, tag.id])
anns = list(annGen)
assert len(anns) == 2
assert anns[0].ns in [ns, ns_tag]
assert anns[1].ns in [ns, ns_tag]
assert anns[0].OMERO_TYPE != anns[1].OMERO_TYPE
# get all available annotation links on the image
annLinks = gatewaywrapper.gateway.getAnnotationLinks("Image")
for al in annLinks:
assert isinstance(al.getAnnotation(),
omero.gateway.AnnotationWrapper)
assert al.parent.__class__ == omero.model.ImageI
# get selected links - On image only
annLinks = gatewaywrapper.gateway.getAnnotationLinks(
"Image", parent_ids=[obj.getId()])
for al in annLinks:
assert obj.getId() == al.parent.id.val
assert al.parent.__class__ == omero.model.ImageI
# get selected links - On image only
annLinks = gatewaywrapper.gateway.getAnnotationLinks(
"Image", parent_ids=[obj.getId()])
for al in annLinks:
assert obj.getId() == al.parent.id.val
assert al.parent.__class__ == omero.model.ImageI
# Check links to Tag on the Comment
for obj_type in ["CommentAnnotation", "Annotation"]:
> annLinks = list(gatewaywrapper.gateway.getAnnotationLinks(
obj_type, parent_ids=[ann.getId()]))
test/integration/gatewaytest/test_get_objects.py:598:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <omero.gateway._BlitzGateway object at 0x7fb415c8d650>
parent_type = 'Annotation', parent_ids = [5290], ann_ids = None, ns = None
params = None
def getAnnotationLinks(self, parent_type, parent_ids=None, ann_ids=None,
ns=None, params=None):
"""
Retrieve Annotation Links by parent_type E.g. "Image". Not Ordered.
Returns generator of :class:`AnnotationLinkWrapper`
If parent_ids is None, all available objects will be returned.
i.e. listObjects()
:param obj_type: Object type, e.g. "Project" see above
:type obj_type: String
:param ids: object IDs
:type ids: List of Long
:return: Generator yielding wrapped objects.
"""
if parent_type.lower() not in KNOWN_WRAPPERS:
wrapper_types = ", ".join(list(KNOWN_WRAPPERS.keys()))
err_msg = ("getAnnotationLinks() does not support type: '%s'. "
"Must be one of: %s" % (parent_type, wrapper_types))
raise AttributeError(err_msg)
wrapper = KNOWN_WRAPPERS.get(parent_type.lower(), None)
> link_name = wrapper.ann_link_name()
^^^^^^^^^^^^^^^^^^^^^
E AttributeError: 'function' object has no attribute 'ann_link_name'
../../../../.venv3/lib64/python3.11/site-packages/omero/gateway/__init__.py:3556: AttributeError