From 4ef38e8c3f2efaaab258d437289ce460d808eda8 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Thu, 14 Nov 2024 10:19:05 -0600 Subject: [PATCH] MNT #21 implement --- src/instrument/configs/iconfig.yml | 3 +++ src/instrument/startup.py | 4 ++++ src/instrument/utils/helper_functions.py | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/src/instrument/configs/iconfig.yml b/src/instrument/configs/iconfig.yml index e36ef6e..f770563 100644 --- a/src/instrument/configs/iconfig.yml +++ b/src/instrument/configs/iconfig.yml @@ -29,6 +29,9 @@ RUN_ENGINE: ### Default: True USE_PROGRESS_BAR: false +# Command-line tools, such as %wa, %ct, ... +USE_BLUESKY_MAGICS: True + ### Best Effort Callback Configurations ### Defaults: all true (except no plots in queueserver) # BEC: diff --git a/src/instrument/startup.py b/src/instrument/startup.py index 541b031..5313ef4 100644 --- a/src/instrument/startup.py +++ b/src/instrument/startup.py @@ -22,11 +22,15 @@ # Bluesky data acquisition setup from .utils.config_loaders import iconfig +from .utils.helper_functions import register_bluesky_magics from .utils.helper_functions import running_in_queueserver logger = logging.getLogger(__name__) logger.bsdev(__file__) +if iconfig.get("USE_BLUESKY_MAGICS", False): + register_bluesky_magics() + # Configure the session with callbacks, devices, and plans. if iconfig.get("NEXUS_DATA_FILES") is not None: from .callbacks.nexus_data_file_writer import nxwriter # noqa: F401 diff --git a/src/instrument/utils/helper_functions.py b/src/instrument/utils/helper_functions.py index 2b75ecd..426c3fd 100644 --- a/src/instrument/utils/helper_functions.py +++ b/src/instrument/utils/helper_functions.py @@ -3,6 +3,7 @@ ================================ .. autosummary:: + ~register_bluesky_magics ~running_in_queueserver ~debug_python ~mpl_setup @@ -13,6 +14,7 @@ import matplotlib as mpl import matplotlib.pyplot as plt +from bluesky.magics import BlueskyMagics from bluesky_queueserver import is_re_worker_active from IPython import get_ipython @@ -22,6 +24,13 @@ logger.bsdev(__file__) +def register_bluesky_magics(): + """The Bluesky Magick functions are useful with command-lines.""" + _ipython = get_ipython() + if _ipython is not None: + _ipython.register_magics(BlueskyMagics) + + def running_in_queueserver(): """Detect if running in the bluesky queueserver.""" try: