DiamondLightSource / mx-bluesky

Bluesky plans, plan stubs, and utilities for MX beamlines
https://diamondlightsource.github.io/mx-bluesky/
Apache License 2.0
0 stars 2 forks source link

Hyperion refactor: Add lowest level FGS plan #80

Open olliesilvester opened 7 months ago

olliesilvester commented 7 months ago

This issue begins moving Hyperion's plans into a more generic form inside this repo, see https://github.com/DiamondLightSource/mx-bluesky/issues/296. The idea is to decompose Hyperion bluesky plans into common building blocks for any MX beamline to use. A beamline can then construct its specific implementation by building up these smaller generic plans. We should also look into using bluesky's 'prepare' command for device setup.

To kick off , I think it makes sense for the first plan added to be the lowest level plan for the fast grid scan. Since it is the lowest level, we need to make sure that this plan is as generic as possible, and that any beamline wanting to do a fast grid scan can use this base plan. It should have similar functionality to do_fgs() in hyperion's flyscan_xray_centre_plan.py. Its parameters should be:

The plan should:

EDIT: This is like a plan stub, so is not designed to be ran by itself. Therefore, this plan shouldn't consider setup or tidy-up

callumforrester commented 7 months ago

This design sounds good as-is. A few possibilities for discussion:

Since the aim here is to create building blocks, I think it's okay if they are not self-contained i.e. if it doesn't make sense to run them on their own. So you could take out the exception handling and expect that to be handled separately. Different users may just compose it in different ways e.g.

def do_fgs_and_cleanup(fgs: FastGridScan):
    yield from do_fgs(fgs)
    yield from cleanup(fgs)

def do_fgs_and_cleanup_on_error(fgs: FastGridScan):
    try:
        yield from do_fgs(fgs)
    except FgsException:
        yield from cleanup(fgs)

You could, of course, also provide the two plans above for convenience, but I think it's good to have a pattern of different compositions rather than lots of if statements in a plan. I fear if-heavy plans will get bloated as more and more cases are added.

I think there may also be scope for handling the optional devices separately, perhaps as a group that you then pass into do_fgs()? I'm not sure because I don't know exactly how they are set up and tied into the fgs operation.

I agree with looking into the prepare command to remove complexity, I might even suggest doing that as part of this exercise.