Skip to content

refactor: Include Bluesky plan stubs by default - #1694

Open
shree-iyengar-dls wants to merge 35 commits into
mainfrom
1691_blueapi_plan_stubs
Open

shree-iyengar-dls wants to merge 35 commits into
mainfrom
1691_blueapi_plan_stubs

Conversation

@shree-iyengar-dls

@shree-iyengar-dls shree-iyengar-dls commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1691

Summary of changes

  • Since the improvement of type checking of plan stubs in bluesky, dodal wrapped plan_stubs are no longer required and we can import plan stubs directly from bluesky - these are hardcoded in a list of DEFAULT_PLAN_STUBS
  • NB: bluesky plan stubs have the annotation Moveable[Any]. The is_compatible_args function in blueapi checks type arguments and so there might be a mismatch between for example Moveable[float] and the bluesky plan stub annotation? I had to change the type annotation of FakeDevice but not sure what effect this might have on other devices

@shree-iyengar-dls shree-iyengar-dls changed the title feat: add default plans list refactor: Include Bluesky plan stubs by default Oct 8, 2026
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.32%. Comparing base (4701980) to head (f16a563).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1694   +/-   ##
=======================================
  Coverage   96.31%   96.32%           
=======================================
  Files          50       50           
  Lines        3831     3836    +5     
=======================================
+ Hits         3690     3695    +5     
  Misses        141      141           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shree-iyengar-dls

Copy link
Copy Markdown
Contributor Author

Blocked by #1662 and #1663

Comment thread pyproject.toml Resolved
@oliwenmandiamond

Copy link
Copy Markdown
Contributor

@shree-iyengar-dls I would put this in draft for now as this depends on a few different things which are yet to be merged e.g updated bluesky version, supporting *args and **kwargs

@abbiemery

Copy link
Copy Markdown
Contributor

Unblocked partially by the merging of #1715, might still be blocked by a bluesky release.

@oliwenmandiamond

Copy link
Copy Markdown
Contributor

Blocked by #1720

@oliwenmandiamond

oliwenmandiamond commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

I have tested this

>>> pl.mv(dev.stage.x, 90, dev.stage.theta, 5)
>>> pl.abs_set(dev.stage.x, 100, wait=True)
>>> pl.mvr(dev.stage.x, -2)
>>> pl.mvr
mvr(
    args: list[Movable | Any] | None = None,
    group: Any | None = None,
    timeout: float | None = None,
    kwargs: dict | None = None
)

Seems to work fine for plan stubs now

Comment thread pyproject.toml Resolved
Comment thread pyproject.toml Resolved

def with_config(self, config: EnvironmentConfig) -> None:
if config.metadata is not None:
self.run_engine.md |= config.metadata.model_dump()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change not related to this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the original |= I'm getting an error:

  Operator "|" not supported for types "RunEngineMetadata" and "Dict[str, Any]"

@shree-iyengar-dls
shree-iyengar-dls marked this pull request as ready for review November 13, 2026 11:14
@shree-iyengar-dls
shree-iyengar-dls requested a review from a team as a code owner November 13, 2026 11:14
Comment thread pyproject.toml Resolved

@oliwenmandiamond oliwenmandiamond left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good, thank you! I think a small amount of documentation is needed to go with this about blueapi providing default bluesky plan stubs and that they can be overwritten for whatever reason is also possible.

Then am happy to approve



class FakeDevice(Movable[float]):
class FakeDevice(Movable[Any]):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to Any? If it does indeed take Any, then the type hint for set would need to be updated to Any as well

def set(self, value: Any) -> Status:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not sure if this is right but the NB point in my PR description should explain

module: dodal.plan_stubs.wrapped
```
These plans that will be used in this tutorial can be found in the [dodal repository](https://github.com/DiamondLightSource/dodal/tree/b4b38f1e0cf480faeb29d67695440c45a148f169). Specifically, in `dodal/src/dodal/plans/wrapped.py` and `dodal/src/dodal/plan_stubs/wrapped.py`.
These plans that will be used in this tutorial can be found in the [dodal repository](https://github.com/DiamondLightSource/dodal/tree/b4b38f1e0cf480faeb29d67695440c45a148f169). Specifically, in `dodal/src/dodal/plans/wrapped.py` and [bluesky repository](https://github.com/bluesky/bluesky/blob/1fb2f4e13437edf4a72372dacd455cfaf905f09e/src/bluesky/plan_stubs.py#L321).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make a distinction between the plans that were just added in the example and the plans available by default. At the moment it looks like you add one module and get two loads of plans to work with.

(and nit: Was this meant to point to a specific line? )


ctx.register_plan(mv)
assert ctx.plans["mv"].plan_function is mv
assert ctx.plans["mv"].plan_function is not bps.mv

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think once we've established the plan is mv it's unlikely to also be bps.mv



class FakeDevice(Movable[float]):
class FakeDevice(Movable[Any]):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needing to change is a sign that the type hints in the bluesky plan stubs are wrong. I'll open an issue there.

def test_plans_iterable(bc: BlueapiClient):
names = {plan.name for plan in bc.plans}
assert {"count", "sleep", "set_absolute"} <= names
assert {"count", "sleep", "abs_set"} <= names

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep and abs_set will be in the other list. Might be worth checking another couple of plans from dodal's wrapped plan module.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include Bluesky plan stubs by default

4 participants