Skip to content

Prevent devices connecting as side effect of use elsewhere - #860

Merged
DiamondJoseph merged 3 commits into
mainfrom
prevent-connect-side
Oct 23, 2024
Merged

DiamondJoseph merged 3 commits into
mainfrom
prevent-connect-side

Conversation

@DiamondJoseph

@DiamondJoseph DiamondJoseph commented Oct 23, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #856, issues discussed in the comments of #854
With this change, devices are always created not connected, and it is the responsibility of the user to ensure their device is connected before trying to use it:

e.g. on an ipython terminal:

from bluesky.utils import MsgGenerator
from bluesky.run_engine import RunEngine
from dodal.beamlines.i22 import saxs
from ophyd_async.core import ensure_connected

s = saxs()
mock = int(time.time()) % 2 == 0

def plan(det: Readable) -> MsgGenerator:
    yield from ensure_connected(det)
    yield from {}

# Connects by any of the below
await s.connect(mock=mock)
RE(ensure_connected(s, mock=mock))
RE(plan(s))
s = saxs(connect_immediately=True)

or in blueapi, we will call get_all_device_factories() and call connect on all devices in parallel, reporting on any device connection issues.

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}

@codecov

codecov Bot commented Oct 23, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.20%. Comparing base (523cef8) to head (001bfc2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #860      +/-   ##
==========================================
- Coverage   95.20%   95.20%   -0.01%     
==========================================
  Files         120      120              
  Lines        4985     4984       -1     
==========================================
- Hits         4746     4745       -1     
  Misses        239      239              

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

@d-perl d-perl 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.

Thanks, I think this is much safer

@callumforrester callumforrester 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.

Looks good, one small thing

Comment thread src/dodal/common/coordination.py Resolved
@DiamondJoseph
DiamondJoseph merged commit 52848b3 into main Oct 23, 2024
@DiamondJoseph
DiamondJoseph deleted the prevent-connect-side branch October 23, 2024 14:53
DiamondJoseph added a commit that referenced this pull request Oct 25, 2024
rtuck99 pushed a commit that referenced this pull request Oct 25, 2024
* Revert "Prevent devices connecting as side effect of use elsewhere (#860)"

This reverts commit 52848b3.

* Revert " Prevent simulated connect from trying to connect to real device (#849)"

This reverts commit ecc1a20.

* Revert "Add deprecation warning to inject (#854)"

This reverts commit 0f8989e.

* Revert "Isolated device factory (#841)"

This reverts commit 0ba531c.
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.

device_factory should default to eager_connect=False

3 participants