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(robot-server): update run creation endpoint to accept runtime parameter values #14776

Merged
merged 6 commits into from
Apr 3, 2024

Conversation

jbleon95
Copy link
Contributor

@jbleon95 jbleon95 commented Apr 2, 2024

Overview

Closes AUTH-130

This PR adds a new, optional argument runTimeParameterValues to the request body of the POST /runs endpoint to start a run with new runtime parameter values. It is the same shape as the argument for the /protocols endpoint (a dictionary/map of variable names to the parameter values), but since this endpoint does not take form data, it does not need to be parsed with in the body of the run create function.

These values are then fed to the ProtocolRunner load method which will bind those to the execute function, so that when the protocol starts it will evaluate and use those values when running the protocol. (assuming there are no errors in setting the parameter values).

Since re-analysis has not been implemented yet, when starting a run with overridden values, the frontend will show an incorrect analysis for the run. This will be addressed in a future PR so that it reflects the values (and therefore potentially labware, pipettes, modules used) used in the actual run.

Test Plan

Continuing to use this test protocol seen in other PRs to test parameter values. Using postman, I was able to post the protocol with default values, then start a run with new overridden values:

  • Posting a run with no runTimeParameterValues uses the default values
  • Posting a run with valid overridden values uses that in the actual run execution
  • Posting a run with invalid overridden values causes the run to fail
metadata = {
    'protocolName': 'RTP Test 2 - Default only, all types',
}

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


def add_parameters(parameters):
    parameters.add_int(
        display_name="Sample count",
        variable_name="sample_count",
        default=6,
        minimum=1,
        maximum=12,
        description="How many samples to process."
    )
    parameters.add_float(
        display_name="Pipette volume",
        variable_name="volume",
        default=20.1,
        choices=[
            {"display_name": "Low Volume", "value": 10.23},
            {"display_name": "Medium Volume", "value": 20.1},
            {"display_name": "High Volume", "value": 50.5},
        ],
        description="How many microliters to pipette of each sample.",
        unit="µL"
    )
    parameters.add_bool(
        display_name="Dry Run",
        variable_name="dry_run",
        default=False,
        description="Skip aspirate and dispense steps."
    )
    parameters.add_str(
        display_name="Pipette Name",
        variable_name="pipette",
        choices=[
            {"display_name": "Single channel 50µL", "value": "flex_1channel_50"},
            {"display_name": "Single channel 1000µL", "value": "flex_1channel_1000"},
            {"display_name": "Eight Channel 50µL", "value": "flex_8channel_50"},
            {"display_name": "Eight Channel 1000µL", "value": "flex_8channel_1000"},
        ],
        default="flex_1channel_50",
        description="What pipette to use during the protocol.",
    )



def run(context):
    trash_bin = context.load_trash_bin('A3')
    tip_rack = context.load_labware('opentrons_flex_96_tiprack_50ul', 'D2')
    source = context.load_labware('opentrons_96_wellplate_200ul_pcr_full_skirt', 'C1')
    destination = context.load_labware('opentrons_96_wellplate_200ul_pcr_full_skirt', 'C3')

    pipette = context.load_instrument(context.params.pipette, mount="left", tip_racks=[tip_rack])

    for i in range(context.params.sample_count):
        source_well = source.wells()[i]
        destination_well = destination.wells()[i]

        pipette.pick_up_tip()
        pipette.move_to(source_well.top())
        if not context.params.dry_run:
            pipette.aspirate(context.params.volume, source_well)
            pipette.dispense(context.params.volume, destination_well)

        pipette.drop_tip()

Changelog

  • added runTimeParameterValues argument to POST /runs
  • connected the runtime parameter values to the engine creation so that runs use those values sent

Review requests

Risk assessment

Low

@jbleon95 jbleon95 requested review from sanni-t and a team April 2, 2024 13:55
@jbleon95 jbleon95 requested a review from a team as a code owner April 2, 2024 13:55
@jbleon95 jbleon95 requested review from Elyorcv and removed request for a team and Elyorcv April 2, 2024 13:55
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.19%. Comparing base (cf93d9c) to head (aa492eb).
Report is 13 commits behind head on edge.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #14776   +/-   ##
=======================================
  Coverage   67.19%   67.19%           
=======================================
  Files        2495     2495           
  Lines       71388    71388           
  Branches     8984     8984           
=======================================
  Hits        47972    47972           
  Misses      21301    21301           
  Partials     2115     2115           
Flag Coverage Δ
g-code-testing 92.43% <ø> (ø)

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

Files Coverage Δ
robot-server/robot_server/runs/engine_store.py 95.83% <ø> (ø)
...bot-server/robot_server/runs/router/base_router.py 96.19% <ø> (ø)
robot-server/robot_server/runs/run_models.py 100.00% <ø> (ø)

Copy link
Member

@sanni-t sanni-t left a comment

Choose a reason for hiding this comment

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

Nice!

robot-server/robot_server/runs/run_models.py Outdated Show resolved Hide resolved
@jbleon95 jbleon95 merged commit 6bf0579 into edge Apr 3, 2024
23 checks passed
@jbleon95 jbleon95 deleted the post_rtp_values_to_run_create branch April 3, 2024 19:18
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
…rameter values (#14776)

Adds an optional argument `runTimeParameterValues` to the request body of the POST /runs endpoint to start a run with new runtime parameter values.
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