bluesky / ophyd-async

Hardware abstraction for bluesky written using asyncio
https://blueskyproject.io/ophyd-async
BSD 3-Clause "New" or "Revised" License
12 stars 26 forks source link

StandardDetectors/StreamResource only devices still create empty Events when used in a plan #620

Closed DiamondJoseph closed 4 days ago

DiamondJoseph commented 1 month ago

When running the count plan from bluesky.plan_stubs with the SimPatternDetector as the only Readable to be collected, I receive StreamResources for the detector's 2 datasets, StreamDatums 2*N (where N is the number of points collected, and 2 is the number of StreamResources) and N Event documents.

The event documents are blank, and if I was running a plan over a very large N very quickly, where StreamDatums are emitted at 10Hz, may overwhelm the total number of messages with uselessness.

{'uid': 'eec7b51b-273f-4732-9e5e-e946e7ab4684', 'time': 1729605127.4888647, 'data': {}, 'timestamps': {}, 'seq_num': 1, 'filled': {}, 'descriptor': '74d4f749-a46f-4aef-8512-6a1a2ed41ba7'}
@pytest.fixture
def det(RE: RunEngine, tmp_path: Path) -> StandardDetector:
    with DeviceCollector(mock=True):
        det = PatternDetector(tmp_path / "foo.h5")
    return det

def test_multi_count_output(det: StandardDetector, path_provider, RE):
    docs: dict[str, list[DocumentType]] = {}
    RE(
        count({det}, num=3),
        lambda name, doc: docs.setdefault(name, []).append(doc),
    )
    assert "event" in docs
coretl commented 1 month ago

This is not ophyd-async, this is bluesky. It is also step-scan only. count will always make an Event, even if empty. As we don't expect to be running step scans faster than 10Hz then is this a problem?

coretl commented 4 days ago

@DiamondJoseph is this a problem?

DiamondJoseph commented 4 days ago

It's just inelegant :(