Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): allow setting runtime parameter values and CSV files in cl…
…i analysis (#16387) # Overview Closes AUTH-873. This PR adds two new command line arguments to allow the setting and override of runtime parameters in cli analysis, for both basic RTP types (boolean, string, integer, and float) as well as CSV files. The two new arguments are `--rtp-values` for the basic RTP values and `--rtp-files` for CSV files. Both take similar input in the form of serialized json strings. For RTP values the data passed is in the form of `{variable_name: value}` and for CSV files it is in the form of `{variable_name: /path/to/file}`. Because the CSV file that is used for local analysis is not a data file stored on the robot, and therefore does not have a UUID associated for it in the `"id"` property for the `file` property in the runtime parameters reported we substitute an empty string. The code to find the UUID currently assumes it to be the parent folder name, so logic was added to check if it is a UUID and change it to an empty string if it is not, to prevent the leaking of folder names into analysis. ## Test Plan and Hands on Testing Tested local analysis with the following two protocols and the following RTP arguments and made sure analysis reflected the changed values: ``` requirements = { "robotType": "Flex", "apiLevel": "2.18" } def add_parameters(parameters): parameters.add_int( display_name="Sample count", variable_name="sample_count", default=2, minimum=1, maximum=6, description="How many samples to process." ) parameters.add_float( display_name="Pipette volume", variable_name="volume", default=20, choices=[ {"display_name": "Low Volume", "value": 10.23}, {"display_name": "Medium Volume", "value": 20.0}, {"display_name": "High Volume", "value": 50.5}, ], description="How many microliters to pipette of each sample.", ) 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): pass ``` with `--rtp-values='{"sample_count": 3, "volume": 10.23, "dry_run": true, "pipette": "flex_8channel_50"}'` and ``` requirements = { "robotType": "Flex", "apiLevel": "2.20" } def add_parameters(parameters): 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.", ) parameters.add_csv_file( display_name="CSV Data", variable_name="csv_data", description="CSV file containing labware and volume information." ) def run(context): context.params.csv_data.file ``` with `--rtp-files='{"csv_data": "/Users/jeremyleon/Downloads/example1.csv"}'` ## Changelog - added `--rtp-values` and `--rtp-files` optional command line arguments for cli analysis to allow overrides for RTP values and setting a local file to be used for CSV file protocols. ## Review requests Should we put in some special value for `"id"` when using analysis? Right now it's defaulting to an empty string and it is a client-only concern, but we may want a specific value at some point. Or have the analysis take a slightly different shape when it's local CLI analysis. ## Risk assessment Low, only affects CLI code and new arguments do not change
- Loading branch information