Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BlueskyMagics #23

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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