def test_post_run(RE, hw, db): RE.subscribe(db.insert) output = defaultdict(list) def do_nothing(doctype, doc): output[doctype].append(doc) RE(stepscan(hw.det, hw.motor), {'stop': [post_run(do_nothing, db=db)]}) assert len(output) assert len(output['start']) == 1 assert len(output['stop']) == 1 assert len(output['descriptor']) == 1 assert len(output['event']) == 10
def test_post_run(fresh_RE, db): RE = fresh_RE RE.subscribe('all', db.mds.insert) output = defaultdict(list) def do_nothing(doctype, doc): output[doctype].append(doc) RE.ignore_callback_exceptions = False RE(stepscan(det, motor), subs={'stop': [post_run(do_nothing, db=db)]}) assert len(output) assert len(output['start']) == 1 assert len(output['stop']) == 1 assert len(output['descriptor']) == 1 assert len(output['event']) == 10
#!/opt/conda_envs/lsdc_dev3/bin/ipython -i import asyncio #from ophyd import setup_ophyd from ophyd import * setup_ophyd() # Subscribe metadatastore to documents. # If this is removed, data is not saved to metadatastore. import metadatastore.commands from bluesky.global_state import gs gs.RE.subscribe_lossless('all', metadatastore.commands.insert) from bluesky.callbacks.broker import post_run # At the end of every run, verify that files were saved and # print a confirmation message. from bluesky.callbacks.broker import verify_files_saved gs.RE.subscribe('stop', post_run(verify_files_saved)) # Import matplotlib and put it in interactive mode. import matplotlib.pyplot as plt plt.ion() # Make plots update live while scans run. from bluesky.utils import install_qt_kicker install_qt_kicker() # Optional: set any metadata that rarely changes. # RE.md['beamline_id'] = 'YOUR_BEAMLINE_HERE' # convenience imports from ophyd.commands import * from bluesky.callbacks import *