-
Notifications
You must be signed in to change notification settings - Fork 2
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
595 write to ispyb sample status after collection #625
base: lightweight-events
Are you sure you want to change the base?
595 write to ispyb sample status after collection #625
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## lightweight-events #625 +/- ##
======================================================
+ Coverage 80.11% 80.19% +0.08%
======================================================
Files 98 99 +1
Lines 6845 6949 +104
======================================================
+ Hits 5484 5573 +89
- Misses 1361 1376 +15
|
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.
Great, thanks. Really like the additional system tests! I think we could have a few more unit tests alongside them to test more of the code paths though
@@ -105,8 +108,13 @@ def grid_detection_plan( | |||
# See #673 for improvements | |||
yield from bps.sleep(CONST.HARDWARE.OAV_REFRESH_DELAY) | |||
|
|||
tip_x_px, tip_y_px = yield from catch_exception_and_warn( |
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: With this removed catch_exception_and_warn
is never used other than here, can we just re purpose it to raise a SampleException
rather than WarningException
then keep the call here?
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.
Alternatively we can remove catch_exception_and_warn
as it's no longer needed but I like having this behind a function as it's a bit confusing at first glance.
# Below causes close_run not received before open_run in _open_run | ||
# @set_run_key_decorator(CONST.PLAN.LOAD_CENTRE_COLLECT) | ||
# @run_decorator(md={"metadata": {"sample_id": params.sample_id}, | ||
# "activate_callbacks": ["SampleHandlingCallback"]}) | ||
# @sample_handling_callback_decorator() |
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 commented out code is exactly what is written below? What is the comment trying to tell me?
PinNotFoundException, wait_for_tip_to_be_found, pin_tip_detection | ||
def wrap_exception(e: Exception) -> Generator[Msg, Any, Any]: | ||
if isinstance(e, PinNotFoundException): | ||
raise SampleException(str(e)) |
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:
raise SampleException(str(e)) | |
raise SampleException from e |
will give better chaining information
|
||
|
||
class SampleHandlingCallback(PlanReactiveCallback): | ||
"""Intercepts""" |
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 we have a nicer docstring please?
if not exit_status: | ||
reason = "Exit status not available in stop document!" | ||
elif not self._metadata: | ||
reason = "Metadata not received before stop document." | ||
else: | ||
reason = doc.get("reason") or "OK" |
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: I agree with codcov that some unit tests around this would be good.
bl_sample_status: str | None | ||
|
||
|
||
class ExpeyeSampleHandlingInteraction: |
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: I think some unit tests on this would be good, even if they're just smoke tests really
def _record_exception(self, exception_type: str): | ||
expeye = ExpeyeSampleHandlingInteraction() | ||
assert self._sample_id, "Unable to record exception due to no sample ID" | ||
sample_status = self._decode_sample_status(exception_type) | ||
expeye.update_sample_status(self._sample_id, sample_status) | ||
|
||
def _decode_sample_status(self, exception_type: str) -> BLSampleStatus: |
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: Would be good to have a couple of tests covering these functions
sample_handling_callback_decorator = make_decorator( | ||
partial(contingency_wrapper, except_plan=_exception_interceptor) | ||
) |
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 like this, does a good job of hiding the shenanigans
set_mock_value( | ||
ophyd_pin_tip_detection.triggered_top_edge, | ||
numpy.array([]), | ||
) | ||
|
||
set_mock_value( | ||
ophyd_pin_tip_detection.triggered_bottom_edge, | ||
numpy.array([]), | ||
) |
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: We don't nee to set the edges to []
here for the pin tip to not be found
|
||
|
||
@pytest.fixture(autouse=True) | ||
def use_real_ispyb(): |
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:
def use_real_ispyb(): | |
def use_dev_ispyb(): |
I have also just been told about #636. I think it probably makes sense to assume the new endpoints for this issue |
7b43714
to
1ff6b78
Compare
…ack.py. Add SampleExceptionStatus
… of run-key decorators/wrappers
ccf3dcf
to
bd50284
Compare
Fixes #595
Requires #606
The
blSampleStatus
field in ispyb will now be updated on successful robot load toLOADED
, when theload_centre_collect
plan is used.In the event of the pin not being found or no diffraction,
blSampleStatus
will be updated toERROR - sample
to indicate an issue with the sampleIf any other error occurs,
blSampleStatus
will be updated toERROR - beamline
to indicate a general problem with the beamline.On normal completion the
blSampleStatus
will be left atLOADED