bluesky / event-model

data model for event-based data collection and analysis
https://blueskyproject.io/event-model
BSD 3-Clause "New" or "Revised" License
15 stars 31 forks source link

ComposeStreamBundle.compose_stream_datum: `AttributeError: 'dict' object has no attribute 'compose_stream_datum'` #300

Closed stan-dot closed 6 months ago

stan-dot commented 6 months ago

Calling ComposeStreamBundle.compose_stream_datum with indices returns AttributeError: 'dict' object has no attribute 'compose_stream_datum'

Expected Behavior

I expect to be able to call each of the bundles and yield StreamDatum

Current Behavior

Method crashes with AttributeError: 'dict' object has no attribute 'compose_stream_datum'.

One thing I might be doing differently is that as per the deprecation notice of compose_stream_resource I am using the class variant.

Possible Solution

Not sure

Steps to Reproduce (for bugs)

this pull request and test_streaming_plan.py or: `from pathlib import Path from typing import Iterator from event_model import ( ComposeStreamResource, ComposeStreamResourceBundle, StreamDatum, StreamRange, )

def main(): bundler_composer = ComposeStreamResource()

path: Path = Path("root")
bundle: ComposeStreamResourceBundle = bundler_composer(
    spec="test",
    root="root",
    resource_path=str(path),
    data_key="name",
    resource_kwargs={
        "path": str(path.as_posix()),
        "multiplier": 1,
        "timestamps": "/entry/instrument/NDAttributes/NDArrayTimeStamp",
    },
)
indices_range = StreamRange(start=0, stop=1)

def compose(b: ComposeStreamResourceBundle):
    yield b.compose_stream_datum(indices_range)

iterator: Iterator[StreamDatum] = [compose(b) for b in [bundle]]
print(iterator)

if name == "main": main() `

Context

Trying to set up a simulated h5py writer for ophyd-async issue https://github.com/bluesky/ophyd-async/issues/131

Your Environment

python 3.9

stan-dot commented 6 months ago

resolved: compose... for d in datasets creates an array of 2 composed, while the theoretically equivalent for d in datasets: bundle = compose ... \n bundles += bundle creates an array 4 items, decomposing the bundle