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

test(pd): enable parameters for steps #17442

Merged
merged 25 commits into from
Feb 12, 2025
Merged

Conversation

y3rsh
Copy link
Member

@y3rsh y3rsh commented Feb 5, 2025

Overview

Notes

The types are just OK. I was trying to get all the way having typescript enforce a parameter in addStep if the paramType 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

@y3rsh y3rsh self-assigned this Feb 5, 2025
@y3rsh y3rsh requested a review from a team as a code owner February 5, 2025 22:17
@Opentrons Opentrons deleted a comment from codecov bot Feb 6, 2025
@Opentrons Opentrons deleted a comment from codecov bot Feb 6, 2025
@Opentrons Opentrons deleted a comment from codecov bot Feb 6, 2025
@Opentrons Opentrons deleted a comment from codecov bot Feb 6, 2025
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 21.58%. Comparing base (44cfe58) to head (6e1a4e8).
Report is 2 commits behind head on edge.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
app ?
labware-library ?
opentrons-ai-client ?
protocol-designer 18.76% <ø> (+1.23%) ⬆️
step-generation 4.34% <ø> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 595 files with indirect coverage changes

@y3rsh y3rsh requested a review from a team as a code owner February 7, 2025 22:59
@y3rsh y3rsh requested review from TamarZanzouri and removed request for a team February 7, 2025 22:59
@sfoster1
Copy link
Member

sfoster1 commented Feb 11, 2025

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())

Copy link
Contributor

@alexjoel42 alexjoel42 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 to me!

@y3rsh y3rsh merged commit 3ad2cae into edge Feb 12, 2025
90 checks passed
@y3rsh y3rsh deleted the pd-tools-for-cypress-20250205 branch February 12, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants