We are building a number of tools around OMERO using Python and rely heavily on ephemeral OMERO instances for testing. While it is possible to import test data for testing purposes, we would prefer to keep the test data very simple and generated by the test code itself as pytest fixtures.
Right now I am trying to figure out how to create a “minimal” screen that consists of one screen, one plate, one well, one well sample and one image. My code seems to work all the way up through the WellSample step and then I get errors. I am wondering if you can give me some direction.
The code (imports not shown here, but assume that I have done them correctly ):
# Create Screen screen_name = "screen_" + timestamp screen = ScreenWrapper(conn, ScreenI()) screen.setName(screen_name) screen.save() screen_id = screen.getId() # Create Plate plate_name = "plate_" + timestamp plate = PlateWrapper(conn, PlateI()) plate.setName(plate_name) plate.save() plate_id = plate.getId() link = ScreenPlateLinkI() link.setParent(ScreenI(screen_id, False)) link.setChild(PlateI(plate_id, False)) conn.getUpdateService().saveObject(link) # Create Well well = WellWrapper(conn, WellI()) well.setColumn(rint(1)) well.setRow(rint(1)) well.setPlate(PlateI(plate_id, False)) well.save() # plate.addWell(WellI(well.getId(), False)) # Create Well Sample with Image ws = WellSampleWrapper(conn, WellSampleI()) ws.setWell(WellI(well.getId(), False)) ws.setPosX(LengthI(0, UnitsLength.PIXEL)) ws.setPosY(LengthI(0, UnitsLength.PIXEL)) ws.setImage(ImageI(im_id1, False)) # im_id1 comes from an image fixture ws.save() # well.addWellSample(WellSampleI(ws.getId(), False))
The error is quite long, but seems to boil down to this:
message = Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException): Exception occurred inside getter of ome.model.screen.Well.wellSamples; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of ome.model.screen.Well.wellSamples }
I can send the full trace if that is useful, but I expect I am just missing something simple. Any direction would be helpful!
Also, I have a couple of lines commented there…are those necessary?
# plate.addWell(WellI(well.getId(), False))
# well.addWellSample(WellSampleI(ws.getId(), False))