bluesky / bluesky

experiment orchestration and data acquisition
https://blueskyproject.io/bluesky/
BSD 3-Clause "New" or "Revised" License
173 stars 94 forks source link

Expose `_vendor.super_state_machine.extras/errors` publicly #1760

Open evalott100 opened 4 months ago

evalott100 commented 4 months ago

Super state machine lacks support, and as such we've decided to vendor it within bluesky, keeping it private for convenience.

In ophyd-async, we except TransitionError in tests requiring the RunEngine, but this can be imported from RunEngine directly.

Blueapi uses ProxyMachine in typing, which isn't available through bluesky.run_engine:

https://github.com/DiamondLightSource/blueapi/blob/97b43cec747b22c94de266e05db286ba98f81aba/src/blueapi/worker/event.py#L10-L11

I would suggest:

Change bluesky._vendor.super_state_machine to bluesky.vendor.super_state_machine, with an __init__.py exposing the relevant public members.

@tacaswell @danielballan

DiamondJoseph commented 4 months ago

Here's the relevant blueapi issue https://github.com/DiamondLightSource/blueapi/issues/553

tacaswell commented 4 months ago

My knee-jerk reaction is to make just the errors public as they can be raised out the the RE (or catch them and re-raise errors of a different type) and to have blueapi import the private modules if the only usage is for typing.

I'm not sure what right way to type things using the descriptor protocol (that is Python's descriptors not the event models) as the type of the attribute on the class object is what ever the descriptor class is but the type on an instance of the class is going to be a different type as a core feature of their functionality. Maybe we need to add another Protocol class? I do not think we want the detail that we are using a version of super_state_machine to be public so we should pare that back as far as we can.