Skip to content

Conversation

@tpoliaw
Copy link
Contributor

@tpoliaw tpoliaw commented Oct 30, 2025

Most devices are a straightforward swap to the new decorator. The main things to
be aware of:

  • Devices are no longer cached anywhere.
    a, b = synchrotron.build(), synchrotron.build() will result in two synchrotrons.
    Adding @cache might work if the function takes no other devices but given
    most devices aren't hashable it probably won't work otherwise.
  • devices.build_all() will only build one of each device, so two devices
    depending on the same third device will be passed the same instance.
  • If a device factory calls another device factory itself (rather than using a
    parameter), it will create a separate instance.

Other things specific to i03's module

  • The weird empty method for the ophyd_v1 device (eiger). If there was a
    post_create method, that would be where it was. Given ophyd v1 support is not
    meant to be long-lived, this will do for now.
  • The path_provider is no longer set as a global and needs to be passed in when
    the methods that require them are called. When using the device manager, this
    is automatic, eg panda.build() will automatically create the path provider
    via the fixture. BlueApi will pass its own path_provider which would be used
    instead.
  • The undulator and undulator_dcm now take their configuration path as a
    required argument rather than using the global if not set. This will be taken
    from the fixture unless overridden. When the two devices are built at the same
    time (eg undulator_dcm.build() which builds undulator as a dependency)
    both will use the same configuration path.

The CLI has already been updated so this can be tested via

dodal connect i03 -n devices

with or without -s to mock things as before. The -n devices is currently
needed to determine what the device manager is called. If we standardise on a
convention for this, that can be removed.

@tpoliaw tpoliaw requested a review from a team as a code owner October 30, 2025 16:32
@tpoliaw tpoliaw force-pushed the i03-device-manager branch from 1035326 to 984894d Compare October 30, 2025 16:34
@tpoliaw tpoliaw force-pushed the device_context branch 3 times, most recently from 11dcde0 to 6e29bb8 Compare November 13, 2025 16:57
@tpoliaw tpoliaw requested a review from DominicOram November 14, 2025 10:36
@rtuck99 rtuck99 self-assigned this Nov 14, 2025
@DominicOram DominicOram self-assigned this Nov 18, 2025
Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

I think this is generally ok. I have made DiamondLightSource/mx-bluesky#1459 which fixes most of the tests on the mx-bluesky side I believe.

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Could you take a look at the tests in test_device_instantiation.py?

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.10%. Comparing base (9ed11d4) to head (c360687).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...plans/configure_arm_trigger_and_disarm_detector.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1684      +/-   ##
==========================================
- Coverage   99.13%   99.10%   -0.03%     
==========================================
  Files         279      279              
  Lines       10504    10510       +6     
==========================================
+ Hits        10413    10416       +3     
- Misses         91       94       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@rtuck99 rtuck99 left a comment

Choose a reason for hiding this comment

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

I've updated the docs and made the test_device_instantiation.py cover i03 again, everything else looks fine, will need DiamondLightSource/mx-bluesky#1459 as well when merged

Base automatically changed from device_context to main November 27, 2025 08:13
@DominicOram
Copy link
Contributor

With the manager itself merged I will tidy this up now to make it ready for merging


@devices.factory()
def aperture_scatterguard() -> ApertureScatterguard:
"""Get the i03 aperture and scatterguard device, instantiate it if it hasn't already
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove these docstrings as they're lies

@DominicOram DominicOram enabled auto-merge (squash) November 27, 2025 17:36
@rtuck99 rtuck99 merged commit 2cdee61 into main Dec 1, 2025
9 of 11 checks passed
@rtuck99 rtuck99 deleted the i03-device-manager branch December 1, 2025 11:45
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.

4 participants