Skip to content
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

Defer implementation of MsgGenerator to prevent strange behaviour #832

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

DiamondJoseph
Copy link
Contributor

Previously it has been observed in blueapi that defining the same type alias in different modules has stopped being the same object, and then later stopped even being equal to each other. As checking that the return type of a function is MsgGenerator is used by blueapi to determine which plans to expose, this has prevented plans and stubs from being visible. As of bluesky 1.13, bluesky now defines its own implementation of MsgGenerator, which also meets the requirements of @rtuck99 of having a return type.

Prevents re-occurence of these issues and similar:
DiamondLightSource/blueapi#533
DiamondLightSource/blueapi#643

Instructions to reviewer on how to test:

  1. Run type checking and ensure that functions that return a MsgGenerator are correctly typed
  2. Confirm that
from dodal.common import MsgGenerator as m1
from bluesky.utils import MsgGenerator as m2

assert m1 is m2
assert m1 == m2

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@DiamondJoseph
Copy link
Contributor Author

https://github.com/bluesky/bluesky/blob/b6828c53a68252caeefc3712ea50c49e507d8db2/src/bluesky/utils/__init__.py#L98

Here is the current implementation of MsgGenerator in bluesky.

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.02%. Comparing base (e2b2705) to head (166fec9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #832      +/-   ##
==========================================
- Coverage   95.02%   95.02%   -0.01%     
==========================================
  Files         117      117              
  Lines        4767     4764       -3     
==========================================
- Hits         4530     4527       -3     
  Misses        237      237              

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

Copy link
Contributor

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

Unless you have a good reason to avoid it I would prefer this change were just a big find and replace where all imports within dodal are replaced with from bluesky.utils import MsgGenerator.

@DiamondJoseph
Copy link
Contributor Author

Unless you have a good reason to avoid it I would prefer this change were just a big find and replace where all imports within dodal are replaced with from bluesky.utils import MsgGenerator.

Done

And PRs opened to allow eventual removal of dodal pass-through in other libraries too
DiamondLightSource/mx-bluesky#564
DiamondLightSource/blueapi#645

i22 etc. to follow

@DiamondJoseph DiamondJoseph merged commit 799cae1 into main Oct 10, 2024
18 checks passed
@DiamondJoseph DiamondJoseph deleted the unify-msggenerator branch October 10, 2024 15:23
This was referenced Oct 14, 2024
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.

2 participants