Skip to content

Commit

Permalink
Made HDF writer write layout xml to file
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Feb 15, 2017
1 parent b317177 commit ec71592
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions malcolm/parts/ADCore/hdfwriterpart.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions tests/test_parts/test_ADCore/test_hdfwriterpart.py
Expand Up @@ -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())
Expand All @@ -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 = {
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -159,9 +160,11 @@ def test_configure(self):
</group>
</group>
</hdf5_layout>"""
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()
Expand Down

0 comments on commit ec71592

Please sign in to comment.