Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Conversation

@d-perl
Copy link
Contributor

@d-perl d-perl commented Mar 16, 2023

Fixes #554

Link to dodal PR (if required): #25

To test:

  1. Check organisation/naming of oav code is sensible/coherent
  2. Run tests with both artemis and dodal branches

Copy link
Collaborator

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Thanks for making a start on this but I think it still needs more cleaning up from prototyping. I think to merge it we need at least a unit test against some fake devices to confirm the plan runs through. Can you also address all the musts.

Can you write up issues for the other comments if you don't address them here? I also think this doesn't address all of the things on the issue it links. I have ticked the ones I think it fixes, can you split the others out into new issues?

EXPERIMENT_TYPES = Union[GridScanParams, RotationScanParams]
PLAN_REGISTRY: Dict[str, Dict[str, Callable]] = {
"full_grid_scan": {
"setup": full_grid_scan.create_devices,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must: Without all these devices in S03 yet this now means that we can't start artemis on a developer machine any more. Not sure what the best solution is here, get some dummy devices into S03 ideally...

Comment on lines 66 to 67
width = 600
box_size_microns = 20
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: These should probably come in as parameters?

Comment on lines 186 to 187
yield from bps.abs_set(oav.snapshot.input_pv, parameters.input_plugin + ".CAM")
yield from bps.abs_set(oav.mxsc.enable_callbacks_pv, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: I think these need to be in a finally clause

Comment on lines 39 to 40
detector_motion = Det("BL03I", name="detector_motion")
backlight = Backlight("BL03I-EA-BL-01:", name="backlight")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: For the fgs plan we're passing the beamline in as a param, should probably do the same here

Comment on lines 47 to 59
def wait_for_det_to_finish_moving(detector: Det, timeout=2):
LOGGER.info("Waiting for detector to finish moving")
SLEEP_PER_CHECK = 0.1
times_to_check = int(timeout / SLEEP_PER_CHECK)
for _ in range(times_to_check):
detector_state = yield from bps.rd(detector.shutter)
detector_z_dmov = yield from bps.rd(detector.z.motor_done_move)
LOGGER.info(f"Shutter state is {'open' if detector_state==1 else 'closed'}")
LOGGER.info(f"Detector z DMOV is {detector_z_dmov}")
if detector_state == 1 and detector_z_dmov == 1:
return
yield from bps.sleep(SLEEP_PER_CHECK)
raise Exception("Detector not finished moving")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: This is much like the waiting for fast grid scan to be valid, e.g. messy and horrible. I think we need to put it in the device side probably? Certainly refactor it to be more Bluesky idiomatic

Comment on lines 7 to 8
Returns the scale of the image. The standard calculation for the image is based
on a size of (1024, 768) so we require these scaling factors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: This comment is not correct in that we don't use the scaling factors

- oav cleanup into finally
- update for pv names
- factor out params
@d-perl d-perl marked this pull request as draft March 30, 2023 09:30
@d-perl
Copy link
Contributor Author

d-perl commented Mar 30, 2023

Fair enough, in that case, I'd like to get #595 merged first, since changes there will affect the work that needs to be done here quite a lot

@codecov
Copy link

codecov bot commented Apr 6, 2023

Codecov Report

Merging #584 (5486d9d) into main (89ada29) will increase coverage by 8.32%.
The diff coverage is 94.79%.

@@            Coverage Diff             @@
##             main     DiamondLightSource/hyperion#584      +/-   ##
==========================================
+ Coverage   81.68%   90.01%   +8.32%     
==========================================
  Files          30       32       +2     
  Lines        1376     1412      +36     
==========================================
+ Hits         1124     1271     +147     
+ Misses        252      141     -111     
Impacted Files Coverage Δ
src/artemis/utils/utils.py 100.00% <ø> (ø)
src/artemis/experiment_plans/full_grid_scan.py 89.79% <89.79%> (ø)
...rtemis/experiment_plans/oav_grid_detection_plan.py 96.15% <96.15%> (ø)
src/artemis/device_setup_plans/setup_oav.py 97.43% <97.43%> (ø)
...rc/artemis/experiment_plans/experiment_registry.py 93.75% <100.00%> (-6.25%) ⬇️
...rc/artemis/experiment_plans/fast_grid_scan_plan.py 82.43% <100.00%> (-4.06%) ⬇️
...ernal_interaction/callbacks/fgs/zocalo_callback.py 98.46% <100.00%> (ø)
...emis/external_interaction/ispyb/ispyb_dataclass.py 100.00% <100.00%> (ø)
...temis/external_interaction/ispyb/store_in_ispyb.py 96.92% <100.00%> (ø)
.../external_interaction/zocalo/zocalo_interaction.py 97.14% <100.00%> (ø)
... and 1 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@d-perl d-perl marked this pull request as ready for review May 11, 2023 09:24
@d-perl d-perl requested a review from DominicOram May 11, 2023 09:24
Copy link
Collaborator

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Looks good, thanks. I tried to spin out as much as possible into other issues, what's left is things we can hopefully quickly fix now

) = cli_arg_parse()

artemis.log.set_up_logging_handlers(logging_level, dev_mode)
dodal_logging_setup(logging_level, dev_mode)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: I don't think this is needed, artemis.log.set_up_logging_handlers calls it for you

# Set the python file to use for calculating the edge waveforms
current_filename = yield from bps.rd(oav.mxsc.filename)
if current_filename != filename:
LOGGER.info(f"Current python file is {current_filename}, setting to {filename}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Message should mention that this is the coming form the OAV, it's not clear without context

mock_setup.assert_called_once()


@pytest.mark.skip("fixed in 595")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: In #595? This is already merged, so we should remove this skip

min_y = np.min(top_edge[top_edge != 0])
max_y = np.max(bottom_edge[bottom_edge != full_oav_image_height_px])
LOGGER.info(f"Min/max {min_y, max_y}")
# if top and bottom empty after filter use the whole image (ask neil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: Neil said yes, we can remove the comment to ask him

}

oav_params = OAVParameters("xrayCentring")
oav_params = OAVParameters("loopCentring", **oav_param_files)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: I think there is an issue using loopCentring here, spun out into #653

Copy link
Collaborator

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Great, thanks for the additional tests

@DominicOram DominicOram merged commit 4812b1f into main May 12, 2023
@DominicOram DominicOram deleted the 554_tidy_oav branch May 12, 2023 11:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tidy up OAV devices and grid plan

3 participants