Callbacks (includes File Writers)

Callbacks

Document Collector

DocumentCollectorCallback()

Bluesky callback to collect all documents from most-recent plan

document_contents_callback(key, doc)

prints document contents -- use for diagnosing a document stream

class apstools.callbacks.doc_collector.DocumentCollectorCallback[source]

Bluesky callback to collect all documents from most-recent plan

Will reset when it receives a start document.

EXAMPLE:

from apstools.callbacks import DocumentCollectorCallback
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

apstools.callbacks.doc_collector.document_contents_callback(key, doc)[source]

prints document contents – use for diagnosing a document stream

Snapshot Report

SnapshotReport(*args, **kwargs)

Show the data from a apstools.plans.snapshot().

class apstools.callbacks.snapshot_report.SnapshotReport(*args: Any, **kwargs: Any)[source]

Show the data from a apstools.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
apstools.callbacks.SnapshotReport().print_report(h)

Use as callback to a snapshot plan:

RE(
    apstools.plans.snapshot(ophyd_objects_list),
    apstools.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

File Writers

See the File Writers section.