-
Notifications
You must be signed in to change notification settings - Fork 76
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
Helper function to chain functions that return statuses #1121
Comments
Could this sequencing be lifted up to be a plan that the RE manages? |
That would be cleaner but to do so would require the RE to be multithreaded. It wasn't obvious to me if there was any support for this in the RE at the moment and if not seems like a potentially large refactor? I guess from a user perspective it would look something like: def my_async_plan():
yield from bps.set(.., group="A")
yield from bps.wait("A") # Note this shouldn't block main thread just this plan
...
def my_actual_plan():
yield from bps.run_async_plan(my_async_plan, group="async_plan") # New message that's basically create a thread
yield from bps.set(.., group="B")
yield from bps.wait("B") # Should not block async thread
...
yield from bps.wait("async_plan") # Effectively a join here |
This is a feature that I have wanted to write for a while now (but I would call it multi-task not multi-threaded)! There is a mostly working version of this in #1121 (which was motivated to better isolate the pre/post plans for suspneders). At least at NSLS-II we have gotten away without doing this sort of thing because in the cases where we did need something like this we could either write the sequencing "inline" or made use of the I have concerns about starting to do too much sequencing "natively" in ophyd. If there is sequencing done below Python (that is in the IOCs or what have you), ophyd needs to be able to provide a way to expose that up (which may require adding some additional methods to ophyd objects and verbs to RE, but between I have not seen the code, but I am guessing it looks like: def sequencer(items):
seq = iter(items)
def inner(item):
status = item()
status.add_callback(lambda: inner(next(seq)))
inner(next(seq)) which is (I think) the callback-centric version of the v0 RE in The refactoring I think we need on the RE is:
I think all of this can be done in a backwards compatible |
@WareJosephB has written a task graph implementation that solves this for sub plans that end by returning a status object. I might have got this wrong, but I think you can construct a task graph that says "do A,B,C in parallel, then do D", and if A, B and C all do some setup and return a Status object, then it will do them all in quick succession then wait for the 3 Status objects, then do D.
For things that are "prepare for and do a scan" I think we are covered with What's your use case? |
I meant to link to bluesky/bluesky#541 above |
On MX at DLS we have a usecase where we want to kickoff a series of tasks on the device that must be done in series e.g.
@olliesilvester has written a helper function for the
do_all
to take a generic list and perform everything in order. We think it may be generically useful to be in ophyd so they will add a PR for it here.The text was updated successfully, but these errors were encountered: