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 27, 2023

Fixes #561 and fixes #588

Gets rid of FGSComposite in Dodal and reimplements it as a simple holder class in fast_grid_scan_plan with some config options
Dodal i03.py now manages device instantiation and this functionality is used in Artemis

Link to dodal PR (if required): #31

To test:

  1. Run tests

@d-perl d-perl mentioned this pull request Mar 30, 2023
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 much nicer, particularly with the eiger moved around, thanks. Minor comments in code

class FGSComposite:
"""A device consisting of all the Devices required for a fast gridscan."""

dcm: DCM
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: The FGS doesn't use the DCM or OAV, and we have no simulator for them so I think we should remove them from here

)
fast_grid_scan_composite.wait_for_connection()
with patch("dodal.i03.dcm"):
with patch("dodal.i03.oav"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Maybe add a comment here that we're patching it cos there's no simulator. We should remove the patch once we have merged DiamondLightSource/tickit-devices#27

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this since they are removed from fgs composite anyway

Comment on lines 203 to 240
@patch("dodal.i03.ApertureScatterguard")
@patch("dodal.i03.Backlight")
@patch("dodal.i03.DCM")
@patch("dodal.i03.EigerDetector")
@patch("dodal.i03.FastGridScan")
@patch("dodal.i03.OAV")
@patch("dodal.i03.S4SlitGaps")
@patch("dodal.i03.Smargon")
@patch("dodal.i03.Synchrotron")
@patch("dodal.i03.Undulator")
@patch("dodal.i03.Zebra")
@patch("artemis.experiment_plans.fast_grid_scan_plan.get_beamline_parameters")
def test_when_blueskyrunner_initiated_then_plans_are_setup_and_devices_connected(
mock_get_beamline_params, mock_fgs, mock_eiger
mock_get_beamline_params,
zebra,
undulator,
synchrotron,
smargon,
s4_slits,
oav,
fast_grid_scan,
eiger,
dcm,
backlight,
aperture_scatterguard,
):
BlueskyRunner(MagicMock())

mock_fgs.return_value.wait_for_connection.assert_called_once()
zebra.return_value.wait_for_connection.assert_called_once()
undulator.return_value.wait_for_connection.assert_called_once()
synchrotron.return_value.wait_for_connection.assert_called_once()
smargon.return_value.wait_for_connection.assert_called_once()
s4_slits.return_value.wait_for_connection.assert_called_once()
oav.return_value.wait_for_connection.assert_called_once()
fast_grid_scan.return_value.wait_for_connection.assert_called_once()
eiger.return_value.wait_for_connection.assert_not_called() # can't wait on eiger
dcm.return_value.wait_for_connection.assert_called_once()
backlight.return_value.wait_for_connection.assert_called_once()
aperture_scatterguard.return_value.wait_for_connection.assert_called_once()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Could we just patch dodal.i03 then use mock_i03.zebra.return_value.wait_for_connection.assert_called_once() etc. in the test, reduces complexity a bit

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 you mock dodal.i03 then the function which makes the devices doesn't exist

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Merging #595 (2f5324e) into main (69df05b) will increase coverage by 0.16%.
The diff coverage is 87.17%.

@@            Coverage Diff             @@
##             main     #595      +/-   ##
==========================================
+ Coverage   80.35%   80.52%   +0.16%     
==========================================
  Files          26       26              
  Lines        1405     1422      +17     
==========================================
+ Hits         1129     1145      +16     
- Misses        276      277       +1     
Impacted Files Coverage Δ
...ternal_interaction/callbacks/fgs/ispyb_callback.py 98.00% <ø> (ø)
...rc/artemis/experiment_plans/fast_grid_scan_plan.py 85.51% <86.84%> (+1.14%) ⬆️
...ernal_interaction/callbacks/fgs/zocalo_callback.py 98.46% <100.00%> (ø)

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

@d-perl d-perl requested a review from DominicOram April 5, 2023 11:49
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, thank you!

@DominicOram DominicOram merged commit 81297cc into main Apr 14, 2023
@DominicOram DominicOram deleted the 561_588_improve_dodal_and_its_use_in_artemis branch April 14, 2023 15:59
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.

Improve creation of devices - prevent duplicates Use dodal more idomatically

3 participants