def test_via_OpExportSlot(self): data = 255 * numpy.random.random((64, 128, 128, 1)) data = data.astype(numpy.uint8) data = vigra.taggedView(data, vigra.defaultAxistags("zyxc")) graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue(data) opExport = OpExportSlot(graph=graph) opExport.Input.connect(opPiper.Output) opExport.OutputFormat.setValue("dvid") url = "http://{hostname}/api/node/{data_uuid}/{data_name}".format( **self.__dict__) opExport.OutputFilenameFormat.setValue(url) assert opExport.ExportPath.ready() assert opExport.ExportPath.value == url opExport.run_export() opRead = OpInputDataReader(graph=graph) try: opRead.FilePath.setValue(opExport.ExportPath.value) expected_data = data.view(numpy.ndarray) read_data = opRead.Output(*roiFromShape(data.shape)).wait() assert (read_data == expected_data ).all(), "Read data didn't match exported data!" finally: opRead.cleanUp()
def testBasic_Dvid(self): if _skip_dvid: raise nose.SkipTest # Spin up a mock dvid server to test with. dvid_dataset, data_uuid, data_name = "datasetA", "abcde", "indices_data" mockserver_data_file = self._tmpdir + '/mockserver_data.h5' with H5MockServerDataFile(mockserver_data_file) as test_h5file: test_h5file.add_node(dvid_dataset, data_uuid) server_proc, shutdown_event = H5MockServer.create_and_start( mockserver_data_file, "localhost", 8000, same_process=False, disable_server_logging=True) try: data = 255 * numpy.random.random((100, 100, 4)) data = data.astype(numpy.uint8) data = vigra.taggedView(data, vigra.defaultAxistags('xyc')) graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue(data) opExport = OpExportSlot(graph=graph) opExport.Input.connect(opPiper.Output) opExport.OutputFormat.setValue('dvid') url = 'http://localhost:8000/api/node/{data_uuid}/{data_name}'.format( **locals()) opExport.OutputFilenameFormat.setValue(url) assert opExport.ExportPath.ready() assert opExport.ExportPath.value == url opExport.run_export() try: opRead = OpInputDataReader(graph=graph) opRead.FilePath.setValue(opExport.ExportPath.value) expected_data = data.view(numpy.ndarray) read_data = opRead.Output(*roiFromShape(data.shape)).wait() assert (read_data == expected_data ).all(), "Read data didn't match exported data!" finally: opRead.cleanUp() finally: shutdown_event.set() server_proc.join()