Skip to content

Conversation

@EmsArnold
Copy link
Contributor

Adds load and save plans for spectroscopy detector, with unit tests.

@codecov
Copy link

codecov bot commented Sep 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (338d5f8) to head (85b23d6).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #19   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           65        67    +2     
=========================================
+ Hits            65        67    +2     

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

@EmsArnold EmsArnold marked this pull request as ready for review September 3, 2025 14:19
description=f"Sum of {roi.name} channel",
)
]
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

The NDAttribute setup should stay in code. We don't want to have to edit the xml by hand to update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the ROIs are consistent, would the xml not also be consistent? I understand at the moment it's only saved for red, but I can easily re-generate the .yaml once #18 has been merged

yield from load_settings(spectroscopy_detector, yaml_directory, yaml_filename)

for motor in [sample_stage.x, sample_stage.y]:
yield from bps.mv(
Copy link
Contributor

Choose a reason for hiding this comment

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

These motor settings should be included

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we want to include motor settings that will be a separate settings yaml - not a problem but will involve expanding the issue to encompass saving/loading baseline states of devices in general, rather than just the spectroscopy detector

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that seems reasonable

Copy link
Contributor

Choose a reason for hiding this comment

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

I might suggest handling the panda separately, since ophyd-async does

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean handle the motors separately?

Copy link
Contributor

Choose a reason for hiding this comment

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

No I mean the panda, but looking more closely ophyd-async only special cases it on load, not save https://github.com/bluesky/ophyd-async/blob/main/src/ophyd_async/plan_stubs/__init__.py.

@EmsArnold EmsArnold marked this pull request as draft September 5, 2025 12:42
yield from load_settings(spectroscopy_detector, yaml_directory, yaml_filename)

for motor in [sample_stage.x, sample_stage.y]:
yield from bps.mv(
Copy link
Contributor

Choose a reason for hiding this comment

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

I might suggest handling the panda separately, since ophyd-async does

callback_on_mock_put(detector.driver.acquire, on_acquire)


def test_save_settings(RE: RunEngine):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: Assert that the file appears in /tmp

)


def test_load_settings(RE: RunEngine):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: Assert that mock signal values now match the settings

roistat.enable_callbacks: Enable
roistat.nd_array_address: 0
roistat.nd_array_port: D2.CAM
roistat.nd_attributes_file: <Attributes><Attribute name="&lt;ophyd_async.core._signal.SignalRW
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, this doesn't look right. Presumably this doesn't resolve itself when loading and it sends this as the actual value to the PV?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, presumably that's because of how I tried to pull the ROI names out - is there a way to interrogate these signals easily? I seem to be having trouble trying to read the signals in a local RE...

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure but I don't think it is a problem worth solving because we don't want this xml in the save file anyway. Or at least we don't want to load it.

@EmsArnold EmsArnold marked this pull request as ready for review September 23, 2025 10:51
Copy link
Contributor

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

LGTM! Can be merged once the conflicts are fixed.

def save_settings(
device: Device,
design_name: str,
design_directory: str = os.path.abspath("./src/test_rig_bluesky/"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still not thrilled about letting the user configure this, makes it harder for us to swap it out for a database in the future. I won't block merge over it though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it back in to allow the settings for testing to be saved in the testing directory. I'm sure there's a better way to do it but I'm not sure what that way is

Copy link
Contributor

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

Blocking pending conflict resolution and commit tidying

wait=True,
)
channel_name = yield from bps.rd(roistatn.name_)
print("channel_name")
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete

@EmsArnold EmsArnold merged commit 5b1c137 into main Sep 23, 2025
8 checks passed
@callumforrester callumforrester deleted the load_save_plans branch September 24, 2025 12:29
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.

4 participants