Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
1e9a569 to
1117a2d
Compare
| 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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/dodal/beamlines/i24.py
Outdated
|
|
||
|
|
||
| @devices.fixture | ||
| @cache |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Have removed the fixture and just call set_config_client now
Fixes DiamondLightSource/mx-bluesky#1509
Required by DiamondLightSource/mx-bluesky#1510
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}