-
Notifications
You must be signed in to change notification settings - Fork 11
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
add the docs to make a new device #579
Merged
stan-dot
merged 4 commits into
main
from
578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls
Jun 18, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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,63 @@ | ||||||
# Decision Flowchart for Creating a New ophyd_async Device | ||||||
|
||||||
This document contains decision flowcharts designed to guide developers through the process of creating a new device in the Dodal library. That is done using [ophyd-async](https://github.com/bluesky/ophyd-async) framework, the standard hardware abstraction library at Diamond. These flowcharts help in determining the appropriate class inheritance, methods to override, and testing procedures for optimal device functionality and integration into the system. | ||||||
|
||||||
## High-Level Development Flowchart | ||||||
|
||||||
The **objective** is to get it into main and then test it on the beamline! Ensuring fast iteration. You write the device, you assume you know how it works, you write tests against those assumptions, you merge. Then and only then do you test your assumptions on the beamline. If they were wrong, that's more issues. | ||||||
|
||||||
See if you can find a similar device that someone has already made. If one seems to exists but has different PV names, those can and should be changed. Advise consulting with controls. If the device is urgently needed, two copies can coexist but there must be an issue to reconcile. | ||||||
|
||||||
You might find the dodal CLI useful to verify the PV values. | ||||||
|
||||||
There's some of this already but more general advise not to do this task alone. Consult before starting, seek feedback early (e.g. draft PR) and merge with other people's devices where possible. The test suite should provide the confidence to do so without breaking anything. | ||||||
|
||||||
```{mermaid} | ||||||
|
||||||
flowchart TD | ||||||
highLevelStart([Start]) --> createIssue[Create Issue for New Device] | ||||||
createIssue --> scoutUsers[Scout current and potential users of the device, tag them in the issue] | ||||||
scoutUsers --> checkExistingDevices[Check if a similar device exists] | ||||||
checkExistingDevices -- "Exists but with different PV names" --> adviseConsultControls[Advise consulting with controls to change PV names] | ||||||
adviseConsultControls --> testPVs[Test PVs to get the right values] | ||||||
checkExistingDevices -- "No similar device" --> testPVs | ||||||
testPVs --> decideStateEnums[Decide on State Enums: extend str, Enum] | ||||||
decideStateEnums --> chooseMethods[Choose which superclass methods to override] | ||||||
chooseMethods --> finalizeDevice[Finalize Device Implementation] | ||||||
finalizeDevice --> requestFeedback[Request feedback from tagged users] | ||||||
requestFeedback --> rebaseOnMain[Rebase on main -> make sure tests pass still] | ||||||
rebaseOnMain --> coordinateMerges[Coordinate merges with other codebase updates] | ||||||
coordinateMerges --> markPRReady[Mark PR as ready] | ||||||
adviseConsultControls -- "Urgent need for device" --> createIssueForReconciliation[Create an issue to reconcile two versions later] | ||||||
createIssueForReconciliation --> testPVs | ||||||
|
||||||
``` | ||||||
|
||||||
## Interface Selection Flowchart | ||||||
|
||||||
See the chart in [ophyd-async](https://blueskyproject.io/ophyd-async/main/how-to/choose-interfaces-for-devices.html) | ||||||
|
||||||
## Testing Flowchart | ||||||
|
||||||
This flowchart outlines the testing procedure for the new ophyd_async device, from creating fixtures to testing state transitions and hardware integration. | ||||||
|
||||||
```{mermaid} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
flowchart TD | ||||||
testStart([Start Testing]) --> checkExistingFixtures[Check for existing fixtures] | ||||||
checkExistingFixtures --> createFixtures[Create or update fixtures for various states of the device] | ||||||
createFixtures --> createMockReactions[Create mock reactions to signals] | ||||||
createMockReactions --> testStateTransitions[Test each device state transition] | ||||||
testStateTransitions --> testPVValues[Check PV values to ensure accuracy] | ||||||
testPVValues --> testAgainstHardware[Test against hardware] | ||||||
testAgainstHardware --> decision{Check if all tests pass} | ||||||
decision -- "Yes" --> testingComplete[Testing Complete] | ||||||
decision -- "No" --> modifyCode[Modify code and update tests] | ||||||
modifyCode --> createFixtures | ||||||
|
||||||
|
||||||
``` | ||||||
|
||||||
## Additional Notes | ||||||
|
||||||
- `with self.add_children_as_readables():` Ensure this context manager is used appropriately in the device implementation to add child components as readable properties, but not Movables. |
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.
Could: Extra things that I think should also go in here:
main
and then test it on the beamline! Ensuring fast iteration. You write the device, you assume you know how it works, you write tests against those assumptions, you merge. Then and only then do you test your assumptions on the beamline. If they were wrong, that's more issues.