bluesky_tiled_plugins.exporters#

Module Contents#

Functions#

build_descriptor_docs

Reconstruct the sequence of EventDescriptor documents for a single stream from the raw metadata dictionary cached on its Tiled node.

json_seq_exporter

Export BlueskyRun as newline-delimited sequence of JSON documents.

API#

bluesky_tiled_plugins.exporters.build_descriptor_docs(raw_metadata, stream_name, run_start_uid=None)#

Reconstruct the sequence of EventDescriptor documents for a single stream from the raw metadata dictionary cached on its Tiled node.

The stored metadata on a Tiled node is user-arbitrary, so this helper narrows the raw metadata down to the fields that make up a valid EventDescriptor document (per the event_model schema) and validates the result before returning it. Sharing this assembly logic between the JSON-Seq exporter and the client descriptors properties keeps their output byte-identical.

Parameters

raw_metadata : dict The metadata() payload of the stream node. May contain arbitrary keys; only the ones defined by the EventDescriptor schema are consumed. Any _config_updates list is unfolded into subsequent descriptor documents. stream_name : str The name field to place on every reconstructed descriptor. run_start_uid : str or None The UID of the RunStart document that owns this stream. When supplied, it is written to run_start on every descriptor.

Returns

list of dict One or more descriptor documents validated against the event_model EventDescriptor schema.

async bluesky_tiled_plugins.exporters.json_seq_exporter(mimetype, adapter, metadata, filter_for_access)#

Export BlueskyRun as newline-delimited sequence of JSON documents.

This callback is to be configured on the server-side to enable exporting BlueskyRun objects in JSON-Seq format.

The resulting stream yields strings, each of which is a JSON document representing one of the standard Bluesky documents: start, descriptor, event, stream_resource, stream_datum, and stop, in the appropriate order.

For example:

{"name": "start", "doc": {...}}
{"name": "descriptor", "doc": {...}}
{"name": "event", "doc": {...}}
{"name": "stream_resource", "doc": {...}}
{"name": "stream_datum", "doc": {...}}
...
{"name": "stop", "doc": {...}}