We will need a function to acquire a suitably-configured bluesky run engine under which plans will be executed
This should be a lazily instantiated singleton (only one run engine should ever be created in any given python process).
The run engine should not be created at library import time.
Implementation hint: @functools.cache
This method should be part of the "public" API of this library
In a future ticket, we may add something like RE = ibex_bluesky_core.create_run_engine() as one of the GUI initialization commands which are automatically run. However that is out-of-scope for this issue.
Consider how the bluesky event loop interacts with the existing matplotlib event loop in the GUI
Generally multiple event loops are not usually recommended, read up on best practice in this area to decide what to do in each of these cases.
We already use an asyncio event loop for matplotlib plotting (in genie_python.matplotlib_backend):
Review that event loop setup/configuration to make sure the two event loops don't clash with each other / check any global configuration around event loop policies and asyncio error handlers.
For this issue, we do not need to add any particular hooks or customization to the run engine, these will be added in a future ticket.
Ensure basic run engine control works - especially keyboard interrupts, you should be able to pause/resume/abort a long-running plan (e.g. bps.sleep(99)) both from a normal python shell and from the IBEX gui.
Acceptance criteria
Something in the following form works:
import bluesky.plan_stubs as bps
from bluesky.run_engine import RunEngine
from ibex_bluesky_core import get_run_engine
RE: RunEngine = get_run_engine()
RE(bps.null()) # Or any other plan - null() is the simplest possible plan, which emits no messages
ANOTHER_RE: RunEngine = get_run_engine() # Should return the same run_engine as before
assert ANOTHER_RE is RE
Ensure unit tests have been created, to cover at a minimum:
Ensuring we don't create multiple run engines
Basic run engine functionality - running a trivial plan
Ability to pause/resume/abort the run engine (this is standard bluesky functionality)
Ability to get the plan result out of the run engine (this is standard bluesky functionality)
We will need a function to acquire a suitably-configured bluesky run engine under which plans will be executed
@functools.cache
RE = ibex_bluesky_core.create_run_engine()
as one of the GUI initialization commands which are automatically run. However that is out-of-scope for this issue.asyncio
event loop for matplotlib plotting (ingenie_python.matplotlib_backend
):asyncio
error handlers.bps.sleep(99)
) both from a normal python shell and from the IBEX gui.Acceptance criteria
Something in the following form works:
Ensure unit tests have been created, to cover at a minimum:
Time in planning meeting (18/07/24)
1:26:00 (ish - sorry, GR)