instrument.startupΒΆ

This same code can be used with IPython console & Jupyter notebook sessions and the bluesky queueserver. Use this inspiration to build your own custom startup procedures.

 1"""
 2Start Bluesky Data Acquisition sessions of all kinds.
 3
 4Includes:
 5
 6* Python script
 7* IPython console
 8* Jupyter notebook
 9* Bluesky queueserver
10"""
11
12# logging setup first
13import logging
14
15from .core.best_effort_init import bec  # noqa: F401
16from .core.best_effort_init import peaks  # noqa: F401
17from .core.catalog_init import cat  # noqa: F401
18from .core.run_engine_init import RE  # noqa: F401
19from .core.run_engine_init import sd  # noqa: F401
20from .devices import *  # noqa: F403
21from .plans import *  # noqa: F403
22
23# Bluesky data acquisition setup
24from .utils.config_loaders import iconfig
25from .utils.helper_functions import register_bluesky_magics
26from .utils.helper_functions import running_in_queueserver
27
28logger = logging.getLogger(__name__)
29logger.bsdev(__file__)
30
31if iconfig.get("USE_BLUESKY_MAGICS", False):
32    register_bluesky_magics()
33
34# Configure the session with callbacks, devices, and plans.
35if iconfig.get("NEXUS_DATA_FILES") is not None:
36    from .callbacks.nexus_data_file_writer import nxwriter  # noqa: F401
37
38if iconfig.get("SPEC_DATA_FILES") is not None:
39    from .callbacks.spec_data_file_writer import newSpecFile  # noqa: F401
40    from .callbacks.spec_data_file_writer import spec_comment  # noqa: F401
41    from .callbacks.spec_data_file_writer import specwriter  # noqa: F401
42
43# These imports must come after the above setup.
44if running_in_queueserver():
45    ### To make all the standard plans available in QS, import by '*', otherwise import
46    ### plan by plan.
47    from apstools.plans import lineup2  # noqa: F401
48    from bluesky.plans import *  # noqa: F403
49
50else:
51    # Import bluesky plans and stubs with prefixes set by common conventions.
52    # The apstools plans and utils are imported by '*'.
53    from apstools.plans import *  # noqa: F403
54    from apstools.utils import *  # noqa: F403
55    from bluesky import plan_stubs as bps  # noqa: F401
56    from bluesky import plans as bp  # noqa: F401
57
58    from .utils.controls_setup import oregistry  # noqa: F401