-
Notifications
You must be signed in to change notification settings - Fork 12
Migrate BeamlineParameters to use config server #1773
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
base: main
Are you sure you want to change the base?
Migrate BeamlineParameters to use config server #1773
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1773 +/- ##
==========================================
- Coverage 99.07% 99.07% -0.01%
==========================================
Files 294 295 +1
Lines 11207 11183 -24
==========================================
- Hits 11103 11079 -24
Misses 104 104 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
DominicOram
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good, some comments in code. This also means that we are now reliant on the config server so I think we need to do DiamondLightSource/mx-bluesky#478 before we put this on the beamline. Would you be able to pick that up and put in a meeting with Neil, Mark, Rob and Myself?
| from dodal.log import LOGGER | ||
| from dodal.utils import get_beamline_name | ||
|
|
||
| BEAMLINE_PARAMETER_KEYWORDS = ["FB", "FULL", "deadtime"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: This list is no longer used, can we remove it?
| ) | ||
|
|
||
|
|
||
| def get_beamline_parameters(beamline_param_path: str | None = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could: This is a bit of scope creep but the way we're doing this is a bit messy. I think we can do it like we do
dodal/src/dodal/beamlines/i03.py
Line 92 in d245f0a
| def daq_configuration_path() -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. So when devices need beamline parameters and before would have called get_beamline_parameters(), I'm guessing now they'd be passed in when the device is constructed.
How would this work when we need to get beamline parameters inside common plans? Or should these params always be attached to devices by that point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when devices need beamline parameters and before would have called get_beamline_parameters(), I'm guessing now they'd be passed in when the device is constructed.
Yes
How would this work when we need to get beamline parameters inside common plans? Or should these params always be attached to devices by that point?
Yh, that is a bit harder. I think we would need to have a look at it, which maybe means it should be in another issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a similar thing can be done for the config server itself? So have a get_config_server() in every ixx.py that returns a config client set up for that beamline
| return cls(params=dict(config_pairs)) | ||
|
|
||
| @classmethod | ||
| def from_file(cls, path: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It's a little misleading that this is still called from_file when it's not reading directly from the file
| @classmethod | ||
| def parse_value(cls, value: str): | ||
| return ast.literal_eval(value.replace("Yes", "True").replace("No", "False")) | ||
| config_server = ConfigServer(url="https://daq-config.diamond.ac.uk") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: Can you pull the URL into a constant? From DiamondLightSource/mx-bluesky#478 (comment) it may be that we will need it to be beamline specific too
tests/conftest.py
Outdated
| print(contents) | ||
| if desired_return_type is str: | ||
| return contents | ||
| elif desired_return_type is dict: | ||
| print("return type is dict") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: Remove print statements
| elif desired_return_type is dict: | ||
| print("return type is dict") | ||
| return json.loads(contents) | ||
| elif issubclass(desired_return_type, ConfigModel): # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: As far as I can see we're never trying to return a ConfigModel so why do we need this bit? Or is it for later PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is for later PRs. We either get a dict or a ConfigModel depending on what we request from the server, other config like LUTs or display config will be returned as a subclass of ConfigModel, this fixture emulates that
c87a30e to
3dbb881
Compare
Fixes DiamondLightSource/mx-bluesky#1504
Required by DiamondLightSource/mx-bluesky#1511
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}