Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include chunk shape as a parameter in stream resource for HDF dataset #544

Merged
merged 32 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2202413
Adding record for num frames in chunk along with chunk_size field in …
jwlodek Aug 28, 2024
02332c3
Attributes are saved all in a single chunk
jwlodek Aug 28, 2024
561da46
Update tests to account for chunk_size datakey parameter
jwlodek Aug 28, 2024
edc8f1c
Chunk size should be in sres not desc
jwlodek Aug 28, 2024
3cfb4e7
Move chunk size to sres parameters
jwlodek Aug 28, 2024
8117e4b
Refactor tests to reflect changes
jwlodek Aug 28, 2024
3313d1a
Merge branch 'main' of https://github.com/bluesky/ophyd-async into ch…
jwlodek Sep 4, 2024
ada0b15
chunk size can be int or none
jwlodek Sep 4, 2024
a835183
Update chunk size signal to non-zero in one of the AD test sets
jwlodek Sep 4, 2024
31dfcb1
Merge branch 'main' of https://github.com/bluesky/ophyd-async into ch…
jwlodek Sep 5, 2024
54e42f0
Use correct chunk size for PandA, make sure we use chunk size auto
jwlodek Sep 5, 2024
ad8b63f
Add comment on chunk size
jwlodek Sep 5, 2024
9856e2e
Make chunk_size a tuple that explicitly describes all chunk dims
jwlodek Sep 5, 2024
386e61b
Make sure chunk size is tuple even with one dim, update tests, simpli…
jwlodek Sep 9, 2024
415c398
Make chunk_size always tuple of int, default to empty tuple
jwlodek Sep 9, 2024
deec8d1
Merge branch 'main' into chunk-size-in-sres
jwlodek Sep 9, 2024
5ad4b7a
Use readback value to avoid disconnect between actual value and signa…
jwlodek Sep 9, 2024
09b51b3
Merge branch 'chunk-size-in-sres' of https://github.com/jwlodek/ophyd…
jwlodek Sep 9, 2024
578969c
Follow import convention for tests
jwlodek Sep 10, 2024
00275f3
Make use of slicing for detector name in ad_standard_det_factory clearer
jwlodek Sep 10, 2024
025ac06
Merge branch 'main' into chunk-size-in-sres
jwlodek Sep 10, 2024
1600a2c
Rename chunk size to chunk shape
jwlodek Sep 16, 2024
4a76859
Merge branch 'main' into chunk-size-in-sres
jwlodek Sep 16, 2024
f105e34
Add space for linting
jwlodek Sep 16, 2024
395b58b
Merge branch 'chunk-size-in-sres' of https://github.com/jwlodek/ophyd…
jwlodek Sep 16, 2024
3821fc6
Merge branch 'main' of https://github.com/bluesky/ophyd-async into ch…
jwlodek Sep 17, 2024
398ac01
Fix test
jwlodek Sep 17, 2024
9e28151
Merge with upstream
jwlodek Sep 18, 2024
0bd5ba2
Fix merge conflict
jwlodek Sep 18, 2024
4d01dae
Simplifying ad standard det factory fixture
jwlodek Sep 18, 2024
4f15ac1
Fix unawaited task issue
jwlodek Sep 18, 2024
4d4e12e
kinetix fixture doesn't need to be async
jwlodek Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ophyd_async/core/_hdf_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class HDFDataset:
dtype_numpy: str = ""
multiplier: int = 1
swmr: bool = False
chunk_size: int | None = None


SLICE_NAME = "AD_HDF5_SWMR_SLICE"
Expand Down Expand Up @@ -65,6 +66,7 @@ def __init__(
"dataset": ds.dataset,
"swmr": ds.swmr,
"multiplier": ds.multiplier,
"chunk_size": ds.chunk_size,
},
uid=None,
validate=True,
Expand Down
1 change: 1 addition & 0 deletions src/ophyd_async/epics/adcore/_core_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ def __init__(self, prefix: str, name="") -> None:
self.array_size0 = epics_signal_r(int, prefix + "ArraySize0")
self.array_size1 = epics_signal_r(int, prefix + "ArraySize1")
self.create_directory = epics_signal_rw(int, prefix + "CreateDirectory")
self.num_frames_chunks = epics_signal_rw(int, prefix + "NumFramesChunks")
super().__init__(prefix, name)
4 changes: 4 additions & 0 deletions src/ophyd_async/epics/adcore/_hdf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ async def open(self, multiplier: int = 1) -> Dict[str, DataKey]:
self._multiplier = multiplier
outer_shape = (multiplier,) if multiplier > 1 else ()

# Determine number of frames that will be saved per HDF chunk
frames_per_chunk = await self.hdf.num_frames_chunks.get_value()

# Add the main data
self._datasets = [
HDFDataset(
Expand All @@ -91,6 +94,7 @@ async def open(self, multiplier: int = 1) -> Dict[str, DataKey]:
shape=detector_shape,
dtype_numpy=np_dtype,
multiplier=multiplier,
chunk_size=frames_per_chunk,
)
]
# And all the scalar datasets
Expand Down
1 change: 1 addition & 0 deletions tests/epics/adaravis/test_aravis.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ async def test_can_collect(
"dataset": "/entry/data/data",
"swmr": False,
"multiplier": 1,
"chunk_size": 0,
genematx marked this conversation as resolved.
Show resolved Hide resolved
jwlodek marked this conversation as resolved.
Show resolved Hide resolved
}
assert docs[1][0] == "stream_datum"
stream_datum = docs[1][1]
Expand Down
4 changes: 4 additions & 0 deletions tests/epics/adkinetix/test_kinetix.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ async def test_adkinetix(
async with DeviceCollector(mock=True):
test_adkinetix = adkinetix.KinetixDetector("KINETIX:", static_path_provider)

# Set number of frames per chunk to something reasonable
set_mock_value(test_adkinetix.hdf.num_frames_chunks, 10)

return test_adkinetix


Expand Down Expand Up @@ -105,6 +108,7 @@ async def test_can_collect(
"dataset": "/entry/data/data",
"swmr": False,
"multiplier": 1,
"chunk_size": 10,
}
assert docs[1][0] == "stream_datum"
stream_datum = docs[1][1]
Expand Down
1 change: 1 addition & 0 deletions tests/epics/advimba/test_vimba.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async def test_can_collect(
"dataset": "/entry/data/data",
"swmr": False,
"multiplier": 1,
"chunk_size": 0,
jwlodek marked this conversation as resolved.
Show resolved Hide resolved
}
assert docs[1][0] == "stream_datum"
stream_datum = docs[1][1]
Expand Down
1 change: 1 addition & 0 deletions tests/fastcs/panda/test_hdf_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def assert_resource_document():
"dataset": f"/{dataset_name}",
"swmr": False,
"multiplier": 1,
"chunk_size": None,
jwlodek marked this conversation as resolved.
Show resolved Hide resolved
},
}
assert "test-panda.h5" in stream_resource["uri"]
Expand Down
7 changes: 6 additions & 1 deletion tests/fastcs/panda/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ def assert_resource_document(name, resource_doc):
"data_key": name,
"mimetype": "application/x-hdf5",
"uri": "file://localhost" + str(tmp_path / "mock_panda" / "data.h5"),
"parameters": {"dataset": f"/{name}", "swmr": False, "multiplier": 1},
"parameters": {
"dataset": f"/{name}",
"swmr": False,
"multiplier": 1,
"chunk_size": None,
},
}
assert "mock_panda/data.h5" in resource_doc["uri"]

Expand Down