-
Notifications
You must be signed in to change notification settings - Fork 10
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
Crystal metadata change #843
Conversation
the error has to do with crystal spacing values |
What is the reason for this change? |
@callumforrester this is a refactor as Neater for the |
@stan-dot I have raised a PR #870 which targets this branch and extends these changes onto the I03 DCM, as a prerequisite for DiamondLightSource/mx-bluesky#520
|
thanks @rtuck99 , merged |
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 Stan. Looks like i18 has the PVs now. Some comments in code though
<<<<<<< HEAD
async def test_crystal_metadata_not_propagated_when_not_supplied():
async with DeviceCollector(mock=True):
dcm = DoubleCrystalMonochromator(
prefix="FOO-MO",
temperature_prefix="FOO-DI",
crystal_1_metadata=None,
crystal_2_metadata=None,
)
configuration = await dcm.read_configuration()
expected_absent_keys = {
"crystal-1-usage",
"crystal-1-type",
"crystal-1-reflection",
"crystal-1-d_spacing",
"crystal-2-usage",
"crystal-2-type",
"crystal-2-reflection",
"crystal-2-d_spacing",
}
assert expected_absent_keys.isdisjoint(configuration)
=======
>>>>>>> e8ac54553 (add to the beamline files)
@DominicOram all is fixed besides this test. I am not sure what is the purpose of the behavior here to have absent keys. For it to pass the metadata param in the DCM init would need to be I'm happy to delete the test, git blame points last modification to the test, for May 2024 by @callumforrester - what is the reason for the test? I'm equally happy to keep the test and change the behavior provided I note the reason for allowing |
Ok, I'm happy to retract https://github.com/DiamondLightSource/dodal/pull/843/files#r1820621900 so that we can keep this usecase. I'm still not 100% sure when it would be necessary but that's scope creep. |
@DominicOram I'm afraid I don't understand your last comment |
c46f234
to
6ee887d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #843 +/- ##
==========================================
+ Coverage 95.60% 95.61% +0.01%
==========================================
Files 125 126 +1
Lines 5229 5242 +13
==========================================
+ Hits 4999 5012 +13
Misses 230 230 ☔ View full report in Codecov by Sentry. |
377c46c
to
999c1b0
Compare
Previously this was hard coded to be a static float in milimeters for some reason, forgot to update this for this PR
* Implement crystal metadata for I03 DCM * Make type-checking happy
854a2c5
to
b489f57
Compare
self.crystal_metadata_reflection, _ = soft_signal_r_and_setter(
Sequence[int],
initial_value=list(cm.reflection), # type: ignore
)
I think this might be due to ophyd-async change - this is in the 'dcm' device |
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 @stan-dot. Couple of minor queries, I think I may have misunderstood a previous discussion.
d_spacing: tuple[float, str] | ||
|
||
@staticmethod | ||
def calculate_default_d_spacing( |
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: Sorry, maybe I've misunderstood, I thought the conclusion of the discussion at #843 (comment) was to remove all this calculation and use the PV? Or is it not yet on i22?
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.
If the PV isn't on i22 yet then I said in that comment, can we get the ball rolling on that?
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 discussion was to add the PV on i18, which ultimately just was a slight name change.
regarding the static method
self.crystal_metadata_d_spacing = epics_signal_r(float, "DSPACING:RBV")
at the moment there is the PV value used. I might have mistaken with the line above where the 'initial value' is used.
at the moment the only place when the calculation is used is in the make_crystal_metadata_from_material
where if the d_spacing is not supplied by the user, it's calculated.
we could remove it and make it required
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.
Ok, so we still need it in there for i22. That's fine, I'll make a note on the conversion issue.
src/dodal/devices/i22/dcm.py
Outdated
@@ -74,63 +61,45 @@ def __init__( | |||
|
|||
# Soft metadata | |||
# If supplied include crystal details in output of read_configuration | |||
crystal_1_metadata = crystal_1_metadata or CrystalMetadata() | |||
crystal_2_metadata = crystal_2_metadata or CrystalMetadata() | |||
with self.add_children_as_readables(ConfigSignal): | |||
if crystal_1_metadata.usage is not 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.
Should: If we've now removed the option for these to be None
then I don't think we need to check them all?
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.
removed
tests/devices/unit_tests/test_dcm.py
Outdated
async def test_metadata_reflection(dcm: DCM): | ||
signal = dcm.crystal_metadata_reflection | ||
v = await signal.read() | ||
print(v) |
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: It's not best practice to leave print statements in code
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.
Looks good to me, thank you!
Code extracted from https://github.com/DiamondLightSource/dodal/pull/722/files
I don't quite understand why do we set this as a soft signal - that is one failing test at the moment
And I deleted one test too