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

Add deprecation warning to inject #854

Merged
merged 6 commits into from
Oct 18, 2024
Merged

Conversation

callumforrester
Copy link
Contributor

@callumforrester callumforrester commented Oct 18, 2024

Fixes #845
Supersedes #839

Instructions to reviewer on how to test:

  1. Confirm tests pass
  2. Optional: write a plan that uses inject and confirm it raises a warning when run.

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}

@callumforrester callumforrester marked this pull request as ready for review October 18, 2024 13:02
@callumforrester
Copy link
Contributor Author

@DominicOram is there anything else from your comments in #841 that you feel would be appropriate to document here?

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.19%. Comparing base (ecc1a20) to head (cd50d73).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #854   +/-   ##
=======================================
  Coverage   95.19%   95.19%           
=======================================
  Files         120      120           
  Lines        4976     4979    +3     
=======================================
+ Hits         4737     4740    +3     
  Misses        239      239           

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

Comment on lines 49 to 57
def my_plan() -> MsgGenerator:
detector = i22.saxs(connect_immediately=False)
# We need to connect via the stub instead of directly
# so that the RunEngine performs the connection in the
# correct event loop
yield from ops.ensure_connected(detector)
yield from bp.count([detector])

RE(my_plan()))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't want to encourage this, I want to always have the device as a default argument.
This prevents any metrics/tracing/logging/documenting on the arguments of the plan, leads to N different plans that are just using a different device, makes it easier for the scope of the device to be managed incorrectly and cause issues (conditionally instantiating my device as mock/connecting my device?).
I think the Finder in GDA was a mistake that made every momentary decision to use it slightly easier and every subsequent attempt to extract what the hell was going on a lot harder.

I think it's risking making debugging a lot harder for a small benefit in verbosity, so I would like more attention paid to the above and comments about the benefits of doing it that way.

I'm prepared to be told I'm getting in the way of writing plans for this standpoint. I really don't like it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It also means we can call ensure_connected at the top of the plan and fail fast if any device won't be available, rather than after completing the first iteration of the fastest axis: and we can call connect on all of the devices in parallel rather than on each one as we encounter it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest I broadly agree. Dependency injection is a good thing and, in my opinion, having lots of defaulted parameters is not a particularly terrible thing. Maybe we take this out for now and add it later if demand calls for it?

@callumforrester callumforrester merged commit 0f8989e into main Oct 18, 2024
18 checks passed
@callumforrester callumforrester deleted the 845-deprecate-inject branch October 18, 2024 13:54
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.

Deprecate inject method
2 participants