Callbacks

Callbacks that might be useful at the APS using BlueSky

document_contents_callback(key, doc) prints document contents – use for diagnosing a document stream
DocumentCollectorCallback() BlueSky callback to collect all documents from most-recent plan
SnapshotReport(*args, **kwargs) show the data from a APS_BlueSky_Tools.plans.snapshot()

FILE WRITER CALLBACK

see SpecWriterCallback()

class APS_BlueSky_tools.callbacks.DocumentCollectorCallback[source]

BlueSky callback to collect all documents from most-recent plan

Will reset when it receives a start document.

EXAMPLE:

from APS_BlueSky_tools.callbacks import DocumentCollector
doc_collector = DocumentCollectorCallback()
RE.subscribe(doc_collector.receiver)
...
RE(some_plan())
print(doc_collector.uids)
print(doc_collector.documents["stop"])
receiver(key, document)[source]

keep all documents from recent plan in memory

class APS_BlueSky_tools.callbacks.SnapshotReport(*args, **kwargs)[source]

show the data from a APS_BlueSky_Tools.plans.snapshot()

Find most recent snapshot between certain dates:

headers = db(plan_name="snapshot", since="2018-12-15", until="2018-12-21")
h = list(headers)[0]        # pick the first one, it's the most recent
APS_BlueSky_Tools.callbacks.SnapshotReport().print_report(h)

Use as callback to a snapshot plan:

RE(
    APS_BlueSky_Tools.plans.snapshot(ophyd_objects_list),
    APS_BlueSky_Tools.callbacks.SnapshotReport()
)
descriptor(doc)[source]
special case:
the data is both in the descriptor AND the event docs due to the way our plan created it
print_report(header)[source]

simplify the job of writing our custom data table

method: play the entire document stream through this callback

APS_BlueSky_tools.callbacks.document_contents_callback(key, doc)[source]

prints document contents – use for diagnosing a document stream