From 8273a2e0980fc586db38abb15fc6d354e0d40e68 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Wed, 31 Jul 2024 09:16:44 -0400 Subject: [PATCH] AD HDF plugin should set directory creation value before path (#497) --- src/ophyd_async/epics/adcore/_hdf_writer.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ophyd_async/epics/adcore/_hdf_writer.py b/src/ophyd_async/epics/adcore/_hdf_writer.py index fa8ca03f04..b06bdb368b 100644 --- a/src/ophyd_async/epics/adcore/_hdf_writer.py +++ b/src/ophyd_async/epics/adcore/_hdf_writer.py @@ -51,16 +51,19 @@ def __init__( async def open(self, multiplier: int = 1) -> Dict[str, DataKey]: self._file = None info = self._path_provider(device_name=self.hdf.name) - file_path = info.directory_path + + # Set the directory creation depth first, since dir creation callback happens + # when directory path PV is processed. + await self.hdf.create_directory.set(info.create_dir_depth) + await asyncio.gather( self.hdf.num_extra_dims.set(0), self.hdf.lazy_open.set(True), self.hdf.swmr_mode.set(True), # See https://github.com/bluesky/ophyd-async/issues/122 - self.hdf.file_path.set(file_path), + self.hdf.file_path.set(info.directory_path), self.hdf.file_name.set(info.filename), self.hdf.file_template.set("%s/%s.h5"), - self.hdf.create_directory.set(info.create_dir_depth), self.hdf.file_write_mode.set(FileWriteMode.stream), # Never use custom xml layout file but use the one defined # in the source code file NDFileHDF5LayoutXML.cpp @@ -69,7 +72,7 @@ async def open(self, multiplier: int = 1) -> Dict[str, DataKey]: assert ( await self.hdf.file_path_exists.get_value() - ), f"File path {file_path} for hdf plugin does not exist" + ), f"File path {info.directory_path} for hdf plugin does not exist" # Overwrite num_capture to go forever await self.hdf.num_capture.set(0)