Stack Trace
self = <test_api_annotations.TestAnnotations object at 0x7f8388aa1a50>
user1 = (<omero.clients.BaseClient object at 0x7f83777e9a50>, object #0 (::omero::model::Experimenter)
{
_id = object #1 (...nnotationLinksSeq =
{
}
_annotationLinksLoaded = False
_annotationLinksCountPerOwner =
{
}
})
@pytest.fixture()
def dataset_anns(self, user1):
"""Create a bunch of Annotations."""
conn = BlitzGateway(client_obj=user1[0])
update = conn.getUpdateService()
def create_dataset_with_annotations(name, dtype="Dataset"):
if dtype == "Dataset":
obj = DatasetI()
obj.name = wrap(name)
obj = update.saveAndReturnObject(obj)
wrapper = DatasetWrapper(conn, obj)
elif dtype == "Project":
obj = ProjectI()
obj.name = wrap(name)
obj = update.saveAndReturnObject(obj)
wrapper = ProjectWrapper(conn, obj)
# Create total of 10 annotations on the object...
# create Comment, Tag, Xml, etc
for ann_type in self.ann_types:
ann = getattr(omero.gateway, ann_type + "Wrapper")(conn)
ann.setNs(self.ns)
if ann_type in ("LongAnnotation", "DoubleAnnotation",
"TimestampAnnotation"):
ann.setValue(100.0)
elif ann_type == "BooleanAnnotation":
ann.setValue(True)
else:
ann.setValue("Test %s: %s" % (ann_type, name))
wrapper.linkAnnotation(ann)
# create MapAnnotation
mapAnn = omero.gateway.MapAnnotationWrapper(conn)
mapAnn.setValue([("key1", "value1"), ("key2", "value2")])
mapAnn.setNs(self.ns_map)
mapAnn.save()
wrapper.linkAnnotation(mapAnn)
# create FileAnnotation
fileAnn = FileAnnotationWrapper(conn)
fileObj = OriginalFileI()
fileObj = OriginalFileWrapper(conn, fileObj)
fileObj.setName(wrap("fileName"))
fileObj.setPath(wrap("path/to/file"))
fileObj.setHash(wrap("a"))
fileObj.setSize(omero.rtypes.rlong(0))
fileObj.save()
fileAnn.setFile(fileObj)
fileAnn.setNs(self.ns_file)
fileAnn.save()
wrapper.linkAnnotation(fileAnn)
return wrapper
dataset1 = create_dataset_with_annotations("Dataset 1")
dataset2 = create_dataset_with_annotations("Dataset 2")
project1 = create_dataset_with_annotations("Project 1",
dtype="Project")
# Also add Tag to the Group
tag = TagAnnotationWrapper(conn)
tag.setNs("test_get_objects_group_tag")
tag.setValue("Test Tag on Group")
group = conn.getGroupFromContext()
> group.linkAnnotation(tag)
test/integration/test_api_annotations.py:127:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../.venv3/lib64/python3.11/site-packages/omero/gateway/__init__.py:1158: in linkAnnotation
ann = self._linkAnnotation(ann)
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.venv3/lib64/python3.11/site-packages/omero/gateway/__init__.py:1090: in _linkAnnotation
return self._linkObject(ann, "%sI" % link_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExperimenterGroupWrapper id=3276>
obj = <omero.gateway.TagAnnotationWrapper object at 0x7f83779969d0>
lnkobjtype = 'ExperimenterGroupAnnotationLinkI'
def _linkObject(self, obj, lnkobjtype):
"""
Saves the object to DB if needed - setting the permissions manually.
Creates the object link and saves it, setting permissions manually.
TODO: Can't set permissions manually in 4.2
- Assumes world & group writable
:param obj: The object to link
:type obj: :class:`BlitzObjectWrapper`
"""
ctx = self._conn.SERVICE_OPTS.copy()
> ctx.setOmeroGroup(self.details.group.id.val)
^^^^^^^^^^^^^^^^^^^^^
E AttributeError: 'NoneType' object has no attribute 'id'
../../../../.venv3/lib64/python3.11/site-packages/omero/gateway/__init__.py:1066: AttributeError