Configure IPython Profile for Bluesky#

In this optional step, an IPython profile [1] is used to enable the console interface for a bluesky session.

Python snippet to start instrument for data collection#

This snippet of Python code will start Bluesky for data collection. Use it in the IPython startup script and also in Jupyter notebooks. First, it puts the parent directory of the instrument package on the exectuable path, then it starts the instrument.

1import pathlib, sys
2sys.path.append(str(pathlib.Path.home() / "bluesky"))
3from instrument.collection import *

Tip

Use this snippet in Jupyter notebooks to start the instrument.

A slightly more robust version of this snippet is supplied by this bluesky_training repository: __start_bluesky_instrument__.py

Create IPython Profile for Bluesky#

If there is an existing ~/.ipython directory (perhaps created for other use from this account), then choose a unique directory for bluesky. Typical alternative is ~/.ipython-bluesky.

1export BLUESKY_DIR=~/.ipython-bluesky
2mkdir -p "${BLUESKY_DIR}"
3ipython profile create bluesky --ipython-dir="${BLUESKY_DIR}"

Add a single Python file to the startup directory#

1  .ipython-bluesky/
2    profile_bluesky/
3      startup/
4        __start_bluesky_instrument__.py --> ~/bluesky/console/__start_bluesky_instrument__.py

Tip

when IPython starts …

Every Python file in the startup directory is run when IPython starts. The files are run in lexical (alphabetical) order.