Skip to content
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

Conversation

stan-dot
Copy link
Contributor

@stan-dot stan-dot commented May 28, 2024

Fixes #578

Instructions to reviewer on how to test:

  1. Do thing x
  2. Confirm thing y happens

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@stan-dot stan-dot self-assigned this May 28, 2024
@stan-dot stan-dot linked an issue May 28, 2024 that may be closed by this pull request
@stan-dot stan-dot added the documentation Improvements or additions to documentation label May 28, 2024
@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch from b7ae8df to a2dd6c3 Compare May 28, 2024 16:31
@stan-dot
Copy link
Contributor Author

the tests are failing because of an ophyd-async issue

@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch 2 times, most recently from 46ea122 to 3b84edb Compare June 3, 2024 07:17
Copy link
Contributor

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

I like the idea, but I'm not sure flowcharts are the best format for this. Read my other comments and see what you think.

docs/developer/how-to/make-new-ophyd-async-device.md Outdated Show resolved Hide resolved
docs/developer/how-to/make-new-ophyd-async-device.md Outdated Show resolved Hide resolved
docs/developer/how-to/make-new-ophyd-async-device.md Outdated Show resolved Hide resolved
docs/developer/how-to/make-new-ophyd-async-device.md Outdated Show resolved Hide resolved
Comment on lines 12 to 30
flowchart TD
highLevelStart([Start]) --> scoutUsers[Scout current and potential users of the device, tag them in the draft PR]
scoutUsers --> testPVs[Test PVs to get the right values]
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]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: I'm actually not sure this works very well as a flowchart for the following reasons:

  1. It prescribes an arbitrary order in which to do things, who says I should test the PVs before coming up with enum values? The other way around is actually easier using the dodal CLI.
  2. It implies you should do each step once and never again. In reality making a device is nothing like that, it is an iterative process. The dodal CLI makes it easy to constantly test the PVs as you write signals, rather than once upfront. You also don't come up with a list of enums upfront, you work through one signal at a time and when you discover one that needs to be an enum, you write it and decide on enum values for that signal only, rinse and repeat.
  3. It takes up a lot of page-space to convey comparatively little information.

I think what we want here is a worked example, rather than a precise series of steps. Perhaps a paragraph explaining in prose about testing the PVs, making enum signals, raising draft PRs etc. and then an example device with all of those things?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Callum, I think a worked example would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It takes up a lot of page-space to convey comparatively little information.
1 I got this based on #480 experiences where defining enum values before testing the right PVs was counterproductive. I'm happy to change this into a command from dodal cli, I didn't know this existed
2 then we can change it for there to be an iterative process. we can put what you just wrote.
page-space is free and it's not like we're printing this. empty space is the key to clear design.

re 'worked example': it's personal preference, it's fair that some people prefer prose modality to a diagram or the other way around, I think for inclusiveness we should support both.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would argue they are fundamentally different. My suggestion is a rough guide to help you figure out the sequence of steps you need to take. The current flowchart provides a precise sequence of steps, which I think is too prescriptive.

Copy link
Contributor

Choose a reason for hiding this comment

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

Of the 3 flowcharts, only one has branching while the others are a strict linear progression. I agree that those make more sense as a worked example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@callumforrester pls what would be a good prose exmple here?

Copy link
Contributor

Choose a reason for hiding this comment

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

This but with more words/detail:

"Familiarise yourself with the basics of ophyd-async devices , some considerations you should make while developing are , see example below. You are advised to gather requirements early, raise draft PRs, seek feedback, make use of the CLI to test. You should try to consolidate similar devices, the tests give you confidence that they will still work if you change them
".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current flowchart provides a precise sequence of steps, which I think is too prescriptive.

this is just a guide and of course every user will need to adapt this. word-by-word maybe less than 5% of devices would have gone through this process in this step order.

I don't see this as 'the order' to do things, just 'an order of things to base your investigations on that roughly should work if your use case is the average one'.

and I'm not sure how many more words/detail you see fit, this is very vague to me maybe I am not the best person to write out the prose part.

docs/developer/how-to/make-new-ophyd-async-device.md Outdated Show resolved Hide resolved
Comment on lines 48 to 52
testStart([Start Testing]) --> createFixtures[Create fixtures for various states of the device]
createFixtures --> createMockReactions[Create mock reactions to signals]
createMockReactions --> testStateTransitions[Test each device state transition]
testStateTransitions --> testAgainstHardware[Test against hardware]
testAgainstHardware --> testingComplete[Testing Complete]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto to my other comment, I would prefer examples to flowcharts

Copy link
Contributor

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:

  1. 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.
  2. 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.
  3. 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.


This high-level flowchart guides the overall process of creating a new ophyd_async device, from testing PVs to overriding methods and determining state enums.

```{mermaid}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```{mermaid}
```mermaid

Should get this to render?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

idk, for me it renders in vscode preview


This flowchart assists in selecting the appropriate interfaces based on the device's capabilities, such as file writing, reading values from process variables (PVs), and mobility within scans.

```{mermaid}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```{mermaid}
```mermaid


This flowchart outlines the testing procedure for the new ophyd_async device, from creating fixtures to testing state transitions and hardware integration.

```{mermaid}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```{mermaid}
```mermaid

Comment on lines 12 to 30
flowchart TD
highLevelStart([Start]) --> scoutUsers[Scout current and potential users of the device, tag them in the draft PR]
scoutUsers --> testPVs[Test PVs to get the right values]
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]
Copy link
Contributor

Choose a reason for hiding this comment

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

Of the 3 flowcharts, only one has branching while the others are a strict linear progression. I agree that those make more sense as a worked example.

@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch 7 times, most recently from 8057efc to ced0a10 Compare June 12, 2024 10:43
@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch 3 times, most recently from e90f489 to 55d69fa Compare June 13, 2024 09:25
Copy link

codecov bot commented Jun 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.69%. Comparing base (76be228) to head (55d69fa).
Report is 24 commits behind head on main.

Current head 55d69fa differs from pull request most recent head f133119

Please upload reports for the commit f133119 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #579      +/-   ##
==========================================
+ Coverage   93.03%   93.69%   +0.66%     
==========================================
  Files         103      104       +1     
  Lines        3903     3967      +64     
==========================================
+ Hits         3631     3717      +86     
+ Misses        272      250      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch 5 times, most recently from ab23442 to bab8edd Compare June 18, 2024 07:57
Copy link
Contributor

@DiamondJoseph DiamondJoseph left a comment

Choose a reason for hiding this comment

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

There's no worked examples in this repository of how to produce a device. I think it makes a lot of sense to defer that to existing ophyd-async docs (& docs).

Some of the process of writing a device should then be captured there (enum validation, testing PVs) , and then this can be simplified to "when to create/not create a new device", "how to write a good issue that captures requirements" and "how to properly test a device".

Copy link
Contributor

@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.

I still think that this would be better as a worked example but it's a reasonable start

@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch from bab8edd to 86b1348 Compare June 18, 2024 10:16
@stan-dot stan-dot force-pushed the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch from 86b1348 to f133119 Compare June 18, 2024 14:27
@stan-dot stan-dot merged commit 1829309 into main Jun 18, 2024
11 checks passed
@stan-dot stan-dot deleted the 578-add-a-flowchart-on-the-decisions-to-make-a-new-ophyd-device-for-dls branch June 18, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a flowchart on the decisions to make a new ophyd device for DLS
4 participants