-
Notifications
You must be signed in to change notification settings - Fork 78
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
Update using-existing-devices.rst #1136
Conversation
Related to this issue: #1092 It is beneficial to include in the docs some note about configuring ipython event loops so that await works as expected.
I was going to suggest putting this somewhere in this block: ophyd/docs/user_v2/examples/epics_demo.py Lines 13 to 19 in 5c413cc
and then updating the surrounding explanation text further up the doc. I imagine quite a lot of people will copy-paste straight from the example code, so I think putting it up there makes more sense. What do you reckon? |
Yep sounds good, will change that now |
While we're at it, could I ask why you're registering RunEngine calls with |
Actually, I've just tried to do as you suggested here... and am getting weird errors that I think are IPython isms that I'm not understanding. If the epics_demo file looks like this: # Import bluesky and ophyd
import matplotlib.pyplot as plt
from bluesky import RunEngine
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.plan_stubs import mov, movr, rd # noqa
from bluesky.plans import grid_scan # noqa
from bluesky.run_engine import call_in_bluesky_event_loop # noqa
from bluesky.utils import ProgressBarManager, register_transform
from IPython import get_ipython
get_ipython().run_line_magic("autoawait", "call_in_bluesky_event_loop")
from ophyd import Component, Device, EpicsSignal, EpicsSignalRO
from ophyd.v2 import epicsdemo
from ophyd.v2.core import DeviceCollector
# Create a run engine, with plotting, progressbar and transform
RE = RunEngine({}, call_returns_result=True)
bec = BestEffortCallback()
RE.subscribe(bec)
RE.waiting_hook = ProgressBarManager()
plt.ion()
register_transform("RE", prefix="<")
# Start IOC with demo pvs in subprocess
pv_prefix = epicsdemo.start_ioc_subprocess()
# Create v1 device
class OldSensor(Device):
mode = Component(EpicsSignal, "Mode", kind="config")
value = Component(EpicsSignalRO, "Value", kind="hinted")
det_old = OldSensor(pv_prefix, name="det_old")
# Create v2 devices
with DeviceCollector():
det = epicsdemo.Sensor(pv_prefix)
samp = epicsdemo.SampleStage(pv_prefix) Then, running an ipython terminal with
I get the following error:
What do you think about this? To me it seems obvious that users should only include the 'autoawait' ipython magic if they want to play with the ophyd devices directly, not if they want to use bluesky to actually run plans with them and poke them, and plot things in the terminal. In which case I would argue, the best place for that tidbit of information is where I originally put it. |
@coretl what was the result of this discussion? Do I need to update this PR? Thanks |
The bug is that best effort callback doesn't work with tk, only with qt. The notes say that you were going to raise a bluesky issue with this stack trace, then add |
Closing as this should be in |
Related to this issue: #1092
It is beneficial to include in the docs some note about configuring ipython event loops so that await works as expected.