-
Notifications
You must be signed in to change notification settings - Fork 4
Ability to launch blueapi and run Hyperion plans #1389
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2b7daa2
Add load_centre_collect, robot_unload and udc_default_state blueapi p…
rtuck99 88687d6
Add some documentation for hyperion-blueapi
rtuck99 353efb9
Fixup imports
rtuck99 148b966
Updates to work with DeviceManager, BartRobot changes
rtuck99 a602469
Pin dodal
rtuck99 cf5b103
Make docs build happy
rtuck99 44c6150
Additional unit tests for blueapi plans
rtuck99 575614e
Fix incorrect blueapi config for production
rtuck99 51d279d
Merge remote-tracking branch 'origin/main' into hyperion_on_blueapi
rtuck99 f8aacea
Unpin main
rtuck99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| Hyperion on BlueAPI | ||
| =================== | ||
|
|
||
| This document describes the migration of Hyperion from a monolithic service that contains its own application server | ||
| and is only partially dependent on BlueAPI, | ||
| to a standard BlueAPI application deployment. | ||
|
|
||
| Architecture | ||
| ------------ | ||
|
|
||
| Hyperion on BlueAPI consists of two components: | ||
|
|
||
| * hyperion-blueapi: This is intended to ultimately be a standard blueapi installation, consisting of a beamline | ||
| module and a dodal plan module. In the interim, deployment may vary from the standard method until such time as | ||
| monolithic operation can be desupported. ``hyperion-blueapi`` exposes a minimal set of bluesky plans for UDC data | ||
| collection. | ||
|
|
||
| * hyperion-supervisor: This will be a separate service that is responsible for fetching instructions from | ||
| Agamemnon, decoding them and sending corresponding requests to ``hyperion-blueapi`` for execution. The supervisor | ||
| also monitors the state of ``hyperion-blueapi``, manages the Hyperion baton and provides endpoints for status | ||
| monitoring. | ||
|
|
||
| Deployment | ||
| ---------- | ||
|
|
||
| ``hyperion-blueapi`` is automatically available in a standard Hyperion deployment. | ||
|
|
||
| Launching | ||
| --------- | ||
|
|
||
| ``hyperion-blueapi`` can be launched in using the ``run_hyperion.sh`` script, using the ``--blueapi`` option: | ||
|
|
||
| :: | ||
|
|
||
| ./run_hyperion.sh --beamline=i03 --dev --blueapi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| env: | ||
| sources: | ||
| - kind: deviceManager | ||
| module: dodal.beamlines.i03 | ||
| - kind: planFunctions | ||
| module: mx_bluesky.hyperion.blueapi_plans | ||
| events: | ||
| broadcast_status_events: false | ||
| api: | ||
| url: http://localhost:5005 | ||
| cors: | ||
| allow_credentials: True | ||
| origins: | ||
| - "*" | ||
| logging: | ||
| graylog: | ||
| url: "tcp://graylog-log-target.diamond.ac.uk:12232" | ||
| enabled: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| env: | ||
| sources: | ||
| - kind: deviceManager | ||
| module: dodal.beamlines.i03 | ||
| mock: true | ||
| - kind: planFunctions | ||
| module: mx_bluesky.hyperion.blueapi_plans | ||
| events: | ||
| broadcast_status_events: false | ||
| api: | ||
| url: http://localhost:5005 | ||
| cors: | ||
| allow_credentials: True | ||
| origins: | ||
| - "*" | ||
| logging: | ||
| level: DEBUG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| """ | ||
| This module contains the bluesky plan entry points for use with hyperion-blueapi. | ||
| The json schema and documentation therein generated by the blueapi /plans endpoint | ||
| from this file constitutes the hyperion-blueapi interface to the hyperion supervisor | ||
| process. | ||
| """ | ||
|
|
||
| from bluesky.utils import MsgGenerator | ||
| from dodal.common import inject | ||
| from dodal.devices.aperturescatterguard import ApertureScatterguard | ||
| from dodal.devices.motors import XYZStage | ||
| from dodal.devices.robot import BartRobot | ||
| from dodal.devices.smargon import Smargon | ||
|
|
||
| from mx_bluesky.common.device_setup_plans.robot_load_unload import ( | ||
| robot_unload as _robot_unload, | ||
| ) | ||
| from mx_bluesky.hyperion.experiment_plans.load_centre_collect_full_plan import ( | ||
| LoadCentreCollectComposite, | ||
| ) | ||
| from mx_bluesky.hyperion.experiment_plans.load_centre_collect_full_plan import ( | ||
| load_centre_collect_full as _load_centre_collect_full, | ||
| ) | ||
| from mx_bluesky.hyperion.experiment_plans.udc_default_state import ( | ||
| UDCDefaultDevices, | ||
| ) | ||
| from mx_bluesky.hyperion.experiment_plans.udc_default_state import ( | ||
| move_to_udc_default_state as _move_to_udc_default_state, | ||
| ) | ||
| from mx_bluesky.hyperion.parameters.load_centre_collect import LoadCentreCollect | ||
|
|
||
| __all__ = [ | ||
| "LoadCentreCollectComposite", | ||
| "LoadCentreCollect", | ||
| "UDCDefaultDevices", | ||
| "load_centre_collect", | ||
| "move_to_udc_default_state", | ||
| "robot_unload", | ||
| ] | ||
|
|
||
|
|
||
| def load_centre_collect( | ||
| parameters: LoadCentreCollect, composite: LoadCentreCollectComposite = inject() | ||
| ) -> MsgGenerator: | ||
| """ | ||
| Attempt a complete data collection experiment, consisting of the following: | ||
| * Load the sample if necessary | ||
| * Move to the specified goniometer start angles | ||
| * Perform optical centring, then X-ray centring | ||
| * If X-ray centring finds one or more diffracting centres then for each centre | ||
| that satisfies the chosen selection function, | ||
| move to that centre and do a collection with the specified parameters. | ||
| """ | ||
| yield from _load_centre_collect_full(composite, parameters) | ||
|
|
||
|
|
||
| def robot_unload( | ||
| visit: str, | ||
| robot: BartRobot = inject("robot"), | ||
| smargon: Smargon = inject("smargon"), | ||
| aperture_scatterguard: ApertureScatterguard = inject("aperture_scatterguard"), | ||
| lower_gonio: XYZStage = inject("lower_gonio"), | ||
| ) -> MsgGenerator: | ||
| """ | ||
| Unload the currently mounted pin into the location that it was loaded from. | ||
| This is to be invoked as the final step upon successful completion of the UDC queue. | ||
| """ | ||
| yield from _robot_unload(robot, smargon, aperture_scatterguard, lower_gonio, visit) | ||
|
|
||
|
|
||
| def move_to_udc_default_state( | ||
| composite: UDCDefaultDevices = inject(), | ||
| ) -> MsgGenerator: | ||
| """ | ||
| Move beamline hardware to known positions prior to UDC start. | ||
| """ | ||
| yield from _move_to_udc_default_state(composite) |
5 changes: 5 additions & 0 deletions
5
tests/test_data/hyperion_blueapi/move_to_udc_default_state.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "move_to_udc_default_state", | ||
| "params": {}, | ||
| "instrument_session": "cm12345-1" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "robot_unload", | ||
| "params": { | ||
| "visit": "cm12345-1" | ||
| }, | ||
| "instrument_session": "cm12345-1" | ||
| } | ||
56 changes: 56 additions & 0 deletions
56
tests/test_data/hyperion_blueapi/test_load_centre_collect.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| { | ||
| "name": "load_centre_collect", | ||
| "params": { | ||
| "parameters": { | ||
| "parameter_model_version": "5.0.0", | ||
| "beamline": "BL03S", | ||
| "det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt", | ||
| "insertion_prefix": "SR03S", | ||
| "visit": "cm31105-4", | ||
| "detector_distance_mm": 255, | ||
| "sample_id": 12345, | ||
| "sample_puck": 40, | ||
| "sample_pin": 3, | ||
| "robot_load_then_centre": { | ||
| "storage_directory": "{tmp_data}/123458/xraycentring", | ||
| "file_name": "robot_load_centring_file", | ||
| "comment": "Robot load and centre", | ||
| "exposure_time_s": 0.004, | ||
| "use_roi_mode": false, | ||
| "demand_energy_ev": 11100, | ||
| "run_number": 0, | ||
| "panda_runup_distance_mm": 0.17, | ||
| "box_size_um": 20 | ||
| }, | ||
| "multi_rotation_scan": { | ||
| "comment": "Rotation", | ||
| "storage_directory": "{tmp_data}/123458/", | ||
| "file_name": "file_name", | ||
| "exposure_time_s": 0.004, | ||
| "selected_aperture": "SMALL_APERTURE", | ||
| "transmission_frac": 1.0, | ||
| "demand_energy_ev": 11100, | ||
| "rotation_increment_deg": 0.1, | ||
| "shutter_opening_time_s": 0.6, | ||
| "snapshot_omegas_deg": [ | ||
| 0, | ||
| 90, | ||
| 180, | ||
| 270 | ||
| ], | ||
| "run_number": 1, | ||
| "rotation_scans": [ | ||
| { | ||
| "rotation_axis": "omega", | ||
| "rotation_direction": "Negative", | ||
| "scan_width_deg": 180.0, | ||
| "omega_start_deg": 0, | ||
| "phi_start_deg": 0.47, | ||
| "chi_start_deg": 23.85 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "instrument_session": "cm12345-1" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is visit needed as well as instrument session?
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.
instrument_session is needed by blueapi. It is now exposed to callbacks in the run engine metadata. I think in future we will be able to get rid of the visit parameter, but we will need to update the callbacks, once everyone is on blueapi I think we can do this.