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(step-generation): temperature python commands for temp & heater-shaker modules #17650

Merged
merged 5 commits into from
Mar 5, 2025

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Mar 4, 2025

closes AUTH-1100

Overview

This PR adds python command support for the temperature module (deactivate, waitForTemprature, setTemperature follow up from here). it also fixes the heater-shaker temperature commands.

Test Plan and Hands on Testing

Review code but there are unit tests. Also smoke test!

Here is a test i made where it tests setting a temp with and without a pause for Heater-shaker and Temperature module, as well as deactivating both. And it passes analysis:

from contextlib import nullcontext as pd_step
from opentrons import protocol_api, types

metadata = {
    "protocolName": "testing python hs, temp",
    "created": "2025-03-05T15:33:30.554Z",
    "lastModified": "2025-03-05T15:34:26.229Z",
    "protocolDesigner": "8.4.0",
}

requirements = {
    "robotType": "Flex",
    "apiLevel": "2.23",
}

def run(protocol: protocol_api.ProtocolContext):
    # Load Modules:
    heater_shaker_module_1 = protocol.load_module("heaterShakerModuleV1", "D1")
    temperature_module_1 = protocol.load_module("temperatureModuleV2", "C1")

    # Load Labware:
    tip_rack_1 = protocol.load_labware(
        "opentrons_flex_96_filtertiprack_200ul",
        "C2",
        namespace="opentrons",
        version=1,
    )

    # Load Pipettes:
    pipette_left = protocol.load_instrument("flex_8channel_1000", "left", tip_racks=[tip_rack_1])

    # Load Trash Bins:
    trash_bin_1 = protocol.load_trash_bin("A3")

    # PROTOCOL STEPS

    # Step 1:
    heater_shaker_module_1.close_labware_latch()
    heater_shaker_module_1.set_target_temperature(50)

    # Step 2:
    heater_shaker_module_1.wait_for_temperature()

    # Step 3:
    heater_shaker_module_1.close_labware_latch()
    heater_shaker_module_1.deactivate_heater()

    # Step 4:
    heater_shaker_module_1.close_labware_latch()
    heater_shaker_module_1.set_target_temperature(40)

    # Step 5:
    temperature_module_1.start_set_temperature(40)

    # Step 6:
    temperature_module_1.await_temperature(40)

    # Step 7:
    temperature_module_1.deactivate()

    # Step 8:
    temperature_module_1.start_set_temperature(30)

Changelog

  • add temperature module python command support
  • add unit test coverage

Risk assessment

low, behind ff

@jerader jerader requested a review from a team as a code owner March 4, 2025 20:26
@jerader jerader requested a review from ddcc4 March 4, 2025 20:26
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 25.73%. Comparing base (62d1b6e) to head (322816e).
Report is 5 commits behind head on edge.

Files with missing lines Patch % Lines
...rc/commandCreators/atomic/deactivateTemperature.ts 80.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #17650      +/-   ##
==========================================
+ Coverage   25.69%   25.73%   +0.04%     
==========================================
  Files        2851     2851              
  Lines      219479   219589     +110     
  Branches    17972    18004      +32     
==========================================
+ Hits        56385    56515     +130     
+ Misses     163079   163059      -20     
  Partials       15       15              
Flag Coverage Δ
protocol-designer 18.98% <0.00%> (+0.04%) ⬆️
step-generation 4.39% <87.50%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...ation/src/commandCreators/atomic/setTemperature.ts 85.71% <100.00%> (-0.26%) ⬇️
...n/src/commandCreators/atomic/waitForTemperature.ts 86.04% <100.00%> (+17.37%) ⬆️
...rc/commandCreators/atomic/deactivateTemperature.ts 55.38% <80.00%> (+0.38%) ⬆️

... and 10 files with indirect coverage changes

const moduleType = invariantContext.moduleEntities[moduleId]?.type
const module = invariantContext.moduleEntities[moduleId]
const moduleType = module?.type
const modulePythonName = module?.pythonName
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there ever a case where module is undefined? Are you only doing the module? thing because the typechecker wants it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm actually, good question. i don't think we should hit this since we throw an error if it is null. i'll remove it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok i think we should keep the ? in there to prevent whitescreens in the event that a user deleted their module or something. We should be hitting the "missing module" timeline error before hand but i think this is just addition precautions.

const moduleType = invariantContext.moduleEntities[moduleId]?.type
const module = invariantContext.moduleEntities[moduleId]
const moduleType = module?.type
const pythonCommand = `${module?.pythonName}.wait_for_temperature(${celsius})`
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, I'm having trouble finding the wait_for_temperature() function in the API that takes a temperature argument. Could you point me to where it is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ahh good question. i just looked in the api docs, and i don't see it either. i don't see the temperature module even emitting wait_for_temperature, i only see it referenced for a heater-shaker 🤔 let me double check with the backend team

@jerader jerader requested a review from ddcc4 March 5, 2025 15:39
@jerader jerader changed the title feat(step-generation): python commands for temperature module feat(step-generation): temperature python commands for temp & heater-shaker modules Mar 5, 2025
Copy link
Contributor

@ddcc4 ddcc4 left a comment

Choose a reason for hiding this comment

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

Thanks!

When you get a chance, could you generate a Python protocol that uses the new modules you added and see if the code is runnable?

@@ -44,6 +44,7 @@ export const commandCreatorFromStepArgs = (
)

case 'setTemperature':
console.log('hit set temperature', args)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remember to clean this up before checking in :)

@jerader jerader merged commit 38905cf into edge Mar 5, 2025
17 checks passed
@jerader jerader deleted the sg_temp-mod-python branch March 5, 2025 17:57
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.

2 participants