Skip to content

Use config server for detector LUT#1776

Merged
jacob720 merged 44 commits intomainfrom
mx_bluesky_1509_use_config_server_for_detector_lut
Mar 25, 2026
Merged

Use config server for detector LUT#1776
jacob720 merged 44 commits intomainfrom
mx_bluesky_1509_use_config_server_for_detector_lut

Conversation

@jacob720
Copy link
Copy Markdown
Contributor

@jacob720 jacob720 commented Dec 10, 2025

Fixes DiamondLightSource/mx-bluesky#1509

Required by DiamondLightSource/mx-bluesky#1510

Instructions to reviewer on how to test:

  1. Check detector config is being read through the config server rather than directly from the filesystem

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}

@jacob720 jacob720 requested a review from a team as a code owner December 10, 2025 11:11
@jacob720 jacob720 marked this pull request as draft December 10, 2025 11:11
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.11%. Comparing base (14b2a03) to head (072bf2f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1776   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         318      318           
  Lines       12331    12336    +5     
=======================================
+ Hits        12222    12227    +5     
  Misses        109      109           

☔ 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.

@jacob720 jacob720 force-pushed the mx_bluesky_1509_use_config_server_for_detector_lut branch from 1e9a569 to 1117a2d Compare March 3, 2026 18:33
@jacob720 jacob720 changed the base branch from main to mx_bluesky_1504_migrate_beamline_parameters_to_config_server March 3, 2026 18:34
@jacob720 jacob720 marked this pull request as ready for review March 3, 2026 18:38
Base automatically changed from mx_bluesky_1504_migrate_beamline_parameters_to_config_server to main March 13, 2026 16:26
def __init__(self, lookup_file: str):
self.lookup_file: str = lookup_file
lookup_table_columns: list = parse_lookup_table(self.lookup_file)
config_client = get_config_client(get_beamline_name())
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.

Is it not simpler to just pass in the ConfigClient instance to the constructor?

I dislike this because some additional hidden env configuration someone has to set up and we won't know it fails until you run it. If you don't pass in the ConfigClient to the constructor, type checking would complain instantly

Copy link
Copy Markdown
Contributor Author

@jacob720 jacob720 Mar 17, 2026

Choose a reason for hiding this comment

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

I basically agree, but the issue with passing it in is that DetectorParams then needs to hold an instance of the config client, which seems a bit strange for a parameter model.

@cached_property
    def beam_xy_converter(self) -> DetectorDistanceToBeamXYConverter:
        return DetectorDistanceToBeamXYConverter(self.det_dist_to_beam_converter_path)

Would need to become

@cached_property
    def beam_xy_converter(self) -> DetectorDistanceToBeamXYConverter:
        return DetectorDistanceToBeamXYConverter(
            self.det_dist_to_beam_converter_path, self.config_client
        )

If you still think that's nicer I can do that though. It also might cause issues when trying to serialise the parameter model but I can't see this is ever done so that's probably fine.

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.

This is fine. This way, we have much more control via dependency injection. This doesn't need to be a cached_property either. You don't want the state to persist between tests, it needs to be reset for each one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll do that then. As for it being cached, the params should be reconstructed for each test regardless on whether it's cached. Caching means in actual plans we don't rebuild the lut every time we want to read it



@devices.fixture
@cache
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.

I think that if a fixture is not required by any device factory, it will not be called, so set_config_client() will not be invoked.

So you probably need to include it as an argument to the device factory even if the factory doesn't use it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have removed the fixture and just call set_config_client now

@jacob720 jacob720 requested a review from rtuck99 March 25, 2026 15:38
Copy link
Copy Markdown
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.

Approved

@jacob720 jacob720 merged commit 856994d into main Mar 25, 2026
10 checks passed
@jacob720 jacob720 deleted the mx_bluesky_1509_use_config_server_for_detector_lut branch March 25, 2026 16:10
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.

Migrate detector LUTs to daq config server

3 participants