-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add a UserClient that can be used as a scripting interface for blueapi #1284
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1284 +/- ##
==========================================
- Coverage 94.92% 94.69% -0.23%
==========================================
Files 42 43 +1
Lines 2717 2828 +111
==========================================
+ Hits 2579 2678 +99
- Misses 138 150 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@abbiemery @DominicOram @EmsArnold @olliesilvester @Relm-Arrowny @oliwenmandiamond @noemifrisina I have a feeling this may be controversial, so I would like opinions on this. This has been extremely useful for saxs-bluesky and IMO it means we have something closer to a minimum viable Domain-Specific Language (DSL) |
|
There's definitely a need for this sort of thing. How have scientists/users been using this so far, and is there feedback? I've experimented with similar things using ipython and jupyter notebooks, but it's hard to make it not clunky |
|
Scientists have been experimenting with this on i22 and @EmsArnold has used this. I'd say feedback has been broadly positive. The only complaint i've had is the clunkiness of having to put client.run() to execute a plan via blueapi. |
|
Good to know, I'm a fan of this. I wonder if users would prefer to do this sort of thing in jupyter notebooks or just in a basic terminal. I guess it works fine for both anyway. Maybe this can be a topic for the next athena drop-in, we can work out the best API + features for this |
|
Not sure this is controversial, blueapi as it is, is very hard to use to run any experiment and this make it much easier. Kind of related, we run a jupiter server on p99-k8s with an "option" of using the nexus writer for scientist to play with, it may be of interest. This is the startup I gave scientist https://github.com/DiamondLightSource/sm-bluesky/blob/main/demo/p99/stomp_setup.ipynb. You can play with it here: http://172.23.177.194:8888/lab/tree/work it is password protected, I can dm you the password if needed. We all trying to found ways to make it easier.... may be it is time we try to come up with something we all use? |
Sounds good! |
|
I would find this useful as well. At some point I came up with some functions to wrap Blueapi calls to do something very similar, so having a common standard solution to this problem wouild be good. My current method for testing Blueapi with real hardware on a beamline is fire up GDA and use the Jython console! |
|
I'm not per-say against this if people find it useful but I would say if you take a step back and look at the whole system it kind of feels a bit odd. My understanding was that some of the arguments for using Bluesky in the first place were:
My concern with this change is that now we will have an explosion of "plans" that are: def my_plan():
client.run("a")
client.run("b")and I worry that:
To allow scientists to be able to do any of these things you then have the option of:
My preference is to go down the second path as I think 1) will just lead to even more DLS custom code we will have to maintain and pull us further from the collaboration. Which means I think as part of this I would like us to decide roughly what the line is of what this DSL will and won't support and when we will start teaching scientists to use Bluesky as intended. I would also like us to think about how we can make the transition from a scientists writing things using the DSL to writing plans as easy as possible even small stuff like still using For this specific implementation I have some comments:
P.S. I'm not arguing btw that Bluesky is easy to teach. I think in particular the use of generators is really unfriendly to novices and not worth the benefit you get from it. However, the decision has been made and if all of our backend logic is going to be Bluesky at some point we will have to start teaching more advance users how to use it properly |
|
There's a lot to unpack here, so I will try but this is probably discussed in person.
That's a whole conversation in itself, which I will leave to those that work in DAQ full time
We lost these when we put bluesky behind an API, and then poked it with a request. This class attempts to put it back in python world, and return some of the python-y aspects, whilst also having all the advantages of blueapi.
This is the plan, but once they have written their plan - how do they execute it? We're trying to replace gda, and if they don't have a nice method to execute it, we'll be stuck in gda world (see Iain's comment). This provides a link between the user and blueapi without going through jython.
Is that any different from having (in gda): def my_plan():
run_plan("a")
run_plan("b")I don't know how to resolve this if scientists need to write custom scripts. The only way we can prevent this is by not letting anyone modify/write scripts and stick it all behind a GUI, which we cannot do. Or insist we have everyone submit everything and it goes through code review. Which is impracticable. We should be following the ALARP principle (as low as reasonable achievable) ie keep the crappines of the code as low as reasonably achievable, without hindering the science.
This does not depend on dodal, only for the pytest. This can be removed.
I like this
This works with auth. i22/b21 currently have the latest version of blueapi and user numtracker etc. The user must first login. BlueAPI does this via |
|
I agree with a lot of Dom's concerns. For me though, I am now aware of at least 4 different implementations where someone in DAQ has written some sort of BlueAPI wrapper purely for the purpose of allowing scientists to easily run bluesky plans through a terminal. Given that loads of us are trying to do the same thing ATM, it would be good to have a simple but stable solution we can all use asap |
I don't believe Option 2 is the core issue. Instead, I personallty think BlueAPI does not deliver the same User Experience as GDA. While scientists writing and submitting plans to the server is fine, we need an experience that closer to our current user expectation. |
|
A scripting interface for blueapi is something the core team have visibility on, and are looking to prioritise in the new year. So thank you for curating your experiences and opinions here. I will be at the athena drop in session next week to discuss this with you all :) |
|
After Dom's long comment, and my equally long response we spoke about this IRL. The summary from that conversation:
@DominicOram did I forget anything? I think I probably did |
The client that exists in blueapi is functional. This class extends the ability of the client, abstracts a lot of the logic and allows beamline staff or users to start building scripts used for an experiment.