|
| 1 | +"""The versions of standard labware that the Protocol API should load by default.""" |
| 2 | + |
| 3 | +from typing import TypeAlias |
| 4 | +from opentrons.protocols.api_support.types import APIVersion |
| 5 | + |
| 6 | + |
| 7 | +DefaultLabwareVersions: TypeAlias = dict[APIVersion, dict[str, int]] |
| 8 | + |
| 9 | + |
| 10 | +# This: |
| 11 | +# |
| 12 | +# { |
| 13 | +# APIVersion(2, 100): { |
| 14 | +# "foo_well_plate": 3, |
| 15 | +# }, |
| 16 | +# APIVersion(2, 105): { |
| 17 | +# "foo_well_plate": 7 |
| 18 | +# } |
| 19 | +# } |
| 20 | +# |
| 21 | +# Means this: |
| 22 | +# |
| 23 | +# apiLevels Load name Default labware version |
| 24 | +# ---------------------------------------------------------- |
| 25 | +# <2.100 foo_well_plate 1 |
| 26 | +# >=2.100,<2.105 foo_well_plate 3 |
| 27 | +# >=2.105 foo_well_plate 7 |
| 28 | +# [any] [anything else] 1 |
| 29 | +DEFAULT_LABWARE_VERSIONS: DefaultLabwareVersions = { |
| 30 | + APIVersion(2, 14): { |
| 31 | + "armadillo_96_wellplate_200ul_pcr_full_skirt": 2, |
| 32 | + "biorad_384_wellplate_50ul": 2, |
| 33 | + "biorad_96_wellplate_200ul_pcr": 2, |
| 34 | + "corning_12_wellplate_6.9ml_flat": 2, |
| 35 | + "corning_24_wellplate_3.4ml_flat": 2, |
| 36 | + "corning_384_wellplate_112ul_flat": 2, |
| 37 | + "corning_48_wellplate_1.6ml_flat": 2, |
| 38 | + "corning_6_wellplate_16.8ml_flat": 2, |
| 39 | + "corning_96_wellplate_360ul_flat": 2, |
| 40 | + "nest_1_reservoir_195ml": 2, |
| 41 | + "nest_96_wellplate_100ul_pcr_full_skirt": 2, |
| 42 | + "nest_96_wellplate_200ul_flat": 2, |
| 43 | + "nest_96_wellplate_2ml_deep": 2, |
| 44 | + "opentrons_24_aluminumblock_generic_2ml_screwcap": 2, |
| 45 | + "opentrons_96_aluminumblock_generic_pcr_strip_200ul": 2, |
| 46 | + "opentrons_96_wellplate_200ul_pcr_full_skirt": 2, |
| 47 | + }, |
| 48 | + APIVersion(2, 23): { |
| 49 | + "agilent_1_reservoir_290ml": 2, |
| 50 | + "appliedbiosystemsmicroamp_384_wellplate_40ul": 2, |
| 51 | + "armadillo_96_wellplate_200ul_pcr_full_skirt": 3, |
| 52 | + "axygen_1_reservoir_90ml": 2, |
| 53 | + "biorad_384_wellplate_50ul": 3, |
| 54 | + "biorad_96_wellplate_200ul_pcr": 3, |
| 55 | + "corning_12_wellplate_6.9ml_flat": 3, |
| 56 | + "corning_24_wellplate_3.4ml_flat": 3, |
| 57 | + "corning_384_wellplate_112ul_flat": 3, |
| 58 | + "corning_48_wellplate_1.6ml_flat": 3, |
| 59 | + "corning_6_wellplate_16.8ml_flat": 3, |
| 60 | + "corning_96_wellplate_360ul_flat": 3, |
| 61 | + "nest_12_reservoir_15ml": 2, |
| 62 | + "nest_1_reservoir_195ml": 3, |
| 63 | + "nest_1_reservoir_290ml": 2, |
| 64 | + "nest_96_wellplate_100ul_pcr_full_skirt": 3, |
| 65 | + "nest_96_wellplate_200ul_flat": 3, |
| 66 | + "nest_96_wellplate_2ml_deep": 3, |
| 67 | + "opentrons_10_tuberack_falcon_4x50ml_6x15ml_conical": 2, |
| 68 | + "opentrons_10_tuberack_nest_4x50ml_6x15ml_conical": 2, |
| 69 | + "opentrons_15_tuberack_falcon_15ml_conical": 2, |
| 70 | + "opentrons_15_tuberack_nest_15ml_conical": 2, |
| 71 | + "opentrons_24_aluminumblock_generic_2ml_screwcap": 3, |
| 72 | + "opentrons_24_aluminumblock_nest_0.5ml_screwcap": 2, |
| 73 | + "opentrons_24_aluminumblock_nest_1.5ml_screwcap": 2, |
| 74 | + "opentrons_24_aluminumblock_nest_1.5ml_snapcap": 2, |
| 75 | + "opentrons_24_aluminumblock_nest_2ml_screwcap": 2, |
| 76 | + "opentrons_24_aluminumblock_nest_2ml_snapcap": 2, |
| 77 | + "opentrons_24_tuberack_eppendorf_1.5ml_safelock_snapcap": 2, |
| 78 | + "opentrons_24_tuberack_eppendorf_2ml_safelock_snapcap": 2, |
| 79 | + "opentrons_24_tuberack_generic_2ml_screwcap": 2, |
| 80 | + "opentrons_24_tuberack_nest_0.5ml_screwcap": 2, |
| 81 | + "opentrons_24_tuberack_nest_1.5ml_screwcap": 2, |
| 82 | + "opentrons_24_tuberack_nest_1.5ml_snapcap": 2, |
| 83 | + "opentrons_24_tuberack_nest_2ml_screwcap": 2, |
| 84 | + "opentrons_24_tuberack_nest_2ml_snapcap": 2, |
| 85 | + "opentrons_6_tuberack_falcon_50ml_conical": 2, |
| 86 | + "opentrons_6_tuberack_nest_50ml_conical": 2, |
| 87 | + "opentrons_96_aluminumblock_generic_pcr_strip_200ul": 3, |
| 88 | + "opentrons_96_wellplate_200ul_pcr_full_skirt": 3, |
| 89 | + "opentrons_tough_pcr_auto_sealing_lid": 2, |
| 90 | + "thermoscientificnunc_96_wellplate_1300ul": 2, |
| 91 | + "thermoscientificnunc_96_wellplate_2000ul": 2, |
| 92 | + "usascientific_12_reservoir_22ml": 2, |
| 93 | + "usascientific_96_wellplate_2.4ml_deep": 2, |
| 94 | + }, |
| 95 | + APIVersion(2, 25): { |
| 96 | + "appliedbiosystemsmicroamp_384_wellplate_40ul": 3, |
| 97 | + "axygen_96_wellplate_500ul": 2, |
| 98 | + "biorad_384_wellplate_50ul": 4, |
| 99 | + "biorad_96_wellplate_200ul_pcr": 4, |
| 100 | + "corning_12_wellplate_6.9ml_flat": 4, |
| 101 | + "corning_24_wellplate_3.4ml_flat": 4, |
| 102 | + "corning_48_wellplate_1.6ml_flat": 5, |
| 103 | + "corning_6_wellplate_16.8ml_flat": 4, |
| 104 | + "corning_96_wellplate_360ul_flat": 4, |
| 105 | + "ibidi_96_square_well_plate_300ul": 2, |
| 106 | + "nest_96_wellplate_100ul_pcr_full_skirt": 4, |
| 107 | + "nest_96_wellplate_200ul_flat": 4, |
| 108 | + "nest_96_wellplate_2ml_deep": 4, |
| 109 | + "opentrons_96_wellplate_200ul_pcr_full_skirt": 4, |
| 110 | + "smc_384_read_plate": 2, |
| 111 | + "thermoscientificnunc_96_wellplate_1300ul": 3, |
| 112 | + "thermoscientificnunc_96_wellplate_2000ul": 3, |
| 113 | + "usascientific_96_wellplate_2.4ml_deep": 3, |
| 114 | + }, |
| 115 | +} |
| 116 | + |
| 117 | + |
| 118 | +# Labware where, for whatever reason, we don't want `opentrons.protocol_api` to load |
| 119 | +# the latest available version. |
| 120 | +# |
| 121 | +# Typically, this is because the latest available version of the labware is some kind of |
| 122 | +# unpublicized draft. |
| 123 | +# |
| 124 | +# Beware, though, that users can still load the unpublicized draft if they know how, e.g. |
| 125 | +# by passing an explicit `version` arg to `ProtocolContext.load_labware()`. |
| 126 | +# And non-`opentrons.protocol_api` code like Labware Library, Protocol Designer, and |
| 127 | +# Quick Transfer will still use the unpublicized draft unless you exclude it through |
| 128 | +# other means. |
| 129 | +# |
| 130 | +# This list should not be consumed by production code--it's only for the benefit of tests |
| 131 | +# that make sure every labware is accounted for somehow. |
| 132 | +KNOWN_EXCEPTIONS_FOR_TESTS: set[str] = { |
| 133 | + # Dev testing junk for labware schema 3, not things that users should ever load: |
| 134 | + "schema3test_96_well_aluminum_block", |
| 135 | + "schema3test_96_wellplate_200ul_pcr_full_skirt", |
| 136 | + "schema3test_aluminum_flat_bottom_plate", |
| 137 | + "schema3test_flex_96_tiprack_200ul", |
| 138 | + "schema3test_flex_96_tiprack_adapter", |
| 139 | + "schema3test_flex_tiprack_lid", |
| 140 | + "schema3test_tough_pcr_auto_sealing_lid", |
| 141 | + "schema3test_universal_flat_adapter", |
| 142 | + # These were supposed to be short-lived drafts as part of of a one-two punch of |
| 143 | + # https://github.com/Opentrons/opentrons/pull/18266 + https://github.com/Opentrons/opentrons/pull/18284, |
| 144 | + # but the second punch took a while. We should merge the second punch after v8.6.0 |
| 145 | + # and remove these exceptions as part of that. |
| 146 | + "agilent_1_reservoir_290ml", |
| 147 | + "corning_384_wellplate_112ul_flat", |
| 148 | + "nest_1_reservoir_290ml", |
| 149 | + "opentrons_24_aluminumblock_nest_0.5ml_screwcap", |
| 150 | + "opentrons_24_tuberack_nest_0.5ml_screwcap", |
| 151 | + "opentrons_96_aluminumblock_generic_pcr_strip_200ul", |
| 152 | + "usascientific_12_reservoir_22ml", |
| 153 | +} |
| 154 | + |
| 155 | + |
| 156 | +def get_standard_labware_default_version( |
| 157 | + api_version: APIVersion, |
| 158 | + load_name: str, |
| 159 | + default_labware_versions: DefaultLabwareVersions = DEFAULT_LABWARE_VERSIONS, |
| 160 | +) -> int: |
| 161 | + """Return what version of a standard labware the Protocol API should load by default. |
| 162 | +
|
| 163 | + The `default_labware_versions` param is exposed for testability and should be left |
| 164 | + unspecified. |
| 165 | + """ |
| 166 | + default_labware_versions_newest_to_oldest = sorted( |
| 167 | + default_labware_versions.items(), key=lambda kv: kv[0], reverse=True |
| 168 | + ) |
| 169 | + for ( |
| 170 | + breakpoint_api_version, |
| 171 | + breakpoint_labware_versions, |
| 172 | + ) in default_labware_versions_newest_to_oldest: |
| 173 | + if ( |
| 174 | + api_version >= breakpoint_api_version |
| 175 | + and load_name in breakpoint_labware_versions |
| 176 | + ): |
| 177 | + return breakpoint_labware_versions[load_name] |
| 178 | + |
| 179 | + return 1 |
0 commit comments