-
Notifications
You must be signed in to change notification settings - Fork 5
Final tidy of the great ispyb refactor #1268
Final tidy of the great ispyb refactor #1268
Conversation
@@ -56,6 +68,8 @@ def __init__( | |||
self.log = ISPYB_LOGGER | |||
|
|||
def activity_gated_start(self, doc: RunStart): | |||
self._event_driven_data_collection_info = DataCollectionInfo() | |||
self._sample_barcode = 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.
This may be a bug because this will get called on every activity start while we are active not just the one where we are activated, thus we may end up erasing our data before we write it
20d7c37
to
6a2a0a9
Compare
37e8849
to
266070d
Compare
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.
Half a review, can further discuss in person
@@ -178,6 +178,7 @@ def robot_load_then_centre( | |||
yield from read_energy(cast(SetEnergyComposite, composite)) | |||
) | |||
|
|||
# XXX TODO 1173 remove this - left in to avoid breaking nexus 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.
Created #1292 to remove this in a new PR
dcg_info = populate_data_collection_group( | ||
self.ispyb.experiment_type, | ||
params.hyperion_params.detector_params, | ||
def populate_info_for_update( |
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: Why are we putting the info from the start doc back into this object? Happy to discuss in person
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.
Discussed and fixed in #1279
@@ -178,6 +178,7 @@ def robot_load_then_centre( | |||
yield from read_energy(cast(SetEnergyComposite, composite)) | |||
) | |||
|
|||
# XXX TODO 1173 remove this - left in to avoid breaking nexus 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.
Created #1292 to remove this in a new PR
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, thank you! Made some comments but mostly quite minor in the end as I've pulled the bigger stuff into new issues
@@ -356,6 +356,7 @@ def flyscan_xray_centre( | |||
@transmission_and_xbpm_feedback_for_collection_decorator( | |||
composite.xbpm_feedback, | |||
composite.attenuator, | |||
# TODO 1033 don't use ispyb_params for this value, move it to experiment_params |
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: 1033 is now merged, I think this will be removed when you merge main into the PR?
dcg_info = populate_data_collection_group( | ||
self.ispyb.experiment_type, | ||
params.hyperion_params.detector_params, | ||
def populate_info_for_update( |
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.
Discussed and fixed in #1279
@@ -220,6 +220,7 @@ def test_remote_callbacks_write_to_dev_ispyb_for_rotation( | |||
test_rotation_params.hyperion_params.ispyb_params.beam_size_x = test_bs_x | |||
test_rotation_params.hyperion_params.ispyb_params.beam_size_y = test_bs_y | |||
test_rotation_params.hyperion_params.detector_params.exposure_time = test_exp_time | |||
# TODO this should not be set 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.
Should: What does this comment mean? What's the path to fixing it?
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.
# TODO Can't test barcode as need BLSample which needs Dewar, Shipping, Container entries for the | ||
# upsert stored proc to use it. |
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: The barcode is on the data collection group, I think we can test that. But also that will probably be removed soon anyway with #1293
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.
When you do an upsert_dc_group
the sproc executes the following (or something similar):
IF p_sampleId IS NULL AND p_sampleBarcode IS NOT NULL THEN
SELECT max(bls.blSampleId) INTO p_sampleId
FROM BLSample bls
INNER JOIN Container c on c.containerId = bls.containerId
INNER JOIN Dewar d on d.dewarId = c.dewarId
INNER JOIN Shipping s on s.shippingId = d.shippingId
WHERE bls.code = p_sampleBarcode AND s.proposalId = row_proposal_id;
Therefore the insert will not do anything unless you have all those things
The DCG upsert puts a barcode into a column called actualSampleBarcode
, there isn't a column which is just called sampleBarcode, sampleBarcode
is just used to lookup the sampleId
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.
This is good to know. So basically setting sampleBarcode
is just another way of setting the sampleId
, which we are doing anyway.
@@ -805,3 +816,11 @@ def test_tidy_up_plans_disable_panda_and_zebra( | |||
RE(tidy_up_plans(MagicMock())) | |||
mock_panda_tidy.assert_called_once() | |||
mock_zebra_tidy.assert_called_once() | |||
|
|||
|
|||
def assert_event(mock_call, expected): |
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 just use the one in the conftest?
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, it seems I created both of them at pretty much the same time, so suspect I got distracted whilst moving it and just forgot
), | ||
dummy_params.hyperion_params.detector_params, | ||
dummy_params.hyperion_params.ispyb_params, | ||
def scan_data_info_for_begin(): |
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: I think it would be nicer if we could combine some of the common bits of these test helper functions that make ScanDataInfo
and DataCollectionInfo
as they're very verbose but I appreciate this makes it more explicit so up to you.
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.
Thinking maybe I should remove this file if we don't support 2D gridscans!
@@ -289,6 +289,7 @@ def panda_flyscan_xray_centre( | |||
@transmission_and_xbpm_feedback_for_collection_decorator( | |||
composite.xbpm_feedback, | |||
composite.attenuator, | |||
# TODO 1033 don't use ispyb_params for this value, move it to experiment_params | |||
parameters.hyperion_params.ispyb_params.transmission_fraction, |
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.
As above
# TODO 1173 Remove this once nexus_utils no longer needs it | ||
self.params.hyperion_params.ispyb_params.transmission_fraction = doc[ | ||
"data" | ||
]["attenuator_actual_transmission"] |
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 this disappears on merge?
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.
No it doesn't but I will remove them.
E: on reflection I will do that in a separate PR re new ticket #1295
convert_eV_to_angstrom(energy_ev) | ||
) | ||
# TODO 1173 Remove this once nexus_utils no longer needs wavelength_angstroms | ||
self.params.hyperion_params.ispyb_params.current_energy_ev = energy_ev |
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.
Created #1292 to remove this in a new PR
data_collection_group_id=data_collection_group_id, | ||
data_collection_ids=(data_collection_id,), | ||
ispyb_ids = IspybIds() | ||
if scan_data_info.data_collection_info: |
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.
The creating/updating of groups is very complicated, I've made #1293 to simplify
* Remove dependencies on populate_ methods * Move some tests down to the callback mapping layer * Populate test fixtures by direct parameter construction instead of duplicating caller logic * Remove dependencies on dummy_params from unit tests
…emaining_data_collection_info() Additional unit tests for callbacks
…due to nexus callback * Correct references to current_energy_ev in various test.json files as it is now called expected_energy_ev
266070d
to
5b83260
Compare
…ODOs as per PR feedback
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, thank you!
Failing test is also failing on main so will merge this anyway and fix in a new PR |
…Source/1218_final_tidy_of_the_great_ispyb_refactor Final tidy of the great ispyb refactor
Fixes #1218
Link to dodal PR (if required): #XXX
(remember to update
setup.cfg
with the dodal commit tag if you need it for tests to pass!)To test: