Skip to content

Commit

Permalink
Merge pull request #23 from BCDA-APS/21-Bluesky-Magics
Browse files Browse the repository at this point in the history
add BlueskyMagics
  • Loading branch information
prjemian authored Nov 14, 2024
2 parents 75de131 + 4ef38e8 commit fa033cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/instrument/configs/iconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/instrument/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/instrument/utils/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
================================
.. autosummary::
~register_bluesky_magics
~running_in_queueserver
~debug_python
~mpl_setup
Expand All @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit fa033cd

Please sign in to comment.