bluesky / event-model

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

Switch from `partials` to Compose classes #261

Closed evalott100 closed 1 year ago

evalott100 commented 1 year ago

Currently, compose functions return documents (a dict), and partials of further compose functions, all inside a Bundle:

https://github.com/bluesky/event-model/blob/86474f030294436d33be4ce6d64082a2fc0a8913/event_model/__init__.py#L2180-#L2196

Instead of namedtuple run bundles, and partials, we should use dataclasses, and compose classes of the form

class ComposeDatum:
    resource: Resource
    counter: int

    def __call__(self, uid:str) -> Datum:
        return Datum(uid=uid, resource=self.resource)

compose_datum = back_compat_wrapper(ComposeDatum)

# back_compat_wrapper will make something like:
# def compose_datum(resource, counter, uid) -> Datum:
#     return ComposeDatum(resource, counter)(uid)

Then nothing changes from the bluesky bundler level.

evalott100 commented 1 year ago

We should also change the DescriptorBundle to what is mentioned here.