bluesky / suitcase-core

data export facilities for NSLS-II
https://blueskyproject.io/suitcase
Other
2 stars 13 forks source link

streaming example refers to older version (pre 1.14) #78

Open whs92 opened 3 years ago

whs92 commented 3 years ago

To implement streaming export the documentation suggests the following:

from event_model import RunRouter
from suitcase.specfile import Serializer

def factory(name, start_doc):

    serializer = Serializer('path/to/files')
    serializer('start', start_doc)

    return [serializer], []

rr = RunRouter([factory])

RE.subscribe(rr)

However, this throws the following error:

UserWarning: The callback <suitcase.specfile.Serializer object at 0x7f6f4e8b7430> raised SuitcaseUtilsValueError("The postfix '773fcfd4-ce45-4e3c-83d9-f673d4b891c4.spec' has already been used.") when RunRouter passed it a 'start' document. This is probably because in earlier releases the RunRouter expected its factory functions to forward the 'start' document, but starting in event-model 1.14.0 the RunRouter passes in the document, causing the callback to receive it twice and potentially raise an error. Update the factory function. In a future release this warning will become an error.

Removing the line

serializer('start', start_doc)

Seems to solve the error. I don't understand why, but the documentation should reflect this.