Repository navigation
refactor: Include Bluesky plan stubs by default - #1694
shree-iyengar-dls wants to merge 35 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
@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 |
|
Unblocked partially by the merging of #1715, might still be blocked by a bluesky release. |
d96a6fb to
b020927
Compare
9ff9c16 to
e6ab3b5
Compare
…ce/blueapi into 1691_blueapi_plan_stubs
…ce/blueapi into 1691_blueapi_plan_stubs
|
Blocked by #1720 |
|
I have tested this Seems to work fine for plan stubs now |
|
|
||
| def with_config(self, config: EnvironmentConfig) -> None: | ||
| if config.metadata is not None: | ||
| self.run_engine.md |= config.metadata.model_dump() |
There was a problem hiding this comment.
Change not related to this change
There was a problem hiding this comment.
With the original |= I'm getting an error:
Operator "|" not supported for types "RunEngineMetadata" and "Dict[str, Any]"
oliwenmandiamond
left a comment
There was a problem hiding this comment.
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]): |
There was a problem hiding this comment.
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:There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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]): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
sleep and abs_set will be in the other list. Might be worth checking another couple of plans from dodal's wrapped plan module.
Fixes #1691
Summary of changes
DEFAULT_PLAN_STUBSMoveable[Any]. Theis_compatible_argsfunction in blueapi checks type arguments and so there might be a mismatch between for exampleMoveable[float]and the bluesky plan stub annotation? I had to change the type annotation ofFakeDevicebut not sure what effect this might have on other devices