Skip to content

Conversation

Villtord
Copy link
Contributor

@Villtord Villtord commented Sep 15, 2025

Fixes DiamondLightSource/sm-bluesky#124

Instructions to reviewer on how to test:

  1. Check hard-x-ray undulator class logic is reasonable
  2. Confirm tests pass

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}

@Villtord Villtord linked an issue Sep 15, 2025 that may be closed by this pull request
Copy link

codecov bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.88%. Comparing base (264e738) to head (41e1645).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1531   +/-   ##
=======================================
  Coverage   98.88%   98.88%           
=======================================
  Files         260      262    +2     
  Lines        9468     9526   +58     
=======================================
+ Hits         9362     9420   +58     
  Misses        106      106           

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

@Villtord Villtord changed the base branch from main to shared_beamline_module_dodal_connect_improvements September 16, 2025 15:05
@Villtord Villtord changed the base branch from shared_beamline_module_dodal_connect_improvements to main September 16, 2025 15:09
@Villtord Villtord marked this pull request as ready for review September 16, 2025 15:15
@Villtord Villtord requested a review from a team as a code owner September 16, 2025 15:15
Copy link
Contributor

@oliwenmandiamond oliwenmandiamond left a comment

Choose a reason for hiding this comment

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

Looks really good, thanks for doing this. Just some minor typing improvements

Comment on lines 162 to 164
name: str = "",
poles: int | None = None,
length: float | None = None,
Copy link
Contributor

@oliwenmandiamond oliwenmandiamond Sep 30, 2025

Choose a reason for hiding this comment

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

Suggested change
name: str = "",
poles: int | None = None,
length: float | None = None,
poles: int | None = None,
length: float | None = None,
name: str = "",

The name should be last so that we can still provide other arguments otherwise we have to do this

with init_devices():
     hu = HardUndulator(prefix, order, id_gap_lookup_table_path, calculate_gap_function, poles=poles, length=length)

await self._check_order_valid(value)
await self._order.set(value)

async def _check_order_valid(self, value: int):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
async def _check_order_valid(self, value: int):
async def _check_order_valid(self, value: int) -> None:

await self._check_energy_limits(value)
await self._set_undulator_gap(value)

async def _check_energy_limits(self, value: float):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
async def _check_energy_limits(self, value: float):
async def _check_energy_limits(self, value: float) -> None:

undulator_period_mm=await self.undulator_period.get_value(),
)

async def _update_cached_lookup_table(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
async def _update_cached_lookup_table(self):
async def _update_cached_lookup_table(self) -> None:

@Villtord
Copy link
Contributor Author

Villtord commented Oct 1, 2025

Very sorry, I am moving it to Drafts as we discussed this needs some refactoring in terms of ID definition as we discussed today in our SMG meeting

@Villtord Villtord marked this pull request as draft October 1, 2025 11:26
@Villtord
Copy link
Contributor Author

Villtord commented Oct 6, 2025

Hi @DominicOram and @oliwenmandiamond ,
We had quite some discussions and I hope it is a better design now, sorry that it changed completely.
Short summary:

  1. I extract BaseUndulator class that accept gap [mm] value in set method. Undulator class then inherit from BaseUndulator and rewrites its set method to accept energy_kev value instead, calculate gap value internally and then call parent set method with gap value.
  2. Order class is now not required for any of undulator classes, however I leave it as it will be used in Energy class which is going to handle all convertion (that class is not in this PR).
  3. I still include energy-to-gap conversion function and LUT table unique to I09 hard-x-ray id in this PR as I spent too much time on decoding it (apologies).

@Villtord Villtord marked this pull request as ready for review October 6, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add hard x-ray id new class for i09
3 participants