Task #11939 (closed)
Opened 10 years ago
Closed 9 years ago
Can't delete annotated OriginalFile Annotations
Reported by: | spli | Owned by: | mtbcarroll |
---|---|---|---|
Priority: | minor | Milestone: | 5.1.0-m3 |
Component: | OmeroPy | Version: | 5.1.0-m0 |
Keywords: | n.a. | Cc: | fs@… |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | n.a. |
Sprint: | n.a. |
Description
conn.deleteObjects fails in the following example, as does attempting to delete the FileAnnotation? in OMERO.web. This can be worked-around by deleting the OriginalFileAnnotationLink?, but this obviously won't help anyone deleting via the web.
import omero, omero.gateway from omero.rtypes import wrap, unwrap cli = omero.client('localhost') sess = cli.createSession('user', 'pass') conn = omero.gateway.BlitzGateway(client_obj=cli) us = conn.getUpdateService() res = sess.sharedResources() tag = omero.model.TagAnnotationI() tag.setNs(wrap('version')) tag.setTextValue(wrap('1.2')) tag = us.saveAndReturnObject(tag) project = omero.model.ProjectI() project.setName(wrap('tmp')) project = us.saveAndReturnObject(project) pid = unwrap(project.getId()) project = conn.getObject('Project', pid) table = res.newTable(0, '/test.h5') table.initialize([omero.grid.LongColumn('lc')]) oid = unwrap(table.getOriginalFile().id) # Attach a tag annotation to a table tagAnnLink = omero.model.OriginalFileAnnotationLinkI() tagAnnLink.link(omero.model.OriginalFileI(oid, False), tag) tagAnnLink = us.saveAndReturnObject(tagAnnLink) # Attach the table to a project fileAnn = omero.model.FileAnnotationI() fileAnn.setFile(omero.model.OriginalFileI(oid, False)) fileAnn.setNs(wrap('attachment')) fileAnn.setDescription(wrap('table attachment')) fileAnnLink = omero.model.ProjectAnnotationLinkI() fileAnnLink.link(omero.model.ProjectI(pid, False), fileAnn) fileAnnLink = us.saveAndReturnObject(fileAnnLink) # List the annotations on the table tableFile = conn.getObject('OriginalFile', oid) anns = list(tableFile.listAnnotations()) print anns # Delete the table handle = conn.deleteObjects('OriginalFile', [tableFile.id], True, True) conn._waitOnCmd(handle) # Throws an exception: #Exception: object #0 (::omero::cmd::GraphConstraintERR){ # category = ::omero::cmd::Delete name = STEP ERR # parameters = # { # key = step # value = 0 # # key = stacktrace # value = ome.services.graphs.GraphConstraintException(message=FileAnnotation:1254 improperly linked by 1 objects # ...
Change History (9)
comment:1 Changed 10 years ago by spli
- Cc fs@… added; python-team@… removed
comment:2 Changed 10 years ago by spli
comment:3 Changed 10 years ago by jamoore
- Milestone changed from Unscheduled to 5.1.0-m1
- Owner set to mtbcarroll
I'd think this should be tackled along with the graph reworking at the latest; or if that's not required, even in the 5.0 line.
comment:4 Changed 10 years ago by mtbcarroll
This is related to AnnotationGraphSpec magic.
comment:5 Changed 10 years ago by mtbcarroll
- Milestone changed from 5.1.0-m1 to 5.1.0-m3
Colin: Could you turn this into a @xfail integration test for me?
comment:6 Changed 10 years ago by jburel
- Milestone changed from 5.1.0-m3 to 5.1.0-m4
comment:7 Changed 9 years ago by mtbcarroll
After the graph reworking, deleting the OriginalFile succeeds and also removes the tag and file annotations.
comment:8 Changed 9 years ago by mtbcarroll
- Milestone changed from 5.1.0-m4 to 5.1.0-m3
- Status changed from new to accepted
comment:9 Changed 9 years ago by mtbcarroll
- Resolution set to fixed
- Status changed from accepted to closed
Now fixed by https://github.com/openmicroscopy/openmicroscopy/pull/3228. Simon, to prevent regressions you may want to add your code from the description as a test in gatewaytest/test_delete.py.
Note #11944 doesn't fix this.