-
Notifications
You must be signed in to change notification settings - Fork 180
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
test(pd): enable parameters for steps #17442
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## edge #17442 +/- ##
==========================================
- Coverage 26.21% 21.58% -4.64%
==========================================
Files 3198 2810 -388
Lines 230986 215792 -15194
Branches 9883 7919 -1964
==========================================
- Hits 60562 46568 -13994
+ Misses 170399 169224 -1175
+ Partials 25 0 -25
Flags with carried forward coverage won't be shown. Click here to find out more. |
Oh there's one other way to do this that you might want to consider, which is that instead of the step builder being responsible for interning the call details for the handlers, the handlers are responsible for returning an object representing their future execution with a consistent call interface. Something like this, though I haven't actually run this through tsc: export interface StepThunk {
call: () => void
}
export const Steps {
SelectLabwareByName: (labwareName: string): StepThunk => ({
// the outer param is lexically captured here
call: () => void { doSomethingWith(labwareName) }
}),
SelectFlex: (): StepThunk => ({
call: () => void { doSomething() }
})
}
class StepBuilder {
private readonly steps: StepThunk[]
addStep(step: StepThunk): this {
this.steps.add(step)
}
execute(): void {
this.steps.forEach(step => step.call())
}
}
const builder = new StepBuilder()
// works
builder.add(Steps.SelectLabwareByName("someName"))
// works
builder.add(Steps.SelectFlex())
// doesn't work because it is straightforwardly a normal function called with the wrong number of arguments
builder.add(Steps.SelectLabwareByName()) |
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.
Looks good to me!
Overview
Steps may intake parameters
Move away from switch and define handlers as Records.
Use builder pattern for the steps list.
No mapping or logic in runner since the handler is defined directly.
Wait on test(protocol-designer): start of cypress happy path test for mix settings #17320 to merge then update and get merged ASAP
Notes
The types are just OK. I was trying to get all the way having typescript enforce a parameter inaddStep
if theparamType
is not undefined.@sfoster1 got me on the right track and I love the typing and step mapping much better now.
![2025-02-11_18-34-01](https://private-user-images.githubusercontent.com/502770/412213302-12cda852-a9c1-49d3-9bc5-16545a7d79b5.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODc3NzYsIm5iZiI6MTczOTQ4NzQ3NiwicGF0aCI6Ii81MDI3NzAvNDEyMjEzMzAyLTEyY2RhODUyLWE5YzEtNDlkMy05YmM1LTE2NTQ1YTdkNzliNS5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxM1QyMjU3NTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kN2JkMTBjYzY0ZTY5MWZiYjQ3M2Y4ZjcyOGQ1ZTRlMWVmZDc1YTUzMWEzNjMyYjhmNzgzMGQxY2YyNTgxMDlhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.0Y-5w-fHEtXAaTtPNVdNZ05VYoePZ4ieSeLe6TuVtY0)