diff --git a/malcolm/parts/ADCore/hdfwriterpart.py b/malcolm/parts/ADCore/hdfwriterpart.py index e957165cb..43186e1f3 100644 --- a/malcolm/parts/ADCore/hdfwriterpart.py +++ b/malcolm/parts/ADCore/hdfwriterpart.py @@ -98,7 +98,7 @@ def _create_dataset_infos(self, part_info, generator, filename): yield DatasetProducedInfo( name=name, filename=filename, type=type, rank=dataset_info.rank + generator_rank, - path= "/entry/%s/%s" % (dataset_info.name, dataset_info.name), + path="/entry/%s/%s" % (dataset_info.name, dataset_info.name), uniqueid=uniqueid) # Add any setpoint dimensions @@ -141,7 +141,10 @@ def configure(self, task, completed_steps, steps_to_do, part_info, params): fileTemplate="%s%s")) futures += self._set_dimensions(task, params.generator) xml = self._make_layout_xml(params.generator, part_info) - futures += task.put_async(self.child["xml"], xml) + layout_filename = os.path.join( + file_dir, "%s-layout.xml" % self.params.mri) + open(layout_filename, "w").write(xml) + futures += task.put_async(self.child["xml"], layout_filename) # Wait for the previous puts to finish task.wait_all(futures) # Reset numCapture back to 0 diff --git a/tests/test_parts/test_ADCore/test_hdfwriterpart.py b/tests/test_parts/test_ADCore/test_hdfwriterpart.py index ac8027b82..8d3b0bace 100644 --- a/tests/test_parts/test_ADCore/test_hdfwriterpart.py +++ b/tests/test_parts/test_ADCore/test_hdfwriterpart.py @@ -25,6 +25,7 @@ def getitem(name): self.child.__getitem__.side_effect = getitem self.params = MagicMock() + self.params.mri = "BLOCK-HDF5" self.process.get_block.return_value = self.child self.o = HDFWriterPart(self.process, self.params) list(self.o.create_attributes()) @@ -35,7 +36,7 @@ def test_configure(self): energy = LineGenerator("energy", "kEv", 13.0, 15.2, 2) spiral = SpiralGenerator(["x", "y"], "mm", [0., 0.], 5., scale=2.0) params.generator = CompoundGenerator([energy, spiral], [], []) - params.filePath = "/path/to/file.h5" + params.filePath = "/tmp/file.h5" completed_steps = 0 steps_to_do = 38 part_info = { @@ -92,7 +93,7 @@ def test_configure(self): dimAttDatasets=True, lazyOpen=True, arrayCounter=0, - filePath="/path/to/", + filePath="/tmp/", fileName="file.h5", fileTemplate="%s%s"))) self.assertEqual(task.put_many_async.call_args_list[1], @@ -159,9 +160,11 @@ def test_configure(self): """ + expected_filename = "/tmp/BLOCK-HDF5-layout.xml" self.assertEqual( - task.put_async.call_args_list[0][0][1].replace(">", ">\n").splitlines(), - expected_xml.splitlines()) + task.put_async.call_args_list[0][0][1], expected_filename) + actual_xml = open(expected_filename).read().replace(">", ">\n") + self.assertEqual(actual_xml.splitlines(), expected_xml.splitlines()) def test_run(self): task = MagicMock()