-
Notifications
You must be signed in to change notification settings - Fork 2
Update spectroscopy plan to configure ROIs and motion settings #14
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
Conversation
callumforrester
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.
Looks good, mostly concurrency issues, I also think some more unit testing would be useful
| assert events["FINISHED"][0]["scanDimensions"] == [5] | ||
|
|
||
|
|
||
| def test_spectroscopy_re(): |
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: My only objection to putting tests like this back in is that I can't run them from my laptop over eduroam/vpn, which is very convenient. However if you think they add more value than take I won't block over this.
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.
I wrote this for two reasons:
- Blueapi was not working - maybe that is less likely to be the case in future?
- Passing the scanspec into the TaskRequest didn't seem to work. Do you have an example
of 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.
Can have a look at passing the scanspec into the request, for this we could use something like pytest-requires and then you could have @pytest.mark.requires("beamline network") or similar
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.
I suspect the reason the spec didn't work is because there is no type bound in the plan signature:
def spectroscopy(
spectroscopy_detector: AravisDetector = spectroscopy_detector,
sample_stage: XYZStage = sample_stage,
- spec: Spec | None = None,
+ spec: Spec[Movable] | None = None,
exposure_time: float = 0.1,
metadata: dict[str, Any] | None = None,
) -> MsgGenerator[None]:Specifying a bluesky type tells blueapi to resolve it as a special case (device or devices). I also made a PR on top of this PR that just skips tests like this if you're not on a beamline machine, up to you. https://github.com/DiamondLightSource/test-rig-bluesky/pull/17/files
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.
I have pulled in the PR.
So if I add Spec[Movable] I can do something like this?
_sample_stage = sample_stage()
scan_spec = Line(_sample_stage.x, 2, 5, 30) * Line(_sample_stage.y, 0, 5, 50)
events = bluesky_plan_runner.run(
TaskRequest(
name="demo_spectroscopy",
params={"spec": scan_spec.serialize()},
instrument_session=latest_commissioning_instrument_session,
),
timeout=10,
)I can't test currently because rabbit mq is not running.
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.
Yes, I believe that should work
src/test_rig_bluesky/plans.py
Outdated
| yield from bps.abs_set(roistatn.name_, roi.name) | ||
| yield from bps.abs_set(roistatn.min_x, roi.start_x) | ||
| yield from bps.abs_set(roistatn.min_y, roi.start_y) | ||
| yield from bps.abs_set(roistatn.size_x, roi.size) | ||
| yield from bps.abs_set(roistatn.size_y, roi.size) | ||
| yield from bps.abs_set(roistatn.use, True) |
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.
Must: These won't block until put complete so could lead to race conditions, you could instead:
| yield from bps.abs_set(roistatn.name_, roi.name) | |
| yield from bps.abs_set(roistatn.min_x, roi.start_x) | |
| yield from bps.abs_set(roistatn.min_y, roi.start_y) | |
| yield from bps.abs_set(roistatn.size_x, roi.size) | |
| yield from bps.abs_set(roistatn.size_y, roi.size) | |
| yield from bps.abs_set(roistatn.use, True) | |
| yield from bps.abs_set(roistatn.name_, roi.name, group="setup") | |
| yield from bps.abs_set(roistatn.min_x, roi.start_x, group="setup") | |
| yield from bps.abs_set(roistatn.min_y, roi.start_y, group="setup") | |
| yield from bps.abs_set(roistatn.size_x, roi.size, group="setup") | |
| yield from bps.abs_set(roistatn.size_y, roi.size, group="setup") | |
| yield from bps.abs_set(roistatn.use, True, group="setup") | |
| # This line blocks until all puts are complete | |
| yield from bps.wait(group="setup") |
OR
| yield from bps.abs_set(roistatn.name_, roi.name) | |
| yield from bps.abs_set(roistatn.min_x, roi.start_x) | |
| yield from bps.abs_set(roistatn.min_y, roi.start_y) | |
| yield from bps.abs_set(roistatn.size_x, roi.size) | |
| yield from bps.abs_set(roistatn.size_y, roi.size) | |
| yield from bps.abs_set(roistatn.use, True) | |
| bps.mv(roistatn.name_, roi.name, | |
| bps.abs_set(roistatn.min_x, roi.start_x, | |
| bps.abs_set(roistatn.min_y, roi.start_y, | |
| bps.abs_set(roistatn.size_x, roi.size, | |
| bps.abs_set(roistatn.size_y, roi.size, | |
| bps.abs_set(roistatn.use, True, | |
| wait=True, | |
| ) |
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.
Neat!
src/test_rig_bluesky/plans.py
Outdated
| spectroscopy_detector, TriggerInfo(livetime=exposure_time), wait=True | ||
| ) | ||
| # TODO: This would be nicer if NDArrayBaseIO had a PortName signal | ||
| yield from bps.abs_set(spectroscopy_detector.fileio.nd_array_port, "D2.roistat") |
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.
Must: This should block to avoid race conditions
| yield from bps.abs_set(spectroscopy_detector.fileio.nd_array_port, "D2.roistat") | |
| yield from bps.abs_set(spectroscopy_detector.fileio.nd_array_port, "D2.roistat", wait=True) |
src/test_rig_bluesky/plans.py
Outdated
| yield from bps.abs_set(motor.acceleration_time, 0.001) | ||
| yield from bps.abs_set(motor.velocity, 100) |
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.
Must: See above for suggestions on making these concurrent and blocking
|
What do we have to change here to make the unittests work after removing the path provider? |
f6619ff to
f322789
Compare
| yield from bps.mv( | ||
| bps.abs_set(roistatn.name_, roi.name), | ||
| bps.abs_set(roistatn.min_x, roi.start_x), | ||
| bps.abs_set(roistatn.min_y, roi.start_y), | ||
| bps.abs_set(roistatn.size_x, roi.size), | ||
| bps.abs_set(roistatn.size_y, roi.size), | ||
| bps.abs_set(roistatn.use, True), | ||
| wait=True, | ||
| ) |
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.
Does this work? I thought it had to be:
| yield from bps.mv( | |
| bps.abs_set(roistatn.name_, roi.name), | |
| bps.abs_set(roistatn.min_x, roi.start_x), | |
| bps.abs_set(roistatn.min_y, roi.start_y), | |
| bps.abs_set(roistatn.size_x, roi.size), | |
| bps.abs_set(roistatn.size_y, roi.size), | |
| bps.abs_set(roistatn.use, True), | |
| wait=True, | |
| ) | |
| yield from bps.mv( | |
| roistatn.name_, roi.name, | |
| roistatn.min_x, roi.start_x, | |
| roistatn.min_y, roi.start_y, | |
| roistatn.size_x, roi.size, | |
| roistatn.size_y, roi.size, | |
| roistatn.use, True, | |
| wait=True, | |
| ) |
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.
Ah. No I didn't try running after this change. I have updated it, but I still haven't tested it because I don't want to clash with anyone.
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.
I have now tested this, but only up to running spec_scan as we don't have GPFS currently.
d073c9e to
a8b65fd
Compare
a8b65fd to
b38e924
Compare
Add rule to skip tests that commuicate directly with hardware via EPICS unless the tests are run from one of a list of approved hosts that is known to have access to the b01-1 control system
b38e924 to
6de0f4a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 42 65 +23
=========================================
+ Hits 42 65 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Unit tests passing. System tests might not be. |
callumforrester
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.
LGTM! Thanks
No description provided.