Skip to content

Commit

Permalink
Merge pull request #1 from mrakitin/fix-compose_stream_resource-api
Browse files Browse the repository at this point in the history
Fix `compose_stream_resource` calls
  • Loading branch information
jwlodek authored Jun 11, 2024
2 parents 65fac47 + f0ec761 commit 1b8b510
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
7 changes: 3 additions & 4 deletions src/ophyd_async/epics/areadetector/writers/_hdffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ def __init__(
self._last_emitted = 0
self._bundles = [
compose_stream_resource(
spec="AD_HDF5_SWMR_SLICE",
root=str(path_info.root),
mimetype="application/x-hdf5",
uri=f"file://localhost{full_file_name}",
data_key=ds.name,
resource_path=str(full_file_name.relative_to(path_info.root)),
resource_kwargs={
parameters={
"path": ds.path,
"multiplier": ds.multiplier,
"timestamps": "/entry/instrument/NDAttributes/NDArrayTimeStamp",
Expand Down
3 changes: 2 additions & 1 deletion src/ophyd_async/panda/writers/_hdf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ async def collect_stream_docs(
if not self._file:
self._file = _HDFFile(
self._path_provider(),
Path(await self.panda_device.data.hdf_file_name.get_value()),
Path(await self.panda_device.data.hdf_directory.get_value())
/ Path(await self.panda_device.data.hdf_file_name.get_value()),
self._datasets,
)
for doc in self._file.stream_resources():
Expand Down
7 changes: 3 additions & 4 deletions src/ophyd_async/panda/writers/_panda_hdf_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ def __init__(
self._last_emitted = 0
self._bundles = [
compose_stream_resource(
spec="AD_HDF5_SWMR_SLICE",
root=str(path_info.root),
mimetype="application/x-hdf5",
uri=f"file://localhost{path_info.root / full_file_name}",
data_key=ds.name,
resource_path=(f"{str(path_info.root)}/{full_file_name}"),
resource_kwargs={
parameters={
"name": ds.name,
"block": ds.block,
"path": ds.path,
Expand Down
9 changes: 3 additions & 6 deletions src/ophyd_async/sim/pattern_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,16 @@ def _compose_bundles(
full_file_name: Path,
datasets: List[DatasetConfig],
) -> List[StreamAsset]:
path = str(full_file_name.relative_to(path_info.root))
root = str(path_info.root)
bundler_composer = ComposeStreamResource()

bundles: List[ComposeStreamResourceBundle] = []

bundles = [
bundler_composer(
spec=SLICE_NAME,
root=root,
resource_path=path,
mimetype="application/x-hdf5",
uri=f"file://{full_file_name}",
data_key=d.name.replace("/", "_"),
resource_kwargs={
parameters={
"path": d.path,
"multiplier": d.multiplier,
"timestamps": "/entry/instrument/NDAttributes/NDArrayTimeStamp",
Expand Down
7 changes: 3 additions & 4 deletions tests/core/test_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ async def collect_stream_docs(
if indices_written:
if not self._file:
self._file = compose_stream_resource(
spec="AD_HDF5_SWMR_SLICE",
root="/",
mimetype="application/x-hdf5",
uri="file://",
data_key=self._name,
resource_path="",
resource_kwargs={
parameters={
"path": "",
"multiplier": 1,
"timestamps": "/entry/instrument/NDAttributes/NDArrayTimeStamp",
Expand Down
7 changes: 3 additions & 4 deletions tests/plan_stubs/test_fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ async def collect_stream_docs(
if indices_written:
if not self._file:
self._file = compose_stream_resource(
spec="AD_HDF5_SWMR_SLICE",
root="/",
mimetype="application/x-hdf5",
uri="file://",
data_key=self._name,
resource_path="",
resource_kwargs={
parameters={
"path": "",
"multiplier": 1,
"timestamps": "/entry/instrument/NDAttributes/NDArrayTimeStamp",
Expand Down

0 comments on commit 1b8b510

Please sign in to comment.