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

feat: Add script for provisioning Flex pipettes in emulation #12897

Merged
merged 4 commits into from
Jun 13, 2023

Conversation

DerekMaggio
Copy link
Contributor

@DerekMaggio DerekMaggio commented Jun 12, 2023

Overview

Add script for provisioning Flex pipettes in emulation. This script is run inside the ot3-firmware-builder container from opentrons-emulation

Script Flow:

  1. Read from environment variables: LEFT_OT3_PIPETTE_DEFINITION and RIGHT_OT3_PIPETTE_DEFINITION
  2. Convert env var content to OT3PipetteEnvVar dataclass object
  3. Generate serial code by using opentrons_hardware.instruments.pipettes.serials.serial_val_from_parts
  4. Create eeprom files for each pipette inside of that pipette's volume folder. Note that the volume folders are created inside the emulation scope.

Note:
It is out of scope for this PR to actually ensure that the pipettes run correctly in emulation. They currently do not, and I cannot figure out why. Going to circle up with the wizards in embedded land to see if they can help me figure it out. A followup PR will address them actually working


Test Plan

  • Add unit test to validate that exercising the above flow creates the file
  • Validate against emulation repo
    • Using opentrons-emulation local dev, bind mount the latest version of this branch into the emulation system.
    • Validate that framework automatically creates correct env vars for script to parse
    • Validate that script is automatically called with no required user inpur
    • Validate that eeprom files are created on ot3-firmware-builder
    • Validate that eeprom files are pushed to the pipette containers through the volume connection

Changelog

  • Add script
  • Add test

Review requests

Do you think it is okay to not validate that the content of the eeprom file is correct?
I am not doing this for a few reasons:

  1. Figuring out what the content is actually supposed to be sounds like a pain
  2. I am using a monorepo utility function to do the actual serial number provisioning. This functionality should be tested in the monorepo and not in the context of emulation
  3. The new functionality is parsing the env vars and pushing to the file. Which testing was added for

Risk assessment

Low

  • Script is not used by this repo
  • Tests do not affect this repo
  • No dependencies or existing source code were modified

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #12897 (be944f2) into edge (8a30869) will increase coverage by 0.01%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #12897      +/-   ##
==========================================
+ Coverage   73.01%   73.02%   +0.01%     
==========================================
  Files        1516     1517       +1     
  Lines       49686    49727      +41     
  Branches     3037     3037              
==========================================
+ Hits        36277    36315      +38     
- Misses      12943    12946       +3     
  Partials      466      466              
Flag Coverage Δ
hardware 58.72% <94.11%> (+0.19%) ⬆️
notify-server 89.13% <ø> (ø)

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

Impacted Files Coverage Δ
...ns_hardware/scripts/emulation_pipette_provision.py 94.11% <94.11%> (ø)

... and 1 file with indirect coverage changes

@DerekMaggio DerekMaggio changed the title feat: Add script for provisioning pipettes in emulation feat: Add script for provisioning Flex pipettes in emulation Jun 12, 2023
@DerekMaggio DerekMaggio self-assigned this Jun 12, 2023
@DerekMaggio DerekMaggio marked this pull request as ready for review June 12, 2023 17:41
@DerekMaggio DerekMaggio requested a review from a team as a code owner June 12, 2023 17:41
@DerekMaggio DerekMaggio requested a review from fsinapi June 12, 2023 18:36
Copy link
Contributor

@fsinapi fsinapi left a comment

Choose a reason for hiding this comment

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

Yeah this looks correct to me, couple of comments you can ignore 👍

LEFT_PIPETTE_ENV_VAR_NAME = "LEFT_OT3_PIPETTE_DEFINITION"
RIGHT_PIPETTE_ENV_VAR_NAME = "RIGHT_OT3_PIPETTE_DEFINITION"

LEFT_PIPETTE_EEPROM_DIR_PATH = "/volumes/left-pipette-eeprom"
Copy link
Contributor

Choose a reason for hiding this comment

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

Part of me thinks that these should be parameters instead of hard coded, but this is such a specialized script that I don't think it matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can easily make these part of the parsed environment variable.
Would that suffice?

Copy link
Contributor

Choose a reason for hiding this comment

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

💯 sounds good to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assert not os.path.exists(left_eeprom_path)
assert not os.path.exists(right_eeprom_path)
emulation_pipette_provision.main()
assert os.path.exists(left_eeprom_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth it to verify that the contents of these files is correct by calling serial_val_from_parts and reading the files. Unfortunate that we can't deserialize the encoded serial values though!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify, I am calling that function under the hood to generate the serial number.
Is it redundant to call the same function to compare that value to?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what makes it worth testing is that you want to verify that the script, viewed as a black box, is generating the right contents in the right files. I agree that it isn't the most thorough way to test it, but it at least makes sure you're 1) getting all of the info from the environment variable 2) putting the left/right info in the correct respective files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well good thing you suggested this.
I, being an idiot, was only ever evaluating the left pipette and storing it to both left and right.
Thanks @fsinapi. You saved me from myself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@DerekMaggio DerekMaggio requested a review from fsinapi June 13, 2023 17:57
Copy link
Contributor

@fsinapi fsinapi left a comment

Choose a reason for hiding this comment

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

LGTM !

@DerekMaggio DerekMaggio merged commit 14ca121 into edge Jun 13, 2023
ahiuchingau pushed a commit that referenced this pull request Jun 14, 2023
* feat: Add script for provisioning pipettes in emulation

* chore: Change to support full eeprom path being passed

* Linting

* remove unused constants
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