opentrons 8.6.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of opentrons might be problematic. Click here for more details.

Files changed (600) hide show
  1. opentrons/__init__.py +150 -0
  2. opentrons/_version.py +34 -0
  3. opentrons/calibration_storage/__init__.py +54 -0
  4. opentrons/calibration_storage/deck_configuration.py +62 -0
  5. opentrons/calibration_storage/encoder_decoder.py +31 -0
  6. opentrons/calibration_storage/file_operators.py +142 -0
  7. opentrons/calibration_storage/helpers.py +103 -0
  8. opentrons/calibration_storage/ot2/__init__.py +34 -0
  9. opentrons/calibration_storage/ot2/deck_attitude.py +85 -0
  10. opentrons/calibration_storage/ot2/mark_bad_calibration.py +27 -0
  11. opentrons/calibration_storage/ot2/models/__init__.py +0 -0
  12. opentrons/calibration_storage/ot2/models/v1.py +149 -0
  13. opentrons/calibration_storage/ot2/pipette_offset.py +129 -0
  14. opentrons/calibration_storage/ot2/tip_length.py +281 -0
  15. opentrons/calibration_storage/ot3/__init__.py +31 -0
  16. opentrons/calibration_storage/ot3/deck_attitude.py +83 -0
  17. opentrons/calibration_storage/ot3/gripper_offset.py +156 -0
  18. opentrons/calibration_storage/ot3/models/__init__.py +0 -0
  19. opentrons/calibration_storage/ot3/models/v1.py +122 -0
  20. opentrons/calibration_storage/ot3/module_offset.py +138 -0
  21. opentrons/calibration_storage/ot3/pipette_offset.py +95 -0
  22. opentrons/calibration_storage/types.py +45 -0
  23. opentrons/cli/__init__.py +21 -0
  24. opentrons/cli/__main__.py +5 -0
  25. opentrons/cli/analyze.py +501 -0
  26. opentrons/config/__init__.py +631 -0
  27. opentrons/config/advanced_settings.py +871 -0
  28. opentrons/config/defaults_ot2.py +214 -0
  29. opentrons/config/defaults_ot3.py +499 -0
  30. opentrons/config/feature_flags.py +86 -0
  31. opentrons/config/gripper_config.py +55 -0
  32. opentrons/config/reset.py +203 -0
  33. opentrons/config/robot_configs.py +187 -0
  34. opentrons/config/types.py +183 -0
  35. opentrons/drivers/__init__.py +0 -0
  36. opentrons/drivers/absorbance_reader/__init__.py +11 -0
  37. opentrons/drivers/absorbance_reader/abstract.py +72 -0
  38. opentrons/drivers/absorbance_reader/async_byonoy.py +352 -0
  39. opentrons/drivers/absorbance_reader/driver.py +81 -0
  40. opentrons/drivers/absorbance_reader/hid_protocol.py +161 -0
  41. opentrons/drivers/absorbance_reader/simulator.py +84 -0
  42. opentrons/drivers/asyncio/__init__.py +0 -0
  43. opentrons/drivers/asyncio/communication/__init__.py +22 -0
  44. opentrons/drivers/asyncio/communication/async_serial.py +183 -0
  45. opentrons/drivers/asyncio/communication/errors.py +88 -0
  46. opentrons/drivers/asyncio/communication/serial_connection.py +552 -0
  47. opentrons/drivers/command_builder.py +102 -0
  48. opentrons/drivers/flex_stacker/__init__.py +13 -0
  49. opentrons/drivers/flex_stacker/abstract.py +214 -0
  50. opentrons/drivers/flex_stacker/driver.py +768 -0
  51. opentrons/drivers/flex_stacker/errors.py +68 -0
  52. opentrons/drivers/flex_stacker/simulator.py +309 -0
  53. opentrons/drivers/flex_stacker/types.py +367 -0
  54. opentrons/drivers/flex_stacker/utils.py +19 -0
  55. opentrons/drivers/heater_shaker/__init__.py +5 -0
  56. opentrons/drivers/heater_shaker/abstract.py +76 -0
  57. opentrons/drivers/heater_shaker/driver.py +204 -0
  58. opentrons/drivers/heater_shaker/simulator.py +94 -0
  59. opentrons/drivers/mag_deck/__init__.py +6 -0
  60. opentrons/drivers/mag_deck/abstract.py +44 -0
  61. opentrons/drivers/mag_deck/driver.py +208 -0
  62. opentrons/drivers/mag_deck/simulator.py +63 -0
  63. opentrons/drivers/rpi_drivers/__init__.py +33 -0
  64. opentrons/drivers/rpi_drivers/dev_types.py +94 -0
  65. opentrons/drivers/rpi_drivers/gpio.py +282 -0
  66. opentrons/drivers/rpi_drivers/gpio_simulator.py +127 -0
  67. opentrons/drivers/rpi_drivers/interfaces.py +15 -0
  68. opentrons/drivers/rpi_drivers/types.py +364 -0
  69. opentrons/drivers/rpi_drivers/usb.py +102 -0
  70. opentrons/drivers/rpi_drivers/usb_simulator.py +22 -0
  71. opentrons/drivers/serial_communication.py +151 -0
  72. opentrons/drivers/smoothie_drivers/__init__.py +4 -0
  73. opentrons/drivers/smoothie_drivers/connection.py +51 -0
  74. opentrons/drivers/smoothie_drivers/constants.py +121 -0
  75. opentrons/drivers/smoothie_drivers/driver_3_0.py +1933 -0
  76. opentrons/drivers/smoothie_drivers/errors.py +49 -0
  77. opentrons/drivers/smoothie_drivers/parse_utils.py +143 -0
  78. opentrons/drivers/smoothie_drivers/simulator.py +99 -0
  79. opentrons/drivers/smoothie_drivers/types.py +16 -0
  80. opentrons/drivers/temp_deck/__init__.py +10 -0
  81. opentrons/drivers/temp_deck/abstract.py +54 -0
  82. opentrons/drivers/temp_deck/driver.py +197 -0
  83. opentrons/drivers/temp_deck/simulator.py +57 -0
  84. opentrons/drivers/thermocycler/__init__.py +12 -0
  85. opentrons/drivers/thermocycler/abstract.py +99 -0
  86. opentrons/drivers/thermocycler/driver.py +395 -0
  87. opentrons/drivers/thermocycler/simulator.py +126 -0
  88. opentrons/drivers/types.py +107 -0
  89. opentrons/drivers/utils.py +222 -0
  90. opentrons/execute.py +742 -0
  91. opentrons/hardware_control/__init__.py +65 -0
  92. opentrons/hardware_control/__main__.py +77 -0
  93. opentrons/hardware_control/adapters.py +98 -0
  94. opentrons/hardware_control/api.py +1347 -0
  95. opentrons/hardware_control/backends/__init__.py +7 -0
  96. opentrons/hardware_control/backends/controller.py +400 -0
  97. opentrons/hardware_control/backends/errors.py +9 -0
  98. opentrons/hardware_control/backends/estop_state.py +164 -0
  99. opentrons/hardware_control/backends/flex_protocol.py +497 -0
  100. opentrons/hardware_control/backends/ot3controller.py +1930 -0
  101. opentrons/hardware_control/backends/ot3simulator.py +900 -0
  102. opentrons/hardware_control/backends/ot3utils.py +664 -0
  103. opentrons/hardware_control/backends/simulator.py +442 -0
  104. opentrons/hardware_control/backends/status_bar_state.py +240 -0
  105. opentrons/hardware_control/backends/subsystem_manager.py +431 -0
  106. opentrons/hardware_control/backends/tip_presence_manager.py +173 -0
  107. opentrons/hardware_control/backends/types.py +14 -0
  108. opentrons/hardware_control/constants.py +6 -0
  109. opentrons/hardware_control/dev_types.py +125 -0
  110. opentrons/hardware_control/emulation/__init__.py +0 -0
  111. opentrons/hardware_control/emulation/abstract_emulator.py +21 -0
  112. opentrons/hardware_control/emulation/app.py +56 -0
  113. opentrons/hardware_control/emulation/connection_handler.py +38 -0
  114. opentrons/hardware_control/emulation/heater_shaker.py +150 -0
  115. opentrons/hardware_control/emulation/magdeck.py +60 -0
  116. opentrons/hardware_control/emulation/module_server/__init__.py +8 -0
  117. opentrons/hardware_control/emulation/module_server/client.py +78 -0
  118. opentrons/hardware_control/emulation/module_server/helpers.py +130 -0
  119. opentrons/hardware_control/emulation/module_server/models.py +31 -0
  120. opentrons/hardware_control/emulation/module_server/server.py +110 -0
  121. opentrons/hardware_control/emulation/parser.py +74 -0
  122. opentrons/hardware_control/emulation/proxy.py +241 -0
  123. opentrons/hardware_control/emulation/run_emulator.py +68 -0
  124. opentrons/hardware_control/emulation/scripts/__init__.py +0 -0
  125. opentrons/hardware_control/emulation/scripts/run_app.py +54 -0
  126. opentrons/hardware_control/emulation/scripts/run_module_emulator.py +72 -0
  127. opentrons/hardware_control/emulation/scripts/run_smoothie.py +37 -0
  128. opentrons/hardware_control/emulation/settings.py +119 -0
  129. opentrons/hardware_control/emulation/simulations.py +133 -0
  130. opentrons/hardware_control/emulation/smoothie.py +192 -0
  131. opentrons/hardware_control/emulation/tempdeck.py +69 -0
  132. opentrons/hardware_control/emulation/thermocycler.py +128 -0
  133. opentrons/hardware_control/emulation/types.py +10 -0
  134. opentrons/hardware_control/emulation/util.py +38 -0
  135. opentrons/hardware_control/errors.py +43 -0
  136. opentrons/hardware_control/execution_manager.py +164 -0
  137. opentrons/hardware_control/instruments/__init__.py +5 -0
  138. opentrons/hardware_control/instruments/instrument_abc.py +39 -0
  139. opentrons/hardware_control/instruments/ot2/__init__.py +0 -0
  140. opentrons/hardware_control/instruments/ot2/instrument_calibration.py +152 -0
  141. opentrons/hardware_control/instruments/ot2/pipette.py +777 -0
  142. opentrons/hardware_control/instruments/ot2/pipette_handler.py +995 -0
  143. opentrons/hardware_control/instruments/ot3/__init__.py +0 -0
  144. opentrons/hardware_control/instruments/ot3/gripper.py +420 -0
  145. opentrons/hardware_control/instruments/ot3/gripper_handler.py +173 -0
  146. opentrons/hardware_control/instruments/ot3/instrument_calibration.py +214 -0
  147. opentrons/hardware_control/instruments/ot3/pipette.py +858 -0
  148. opentrons/hardware_control/instruments/ot3/pipette_handler.py +1030 -0
  149. opentrons/hardware_control/module_control.py +332 -0
  150. opentrons/hardware_control/modules/__init__.py +69 -0
  151. opentrons/hardware_control/modules/absorbance_reader.py +373 -0
  152. opentrons/hardware_control/modules/errors.py +7 -0
  153. opentrons/hardware_control/modules/flex_stacker.py +948 -0
  154. opentrons/hardware_control/modules/heater_shaker.py +426 -0
  155. opentrons/hardware_control/modules/lid_temp_status.py +35 -0
  156. opentrons/hardware_control/modules/magdeck.py +233 -0
  157. opentrons/hardware_control/modules/mod_abc.py +245 -0
  158. opentrons/hardware_control/modules/module_calibration.py +93 -0
  159. opentrons/hardware_control/modules/plate_temp_status.py +61 -0
  160. opentrons/hardware_control/modules/tempdeck.py +299 -0
  161. opentrons/hardware_control/modules/thermocycler.py +731 -0
  162. opentrons/hardware_control/modules/types.py +417 -0
  163. opentrons/hardware_control/modules/update.py +255 -0
  164. opentrons/hardware_control/modules/utils.py +73 -0
  165. opentrons/hardware_control/motion_utilities.py +318 -0
  166. opentrons/hardware_control/nozzle_manager.py +422 -0
  167. opentrons/hardware_control/ot3_calibration.py +1171 -0
  168. opentrons/hardware_control/ot3api.py +3227 -0
  169. opentrons/hardware_control/pause_manager.py +31 -0
  170. opentrons/hardware_control/poller.py +112 -0
  171. opentrons/hardware_control/protocols/__init__.py +106 -0
  172. opentrons/hardware_control/protocols/asyncio_configurable.py +11 -0
  173. opentrons/hardware_control/protocols/calibratable.py +45 -0
  174. opentrons/hardware_control/protocols/chassis_accessory_manager.py +90 -0
  175. opentrons/hardware_control/protocols/configurable.py +48 -0
  176. opentrons/hardware_control/protocols/event_sourcer.py +18 -0
  177. opentrons/hardware_control/protocols/execution_controllable.py +33 -0
  178. opentrons/hardware_control/protocols/flex_calibratable.py +96 -0
  179. opentrons/hardware_control/protocols/flex_instrument_configurer.py +52 -0
  180. opentrons/hardware_control/protocols/gripper_controller.py +55 -0
  181. opentrons/hardware_control/protocols/hardware_manager.py +51 -0
  182. opentrons/hardware_control/protocols/identifiable.py +16 -0
  183. opentrons/hardware_control/protocols/instrument_configurer.py +206 -0
  184. opentrons/hardware_control/protocols/liquid_handler.py +266 -0
  185. opentrons/hardware_control/protocols/module_provider.py +16 -0
  186. opentrons/hardware_control/protocols/motion_controller.py +243 -0
  187. opentrons/hardware_control/protocols/position_estimator.py +45 -0
  188. opentrons/hardware_control/protocols/simulatable.py +10 -0
  189. opentrons/hardware_control/protocols/stoppable.py +9 -0
  190. opentrons/hardware_control/protocols/types.py +27 -0
  191. opentrons/hardware_control/robot_calibration.py +224 -0
  192. opentrons/hardware_control/scripts/README.md +28 -0
  193. opentrons/hardware_control/scripts/__init__.py +1 -0
  194. opentrons/hardware_control/scripts/gripper_control.py +208 -0
  195. opentrons/hardware_control/scripts/ot3gripper +7 -0
  196. opentrons/hardware_control/scripts/ot3repl +7 -0
  197. opentrons/hardware_control/scripts/repl.py +187 -0
  198. opentrons/hardware_control/scripts/tc_control.py +97 -0
  199. opentrons/hardware_control/simulator_setup.py +260 -0
  200. opentrons/hardware_control/thread_manager.py +431 -0
  201. opentrons/hardware_control/threaded_async_lock.py +97 -0
  202. opentrons/hardware_control/types.py +792 -0
  203. opentrons/hardware_control/util.py +234 -0
  204. opentrons/legacy_broker.py +53 -0
  205. opentrons/legacy_commands/__init__.py +1 -0
  206. opentrons/legacy_commands/commands.py +483 -0
  207. opentrons/legacy_commands/helpers.py +153 -0
  208. opentrons/legacy_commands/module_commands.py +215 -0
  209. opentrons/legacy_commands/protocol_commands.py +54 -0
  210. opentrons/legacy_commands/publisher.py +155 -0
  211. opentrons/legacy_commands/robot_commands.py +51 -0
  212. opentrons/legacy_commands/types.py +1115 -0
  213. opentrons/motion_planning/__init__.py +32 -0
  214. opentrons/motion_planning/adjacent_slots_getters.py +168 -0
  215. opentrons/motion_planning/deck_conflict.py +396 -0
  216. opentrons/motion_planning/errors.py +35 -0
  217. opentrons/motion_planning/types.py +42 -0
  218. opentrons/motion_planning/waypoints.py +218 -0
  219. opentrons/ordered_set.py +138 -0
  220. opentrons/protocol_api/__init__.py +105 -0
  221. opentrons/protocol_api/_liquid.py +157 -0
  222. opentrons/protocol_api/_liquid_properties.py +814 -0
  223. opentrons/protocol_api/_nozzle_layout.py +31 -0
  224. opentrons/protocol_api/_parameter_context.py +300 -0
  225. opentrons/protocol_api/_parameters.py +31 -0
  226. opentrons/protocol_api/_transfer_liquid_validation.py +108 -0
  227. opentrons/protocol_api/_types.py +43 -0
  228. opentrons/protocol_api/config.py +23 -0
  229. opentrons/protocol_api/core/__init__.py +23 -0
  230. opentrons/protocol_api/core/common.py +33 -0
  231. opentrons/protocol_api/core/core_map.py +74 -0
  232. opentrons/protocol_api/core/engine/__init__.py +22 -0
  233. opentrons/protocol_api/core/engine/_default_labware_versions.py +179 -0
  234. opentrons/protocol_api/core/engine/deck_conflict.py +348 -0
  235. opentrons/protocol_api/core/engine/exceptions.py +19 -0
  236. opentrons/protocol_api/core/engine/instrument.py +2391 -0
  237. opentrons/protocol_api/core/engine/labware.py +238 -0
  238. opentrons/protocol_api/core/engine/load_labware_params.py +73 -0
  239. opentrons/protocol_api/core/engine/module_core.py +1025 -0
  240. opentrons/protocol_api/core/engine/overlap_versions.py +20 -0
  241. opentrons/protocol_api/core/engine/pipette_movement_conflict.py +358 -0
  242. opentrons/protocol_api/core/engine/point_calculations.py +64 -0
  243. opentrons/protocol_api/core/engine/protocol.py +1153 -0
  244. opentrons/protocol_api/core/engine/robot.py +139 -0
  245. opentrons/protocol_api/core/engine/stringify.py +74 -0
  246. opentrons/protocol_api/core/engine/transfer_components_executor.py +990 -0
  247. opentrons/protocol_api/core/engine/well.py +241 -0
  248. opentrons/protocol_api/core/instrument.py +459 -0
  249. opentrons/protocol_api/core/labware.py +151 -0
  250. opentrons/protocol_api/core/legacy/__init__.py +11 -0
  251. opentrons/protocol_api/core/legacy/_labware_geometry.py +37 -0
  252. opentrons/protocol_api/core/legacy/deck.py +369 -0
  253. opentrons/protocol_api/core/legacy/labware_offset_provider.py +108 -0
  254. opentrons/protocol_api/core/legacy/legacy_instrument_core.py +709 -0
  255. opentrons/protocol_api/core/legacy/legacy_labware_core.py +235 -0
  256. opentrons/protocol_api/core/legacy/legacy_module_core.py +592 -0
  257. opentrons/protocol_api/core/legacy/legacy_protocol_core.py +612 -0
  258. opentrons/protocol_api/core/legacy/legacy_well_core.py +162 -0
  259. opentrons/protocol_api/core/legacy/load_info.py +67 -0
  260. opentrons/protocol_api/core/legacy/module_geometry.py +547 -0
  261. opentrons/protocol_api/core/legacy/well_geometry.py +148 -0
  262. opentrons/protocol_api/core/legacy_simulator/__init__.py +16 -0
  263. opentrons/protocol_api/core/legacy_simulator/legacy_instrument_core.py +624 -0
  264. opentrons/protocol_api/core/legacy_simulator/legacy_protocol_core.py +85 -0
  265. opentrons/protocol_api/core/module.py +484 -0
  266. opentrons/protocol_api/core/protocol.py +311 -0
  267. opentrons/protocol_api/core/robot.py +51 -0
  268. opentrons/protocol_api/core/well.py +116 -0
  269. opentrons/protocol_api/core/well_grid.py +45 -0
  270. opentrons/protocol_api/create_protocol_context.py +177 -0
  271. opentrons/protocol_api/deck.py +223 -0
  272. opentrons/protocol_api/disposal_locations.py +244 -0
  273. opentrons/protocol_api/instrument_context.py +3212 -0
  274. opentrons/protocol_api/labware.py +1579 -0
  275. opentrons/protocol_api/module_contexts.py +1425 -0
  276. opentrons/protocol_api/module_validation_and_errors.py +61 -0
  277. opentrons/protocol_api/protocol_context.py +1688 -0
  278. opentrons/protocol_api/robot_context.py +303 -0
  279. opentrons/protocol_api/validation.py +761 -0
  280. opentrons/protocol_engine/__init__.py +155 -0
  281. opentrons/protocol_engine/actions/__init__.py +65 -0
  282. opentrons/protocol_engine/actions/action_dispatcher.py +30 -0
  283. opentrons/protocol_engine/actions/action_handler.py +13 -0
  284. opentrons/protocol_engine/actions/actions.py +302 -0
  285. opentrons/protocol_engine/actions/get_state_update.py +38 -0
  286. opentrons/protocol_engine/clients/__init__.py +5 -0
  287. opentrons/protocol_engine/clients/sync_client.py +174 -0
  288. opentrons/protocol_engine/clients/transports.py +197 -0
  289. opentrons/protocol_engine/commands/__init__.py +757 -0
  290. opentrons/protocol_engine/commands/absorbance_reader/__init__.py +61 -0
  291. opentrons/protocol_engine/commands/absorbance_reader/close_lid.py +154 -0
  292. opentrons/protocol_engine/commands/absorbance_reader/common.py +6 -0
  293. opentrons/protocol_engine/commands/absorbance_reader/initialize.py +151 -0
  294. opentrons/protocol_engine/commands/absorbance_reader/open_lid.py +154 -0
  295. opentrons/protocol_engine/commands/absorbance_reader/read.py +226 -0
  296. opentrons/protocol_engine/commands/air_gap_in_place.py +162 -0
  297. opentrons/protocol_engine/commands/aspirate.py +244 -0
  298. opentrons/protocol_engine/commands/aspirate_in_place.py +184 -0
  299. opentrons/protocol_engine/commands/aspirate_while_tracking.py +211 -0
  300. opentrons/protocol_engine/commands/blow_out.py +146 -0
  301. opentrons/protocol_engine/commands/blow_out_in_place.py +119 -0
  302. opentrons/protocol_engine/commands/calibration/__init__.py +60 -0
  303. opentrons/protocol_engine/commands/calibration/calibrate_gripper.py +166 -0
  304. opentrons/protocol_engine/commands/calibration/calibrate_module.py +117 -0
  305. opentrons/protocol_engine/commands/calibration/calibrate_pipette.py +96 -0
  306. opentrons/protocol_engine/commands/calibration/move_to_maintenance_position.py +156 -0
  307. opentrons/protocol_engine/commands/command.py +308 -0
  308. opentrons/protocol_engine/commands/command_unions.py +974 -0
  309. opentrons/protocol_engine/commands/comment.py +57 -0
  310. opentrons/protocol_engine/commands/configure_for_volume.py +108 -0
  311. opentrons/protocol_engine/commands/configure_nozzle_layout.py +115 -0
  312. opentrons/protocol_engine/commands/custom.py +67 -0
  313. opentrons/protocol_engine/commands/dispense.py +194 -0
  314. opentrons/protocol_engine/commands/dispense_in_place.py +179 -0
  315. opentrons/protocol_engine/commands/dispense_while_tracking.py +204 -0
  316. opentrons/protocol_engine/commands/drop_tip.py +232 -0
  317. opentrons/protocol_engine/commands/drop_tip_in_place.py +205 -0
  318. opentrons/protocol_engine/commands/flex_stacker/__init__.py +64 -0
  319. opentrons/protocol_engine/commands/flex_stacker/common.py +900 -0
  320. opentrons/protocol_engine/commands/flex_stacker/empty.py +293 -0
  321. opentrons/protocol_engine/commands/flex_stacker/fill.py +281 -0
  322. opentrons/protocol_engine/commands/flex_stacker/retrieve.py +339 -0
  323. opentrons/protocol_engine/commands/flex_stacker/set_stored_labware.py +328 -0
  324. opentrons/protocol_engine/commands/flex_stacker/store.py +326 -0
  325. opentrons/protocol_engine/commands/generate_command_schema.py +61 -0
  326. opentrons/protocol_engine/commands/get_next_tip.py +134 -0
  327. opentrons/protocol_engine/commands/get_tip_presence.py +87 -0
  328. opentrons/protocol_engine/commands/hash_command_params.py +38 -0
  329. opentrons/protocol_engine/commands/heater_shaker/__init__.py +102 -0
  330. opentrons/protocol_engine/commands/heater_shaker/close_labware_latch.py +83 -0
  331. opentrons/protocol_engine/commands/heater_shaker/deactivate_heater.py +82 -0
  332. opentrons/protocol_engine/commands/heater_shaker/deactivate_shaker.py +84 -0
  333. opentrons/protocol_engine/commands/heater_shaker/open_labware_latch.py +110 -0
  334. opentrons/protocol_engine/commands/heater_shaker/set_and_wait_for_shake_speed.py +125 -0
  335. opentrons/protocol_engine/commands/heater_shaker/set_target_temperature.py +90 -0
  336. opentrons/protocol_engine/commands/heater_shaker/wait_for_temperature.py +102 -0
  337. opentrons/protocol_engine/commands/home.py +100 -0
  338. opentrons/protocol_engine/commands/identify_module.py +86 -0
  339. opentrons/protocol_engine/commands/labware_handling_common.py +29 -0
  340. opentrons/protocol_engine/commands/liquid_probe.py +464 -0
  341. opentrons/protocol_engine/commands/load_labware.py +210 -0
  342. opentrons/protocol_engine/commands/load_lid.py +154 -0
  343. opentrons/protocol_engine/commands/load_lid_stack.py +272 -0
  344. opentrons/protocol_engine/commands/load_liquid.py +95 -0
  345. opentrons/protocol_engine/commands/load_liquid_class.py +144 -0
  346. opentrons/protocol_engine/commands/load_module.py +223 -0
  347. opentrons/protocol_engine/commands/load_pipette.py +167 -0
  348. opentrons/protocol_engine/commands/magnetic_module/__init__.py +32 -0
  349. opentrons/protocol_engine/commands/magnetic_module/disengage.py +97 -0
  350. opentrons/protocol_engine/commands/magnetic_module/engage.py +119 -0
  351. opentrons/protocol_engine/commands/move_labware.py +546 -0
  352. opentrons/protocol_engine/commands/move_relative.py +102 -0
  353. opentrons/protocol_engine/commands/move_to_addressable_area.py +176 -0
  354. opentrons/protocol_engine/commands/move_to_addressable_area_for_drop_tip.py +198 -0
  355. opentrons/protocol_engine/commands/move_to_coordinates.py +107 -0
  356. opentrons/protocol_engine/commands/move_to_well.py +119 -0
  357. opentrons/protocol_engine/commands/movement_common.py +338 -0
  358. opentrons/protocol_engine/commands/pick_up_tip.py +241 -0
  359. opentrons/protocol_engine/commands/pipetting_common.py +443 -0
  360. opentrons/protocol_engine/commands/prepare_to_aspirate.py +121 -0
  361. opentrons/protocol_engine/commands/pressure_dispense.py +155 -0
  362. opentrons/protocol_engine/commands/reload_labware.py +90 -0
  363. opentrons/protocol_engine/commands/retract_axis.py +75 -0
  364. opentrons/protocol_engine/commands/robot/__init__.py +70 -0
  365. opentrons/protocol_engine/commands/robot/close_gripper_jaw.py +96 -0
  366. opentrons/protocol_engine/commands/robot/common.py +18 -0
  367. opentrons/protocol_engine/commands/robot/move_axes_relative.py +101 -0
  368. opentrons/protocol_engine/commands/robot/move_axes_to.py +100 -0
  369. opentrons/protocol_engine/commands/robot/move_to.py +94 -0
  370. opentrons/protocol_engine/commands/robot/open_gripper_jaw.py +86 -0
  371. opentrons/protocol_engine/commands/save_position.py +109 -0
  372. opentrons/protocol_engine/commands/seal_pipette_to_tip.py +353 -0
  373. opentrons/protocol_engine/commands/set_rail_lights.py +67 -0
  374. opentrons/protocol_engine/commands/set_status_bar.py +89 -0
  375. opentrons/protocol_engine/commands/temperature_module/__init__.py +46 -0
  376. opentrons/protocol_engine/commands/temperature_module/deactivate.py +86 -0
  377. opentrons/protocol_engine/commands/temperature_module/set_target_temperature.py +97 -0
  378. opentrons/protocol_engine/commands/temperature_module/wait_for_temperature.py +104 -0
  379. opentrons/protocol_engine/commands/thermocycler/__init__.py +152 -0
  380. opentrons/protocol_engine/commands/thermocycler/close_lid.py +87 -0
  381. opentrons/protocol_engine/commands/thermocycler/deactivate_block.py +80 -0
  382. opentrons/protocol_engine/commands/thermocycler/deactivate_lid.py +80 -0
  383. opentrons/protocol_engine/commands/thermocycler/open_lid.py +87 -0
  384. opentrons/protocol_engine/commands/thermocycler/run_extended_profile.py +171 -0
  385. opentrons/protocol_engine/commands/thermocycler/run_profile.py +124 -0
  386. opentrons/protocol_engine/commands/thermocycler/set_target_block_temperature.py +140 -0
  387. opentrons/protocol_engine/commands/thermocycler/set_target_lid_temperature.py +100 -0
  388. opentrons/protocol_engine/commands/thermocycler/wait_for_block_temperature.py +93 -0
  389. opentrons/protocol_engine/commands/thermocycler/wait_for_lid_temperature.py +89 -0
  390. opentrons/protocol_engine/commands/touch_tip.py +189 -0
  391. opentrons/protocol_engine/commands/unsafe/__init__.py +161 -0
  392. opentrons/protocol_engine/commands/unsafe/unsafe_blow_out_in_place.py +100 -0
  393. opentrons/protocol_engine/commands/unsafe/unsafe_drop_tip_in_place.py +121 -0
  394. opentrons/protocol_engine/commands/unsafe/unsafe_engage_axes.py +82 -0
  395. opentrons/protocol_engine/commands/unsafe/unsafe_place_labware.py +208 -0
  396. opentrons/protocol_engine/commands/unsafe/unsafe_stacker_close_latch.py +94 -0
  397. opentrons/protocol_engine/commands/unsafe/unsafe_stacker_manual_retrieve.py +295 -0
  398. opentrons/protocol_engine/commands/unsafe/unsafe_stacker_open_latch.py +91 -0
  399. opentrons/protocol_engine/commands/unsafe/unsafe_stacker_prepare_shuttle.py +136 -0
  400. opentrons/protocol_engine/commands/unsafe/unsafe_ungrip_labware.py +77 -0
  401. opentrons/protocol_engine/commands/unsafe/update_position_estimators.py +90 -0
  402. opentrons/protocol_engine/commands/unseal_pipette_from_tip.py +153 -0
  403. opentrons/protocol_engine/commands/verify_tip_presence.py +100 -0
  404. opentrons/protocol_engine/commands/wait_for_duration.py +76 -0
  405. opentrons/protocol_engine/commands/wait_for_resume.py +75 -0
  406. opentrons/protocol_engine/create_protocol_engine.py +193 -0
  407. opentrons/protocol_engine/engine_support.py +28 -0
  408. opentrons/protocol_engine/error_recovery_policy.py +81 -0
  409. opentrons/protocol_engine/errors/__init__.py +191 -0
  410. opentrons/protocol_engine/errors/error_occurrence.py +182 -0
  411. opentrons/protocol_engine/errors/exceptions.py +1308 -0
  412. opentrons/protocol_engine/execution/__init__.py +50 -0
  413. opentrons/protocol_engine/execution/command_executor.py +216 -0
  414. opentrons/protocol_engine/execution/create_queue_worker.py +102 -0
  415. opentrons/protocol_engine/execution/door_watcher.py +119 -0
  416. opentrons/protocol_engine/execution/equipment.py +819 -0
  417. opentrons/protocol_engine/execution/error_recovery_hardware_state_synchronizer.py +101 -0
  418. opentrons/protocol_engine/execution/gantry_mover.py +686 -0
  419. opentrons/protocol_engine/execution/hardware_stopper.py +147 -0
  420. opentrons/protocol_engine/execution/heater_shaker_movement_flagger.py +207 -0
  421. opentrons/protocol_engine/execution/labware_movement.py +297 -0
  422. opentrons/protocol_engine/execution/movement.py +349 -0
  423. opentrons/protocol_engine/execution/pipetting.py +607 -0
  424. opentrons/protocol_engine/execution/queue_worker.py +86 -0
  425. opentrons/protocol_engine/execution/rail_lights.py +25 -0
  426. opentrons/protocol_engine/execution/run_control.py +33 -0
  427. opentrons/protocol_engine/execution/status_bar.py +34 -0
  428. opentrons/protocol_engine/execution/thermocycler_movement_flagger.py +188 -0
  429. opentrons/protocol_engine/execution/thermocycler_plate_lifter.py +81 -0
  430. opentrons/protocol_engine/execution/tip_handler.py +550 -0
  431. opentrons/protocol_engine/labware_offset_standardization.py +194 -0
  432. opentrons/protocol_engine/notes/__init__.py +17 -0
  433. opentrons/protocol_engine/notes/notes.py +59 -0
  434. opentrons/protocol_engine/plugins.py +104 -0
  435. opentrons/protocol_engine/protocol_engine.py +683 -0
  436. opentrons/protocol_engine/resources/__init__.py +26 -0
  437. opentrons/protocol_engine/resources/deck_configuration_provider.py +232 -0
  438. opentrons/protocol_engine/resources/deck_data_provider.py +94 -0
  439. opentrons/protocol_engine/resources/file_provider.py +161 -0
  440. opentrons/protocol_engine/resources/fixture_validation.py +58 -0
  441. opentrons/protocol_engine/resources/labware_data_provider.py +106 -0
  442. opentrons/protocol_engine/resources/labware_validation.py +73 -0
  443. opentrons/protocol_engine/resources/model_utils.py +32 -0
  444. opentrons/protocol_engine/resources/module_data_provider.py +44 -0
  445. opentrons/protocol_engine/resources/ot3_validation.py +21 -0
  446. opentrons/protocol_engine/resources/pipette_data_provider.py +379 -0
  447. opentrons/protocol_engine/slot_standardization.py +128 -0
  448. opentrons/protocol_engine/state/__init__.py +1 -0
  449. opentrons/protocol_engine/state/_abstract_store.py +27 -0
  450. opentrons/protocol_engine/state/_axis_aligned_bounding_box.py +50 -0
  451. opentrons/protocol_engine/state/_labware_origin_math.py +636 -0
  452. opentrons/protocol_engine/state/_move_types.py +83 -0
  453. opentrons/protocol_engine/state/_well_math.py +193 -0
  454. opentrons/protocol_engine/state/addressable_areas.py +699 -0
  455. opentrons/protocol_engine/state/command_history.py +309 -0
  456. opentrons/protocol_engine/state/commands.py +1158 -0
  457. opentrons/protocol_engine/state/config.py +39 -0
  458. opentrons/protocol_engine/state/files.py +57 -0
  459. opentrons/protocol_engine/state/fluid_stack.py +138 -0
  460. opentrons/protocol_engine/state/geometry.py +2359 -0
  461. opentrons/protocol_engine/state/inner_well_math_utils.py +548 -0
  462. opentrons/protocol_engine/state/labware.py +1459 -0
  463. opentrons/protocol_engine/state/liquid_classes.py +82 -0
  464. opentrons/protocol_engine/state/liquids.py +73 -0
  465. opentrons/protocol_engine/state/module_substates/__init__.py +45 -0
  466. opentrons/protocol_engine/state/module_substates/absorbance_reader_substate.py +35 -0
  467. opentrons/protocol_engine/state/module_substates/flex_stacker_substate.py +112 -0
  468. opentrons/protocol_engine/state/module_substates/heater_shaker_module_substate.py +115 -0
  469. opentrons/protocol_engine/state/module_substates/magnetic_block_substate.py +17 -0
  470. opentrons/protocol_engine/state/module_substates/magnetic_module_substate.py +65 -0
  471. opentrons/protocol_engine/state/module_substates/temperature_module_substate.py +67 -0
  472. opentrons/protocol_engine/state/module_substates/thermocycler_module_substate.py +163 -0
  473. opentrons/protocol_engine/state/modules.py +1500 -0
  474. opentrons/protocol_engine/state/motion.py +373 -0
  475. opentrons/protocol_engine/state/pipettes.py +905 -0
  476. opentrons/protocol_engine/state/state.py +421 -0
  477. opentrons/protocol_engine/state/state_summary.py +36 -0
  478. opentrons/protocol_engine/state/tips.py +420 -0
  479. opentrons/protocol_engine/state/update_types.py +904 -0
  480. opentrons/protocol_engine/state/wells.py +290 -0
  481. opentrons/protocol_engine/types/__init__.py +308 -0
  482. opentrons/protocol_engine/types/automatic_tip_selection.py +39 -0
  483. opentrons/protocol_engine/types/command_annotations.py +53 -0
  484. opentrons/protocol_engine/types/deck_configuration.py +81 -0
  485. opentrons/protocol_engine/types/execution.py +96 -0
  486. opentrons/protocol_engine/types/hardware_passthrough.py +25 -0
  487. opentrons/protocol_engine/types/instrument.py +47 -0
  488. opentrons/protocol_engine/types/instrument_sensors.py +47 -0
  489. opentrons/protocol_engine/types/labware.py +131 -0
  490. opentrons/protocol_engine/types/labware_movement.py +22 -0
  491. opentrons/protocol_engine/types/labware_offset_location.py +111 -0
  492. opentrons/protocol_engine/types/labware_offset_vector.py +16 -0
  493. opentrons/protocol_engine/types/liquid.py +40 -0
  494. opentrons/protocol_engine/types/liquid_class.py +59 -0
  495. opentrons/protocol_engine/types/liquid_handling.py +13 -0
  496. opentrons/protocol_engine/types/liquid_level_detection.py +191 -0
  497. opentrons/protocol_engine/types/location.py +194 -0
  498. opentrons/protocol_engine/types/module.py +303 -0
  499. opentrons/protocol_engine/types/partial_tip_configuration.py +76 -0
  500. opentrons/protocol_engine/types/run_time_parameters.py +133 -0
  501. opentrons/protocol_engine/types/tip.py +18 -0
  502. opentrons/protocol_engine/types/util.py +21 -0
  503. opentrons/protocol_engine/types/well_position.py +124 -0
  504. opentrons/protocol_reader/__init__.py +37 -0
  505. opentrons/protocol_reader/extract_labware_definitions.py +66 -0
  506. opentrons/protocol_reader/file_format_validator.py +152 -0
  507. opentrons/protocol_reader/file_hasher.py +27 -0
  508. opentrons/protocol_reader/file_identifier.py +284 -0
  509. opentrons/protocol_reader/file_reader_writer.py +90 -0
  510. opentrons/protocol_reader/input_file.py +16 -0
  511. opentrons/protocol_reader/protocol_files_invalid_error.py +6 -0
  512. opentrons/protocol_reader/protocol_reader.py +188 -0
  513. opentrons/protocol_reader/protocol_source.py +124 -0
  514. opentrons/protocol_reader/role_analyzer.py +86 -0
  515. opentrons/protocol_runner/__init__.py +26 -0
  516. opentrons/protocol_runner/create_simulating_orchestrator.py +118 -0
  517. opentrons/protocol_runner/json_file_reader.py +55 -0
  518. opentrons/protocol_runner/json_translator.py +314 -0
  519. opentrons/protocol_runner/legacy_command_mapper.py +848 -0
  520. opentrons/protocol_runner/legacy_context_plugin.py +116 -0
  521. opentrons/protocol_runner/protocol_runner.py +530 -0
  522. opentrons/protocol_runner/python_protocol_wrappers.py +179 -0
  523. opentrons/protocol_runner/run_orchestrator.py +496 -0
  524. opentrons/protocol_runner/task_queue.py +95 -0
  525. opentrons/protocols/__init__.py +6 -0
  526. opentrons/protocols/advanced_control/__init__.py +0 -0
  527. opentrons/protocols/advanced_control/common.py +38 -0
  528. opentrons/protocols/advanced_control/mix.py +60 -0
  529. opentrons/protocols/advanced_control/transfers/__init__.py +0 -0
  530. opentrons/protocols/advanced_control/transfers/common.py +180 -0
  531. opentrons/protocols/advanced_control/transfers/transfer.py +972 -0
  532. opentrons/protocols/advanced_control/transfers/transfer_liquid_utils.py +231 -0
  533. opentrons/protocols/api_support/__init__.py +0 -0
  534. opentrons/protocols/api_support/constants.py +8 -0
  535. opentrons/protocols/api_support/deck_type.py +110 -0
  536. opentrons/protocols/api_support/definitions.py +18 -0
  537. opentrons/protocols/api_support/instrument.py +151 -0
  538. opentrons/protocols/api_support/labware_like.py +233 -0
  539. opentrons/protocols/api_support/tip_tracker.py +175 -0
  540. opentrons/protocols/api_support/types.py +32 -0
  541. opentrons/protocols/api_support/util.py +403 -0
  542. opentrons/protocols/bundle.py +89 -0
  543. opentrons/protocols/duration/__init__.py +4 -0
  544. opentrons/protocols/duration/errors.py +5 -0
  545. opentrons/protocols/duration/estimator.py +628 -0
  546. opentrons/protocols/execution/__init__.py +0 -0
  547. opentrons/protocols/execution/dev_types.py +181 -0
  548. opentrons/protocols/execution/errors.py +40 -0
  549. opentrons/protocols/execution/execute.py +84 -0
  550. opentrons/protocols/execution/execute_json_v3.py +275 -0
  551. opentrons/protocols/execution/execute_json_v4.py +359 -0
  552. opentrons/protocols/execution/execute_json_v5.py +28 -0
  553. opentrons/protocols/execution/execute_python.py +169 -0
  554. opentrons/protocols/execution/json_dispatchers.py +87 -0
  555. opentrons/protocols/execution/types.py +7 -0
  556. opentrons/protocols/geometry/__init__.py +0 -0
  557. opentrons/protocols/geometry/planning.py +297 -0
  558. opentrons/protocols/labware.py +312 -0
  559. opentrons/protocols/models/__init__.py +0 -0
  560. opentrons/protocols/models/json_protocol.py +679 -0
  561. opentrons/protocols/parameters/__init__.py +0 -0
  562. opentrons/protocols/parameters/csv_parameter_definition.py +77 -0
  563. opentrons/protocols/parameters/csv_parameter_interface.py +96 -0
  564. opentrons/protocols/parameters/exceptions.py +34 -0
  565. opentrons/protocols/parameters/parameter_definition.py +272 -0
  566. opentrons/protocols/parameters/types.py +17 -0
  567. opentrons/protocols/parameters/validation.py +267 -0
  568. opentrons/protocols/parse.py +671 -0
  569. opentrons/protocols/types.py +159 -0
  570. opentrons/py.typed +0 -0
  571. opentrons/resources/scripts/lpc21isp +0 -0
  572. opentrons/resources/smoothie-edge-8414642.hex +23010 -0
  573. opentrons/simulate.py +1065 -0
  574. opentrons/system/__init__.py +6 -0
  575. opentrons/system/camera.py +51 -0
  576. opentrons/system/log_control.py +59 -0
  577. opentrons/system/nmcli.py +856 -0
  578. opentrons/system/resin.py +24 -0
  579. opentrons/system/smoothie_update.py +15 -0
  580. opentrons/system/wifi.py +204 -0
  581. opentrons/tools/__init__.py +0 -0
  582. opentrons/tools/args_handler.py +22 -0
  583. opentrons/tools/write_pipette_memory.py +157 -0
  584. opentrons/types.py +618 -0
  585. opentrons/util/__init__.py +1 -0
  586. opentrons/util/async_helpers.py +166 -0
  587. opentrons/util/broker.py +84 -0
  588. opentrons/util/change_notifier.py +47 -0
  589. opentrons/util/entrypoint_util.py +278 -0
  590. opentrons/util/get_union_elements.py +26 -0
  591. opentrons/util/helpers.py +6 -0
  592. opentrons/util/linal.py +178 -0
  593. opentrons/util/logging_config.py +265 -0
  594. opentrons/util/logging_queue_handler.py +61 -0
  595. opentrons/util/performance_helpers.py +157 -0
  596. opentrons-8.6.0a1.dist-info/METADATA +37 -0
  597. opentrons-8.6.0a1.dist-info/RECORD +600 -0
  598. opentrons-8.6.0a1.dist-info/WHEEL +4 -0
  599. opentrons-8.6.0a1.dist-info/entry_points.txt +3 -0
  600. opentrons-8.6.0a1.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,3212 @@
1
+ from __future__ import annotations
2
+ import logging
3
+ from contextlib import ExitStack
4
+ from typing import Any, List, Optional, Sequence, Union, cast, Tuple
5
+ from opentrons_shared_data.errors.exceptions import (
6
+ CommandPreconditionViolated,
7
+ CommandParameterLimitViolated,
8
+ UnexpectedTipRemovalError,
9
+ UnsupportedHardwareCommand,
10
+ )
11
+
12
+ from opentrons.legacy_broker import LegacyBroker
13
+ from opentrons.hardware_control.dev_types import PipetteDict
14
+ from opentrons import types
15
+ from opentrons.legacy_commands import (
16
+ commands as cmds,
17
+ protocol_commands as protocol_cmds,
18
+ )
19
+
20
+ from opentrons.legacy_commands import publisher
21
+ from opentrons.protocols.advanced_control.mix import mix_from_kwargs
22
+ from opentrons.protocols.advanced_control.transfers import transfer as v1_transfer
23
+ from opentrons.protocols.api_support.deck_type import NoTrashDefinedError
24
+ from opentrons.protocols.api_support.types import APIVersion
25
+ from opentrons.protocols.api_support import instrument
26
+ from opentrons.protocols.api_support.util import (
27
+ FlowRates,
28
+ PlungerSpeeds,
29
+ clamp_value,
30
+ requires_version,
31
+ APIVersionError,
32
+ UnsupportedAPIError,
33
+ )
34
+
35
+ from .core.common import InstrumentCore, ProtocolCore, WellCore
36
+ from .core.core_map import LoadedCoreMap
37
+ from .core.engine import ENGINE_CORE_API_VERSION
38
+ from .core.legacy.legacy_instrument_core import LegacyInstrumentCore
39
+ from .config import Clearances
40
+ from .disposal_locations import TrashBin, WasteChute
41
+ from ._nozzle_layout import NozzleLayout
42
+ from ._liquid import LiquidClass
43
+ from ._transfer_liquid_validation import (
44
+ verify_and_normalize_transfer_args,
45
+ resolve_keep_last_tip,
46
+ )
47
+ from . import labware, validation
48
+ from ..protocols.advanced_control.transfers.common import (
49
+ TransferTipPolicyV2,
50
+ TransferTipPolicyV2Type,
51
+ )
52
+ from ..protocol_engine.types import LiquidTrackingType
53
+
54
+ _DEFAULT_ASPIRATE_CLEARANCE = 1.0
55
+ _DEFAULT_DISPENSE_CLEARANCE = 1.0
56
+
57
+ _log = logging.getLogger(__name__)
58
+
59
+ _PREP_AFTER_ADDED_IN = APIVersion(2, 13)
60
+ """The version after which the pick-up tip procedure should also prepare the plunger."""
61
+ _PRESSES_INCREMENT_REMOVED_IN = APIVersion(2, 14)
62
+ """The version after which the pick-up tip procedure deprecates presses and increment arguments."""
63
+ _DROP_TIP_LOCATION_ALTERNATING_ADDED_IN = APIVersion(2, 15)
64
+ """The version after which a drop-tip-into-trash procedure drops tips in different alternating locations within the trash well."""
65
+ _PARTIAL_NOZZLE_CONFIGURATION_ADDED_IN = APIVersion(2, 16)
66
+ """The version after which a partial nozzle configuration became available for the 96 Channel Pipette."""
67
+ _PARTIAL_NOZZLE_CONFIGURATION_AUTOMATIC_TIP_TRACKING_IN = APIVersion(2, 18)
68
+ """The version after which automatic tip tracking supported partially configured nozzle layouts."""
69
+ _DISPOSAL_LOCATION_OFFSET_ADDED_IN = APIVersion(2, 18)
70
+ """The version after which offsets for deck configured trash containers and changes to alternating tip drop behavior were introduced."""
71
+ _PARTIAL_NOZZLE_CONFIGURATION_SINGLE_ROW_PARTIAL_COLUMN_ADDED_IN = APIVersion(2, 20)
72
+ """The version after which partial nozzle configurations of single, row, and partial column layouts became available."""
73
+ _AIR_GAP_TRACKING_ADDED_IN = APIVersion(2, 22)
74
+ """The version after which air gaps should be implemented with a separate call instead of an aspirate for better liquid volume tracking."""
75
+
76
+
77
+ AdvancedLiquidHandling = v1_transfer.AdvancedLiquidHandling
78
+
79
+
80
+ class _Unset:
81
+ """A sentinel value when no value has been supplied for an argument.
82
+ User code should never use this explicitly."""
83
+
84
+ def __repr__(self) -> str:
85
+ # Without this, the generated docs render the argument as
86
+ # "<opentrons.protocol_api.instrument_context._Unset object at 0x1234>"
87
+ return self.__class__.__name__
88
+
89
+
90
+ class InstrumentContext(publisher.CommandPublisher):
91
+ """
92
+ A context for a specific pipette or instrument.
93
+
94
+ The InstrumentContext class provides the objects, attributes, and methods that allow
95
+ you to use pipettes in your protocols.
96
+
97
+ Methods generally fall into one of two categories.
98
+
99
+ - They can change the state of the InstrumentContext object, like how fast it
100
+ moves liquid or where it disposes of used tips.
101
+
102
+ - They can command the instrument to perform an action, like picking up tips,
103
+ moving to certain locations, and aspirating or dispensing liquid.
104
+
105
+ Objects in this class should not be instantiated directly. Instead, instances are
106
+ returned by :py:meth:`ProtocolContext.load_instrument`.
107
+
108
+ .. versionadded:: 2.0
109
+
110
+ """
111
+
112
+ def __init__(
113
+ self,
114
+ core: InstrumentCore,
115
+ protocol_core: ProtocolCore,
116
+ broker: LegacyBroker,
117
+ api_version: APIVersion,
118
+ tip_racks: List[labware.Labware],
119
+ trash: Optional[Union[labware.Labware, TrashBin, WasteChute]],
120
+ requested_as: str,
121
+ core_map: LoadedCoreMap,
122
+ ) -> None:
123
+ super().__init__(broker)
124
+ self._api_version = api_version
125
+ self._core = core
126
+ self._protocol_core = protocol_core
127
+ self._tip_racks = tip_racks
128
+ self._starting_tip: Union[labware.Well, None] = None
129
+ self._well_bottom_clearances = Clearances(
130
+ default_aspirate=_DEFAULT_ASPIRATE_CLEARANCE,
131
+ default_dispense=_DEFAULT_DISPENSE_CLEARANCE,
132
+ )
133
+ self._user_specified_trash: Union[
134
+ labware.Labware, TrashBin, WasteChute, None
135
+ ] = trash
136
+ self.requested_as = requested_as
137
+ self._core_map = core_map
138
+
139
+ @property
140
+ @requires_version(2, 0)
141
+ def api_version(self) -> APIVersion:
142
+ return self._api_version
143
+
144
+ @property
145
+ @requires_version(2, 0)
146
+ def starting_tip(self) -> Union[labware.Well, None]:
147
+ """
148
+ Which well of a tip rack the pipette should start at when automatically choosing tips to pick up.
149
+
150
+ See :py:meth:`.pick_up_tip()`.
151
+
152
+ .. note::
153
+
154
+ In robot software versions 6.3.0 and 6.3.1, protocols specifying API level
155
+ 2.14 ignored ``starting_tip`` on the second and subsequent calls to
156
+ :py:meth:`.InstrumentContext.pick_up_tip` with no argument. This is fixed
157
+ for all API levels as of robot software version 7.0.0.
158
+ """
159
+ return self._starting_tip
160
+
161
+ @starting_tip.setter
162
+ def starting_tip(self, location: Union[labware.Well, None]) -> None:
163
+ self._starting_tip = location
164
+
165
+ @requires_version(2, 0)
166
+ def reset_tipracks(self) -> None:
167
+ """Reload all tips in each tip rack and reset the starting tip."""
168
+ for tiprack in self.tip_racks:
169
+ tiprack.reset()
170
+ self.starting_tip = None
171
+
172
+ @property
173
+ @requires_version(2, 0)
174
+ def default_speed(self) -> float:
175
+ """The speed at which the robot's gantry moves in mm/s.
176
+
177
+ The default speed for Flex varies between 300 and 350 mm/s. The OT-2 default is
178
+ 400 mm/s. In addition to changing the default, the speed of individual motions
179
+ can be changed with the ``speed`` argument of the
180
+ :py:meth:`InstrumentContext.move_to` method. See :ref:`gantry_speed`.
181
+ """
182
+ return self._core.get_default_speed()
183
+
184
+ @default_speed.setter
185
+ def default_speed(self, speed: float) -> None:
186
+ self._core.set_default_speed(speed)
187
+
188
+ @requires_version(2, 21)
189
+ def get_minimum_liquid_sense_height(self) -> float:
190
+ """Get the minimum allowed height for liquid-level detection."""
191
+ return self._core.get_minimum_liquid_sense_height()
192
+
193
+ @requires_version(2, 0)
194
+ def aspirate( # noqa: C901
195
+ self,
196
+ volume: Optional[float] = None,
197
+ location: Optional[Union[types.Location, labware.Well]] = None,
198
+ rate: float = 1.0,
199
+ flow_rate: Optional[float] = None,
200
+ ) -> InstrumentContext:
201
+ """
202
+ Draw liquid into a pipette tip.
203
+
204
+ See :ref:`new-aspirate` for more details and examples.
205
+
206
+ :param volume: The volume to aspirate, measured in µL. If unspecified,
207
+ defaults to the maximum volume for the pipette and its currently
208
+ attached tip.
209
+
210
+ If ``aspirate`` is called with a volume of precisely 0, its behavior
211
+ depends on the API level of the protocol. On API levels below 2.16,
212
+ it will behave the same as a volume of ``None``/unspecified: aspirate
213
+ until the pipette is full. On API levels at or above 2.16, no liquid
214
+ will be aspirated.
215
+ :type volume: int or float
216
+ :param location: Tells the robot where to aspirate from. The location can be
217
+ a :py:class:`.Well` or a :py:class:`.Location`.
218
+
219
+ - If the location is a ``Well``, the robot will aspirate at
220
+ or above the bottom center of the well. The distance (in mm)
221
+ from the well bottom is specified by
222
+ :py:obj:`well_bottom_clearance.aspirate
223
+ <well_bottom_clearance>`.
224
+
225
+ - If the location is a ``Location`` (e.g., the result of
226
+ :py:meth:`.Well.top` or :py:meth:`.Well.bottom`), the robot
227
+ will aspirate from that specified position.
228
+
229
+ - If the ``location`` is unspecified, the robot will
230
+ aspirate from its current position.
231
+ :param rate: A multiplier for the default flow rate of the pipette. Calculated
232
+ as ``rate`` multiplied by :py:attr:`flow_rate.aspirate
233
+ <flow_rate>`. If not specified, defaults to 1.0. See
234
+ :ref:`new-plunger-flow-rates`.
235
+ :type rate: float
236
+ :param flow_rate: The absolute flow rate in µL/s. If ``flow_rate`` is specified,
237
+ ``rate`` must not be set.
238
+ :type flow_rate: float
239
+ :returns: This instance.
240
+
241
+ .. note::
242
+
243
+ If ``aspirate`` is called with a single, unnamed argument, it will treat
244
+ that argument as ``volume``. If you want to call ``aspirate`` with only
245
+ ``location``, specify it as a keyword argument:
246
+ ``pipette.aspirate(location=plate['A1'])``
247
+
248
+ .. versionchanged:: 2.24
249
+ Added the ``flow_rate`` parameter.
250
+ """
251
+ if flow_rate is not None:
252
+ if self.api_version < APIVersion(2, 24):
253
+ raise APIVersionError(
254
+ api_element="flow_rate",
255
+ until_version="2.24",
256
+ current_version=f"{self.api_version}",
257
+ )
258
+ if rate != 1.0:
259
+ raise ValueError("rate must not be set if flow_rate is specified")
260
+ rate = flow_rate / self._core.get_aspirate_flow_rate()
261
+ else:
262
+ flow_rate = self._core.get_aspirate_flow_rate(rate)
263
+
264
+ _log.debug(
265
+ "aspirate {} from {} at {} µL/s".format(
266
+ volume, location if location else "current position", flow_rate
267
+ )
268
+ )
269
+
270
+ move_to_location: types.Location
271
+ well: Optional[labware.Well]
272
+ last_location = self._get_last_location_by_api_version()
273
+ try:
274
+ target = validation.validate_location(
275
+ location=location, last_location=last_location
276
+ )
277
+ except validation.NoLocationError as e:
278
+ raise RuntimeError(
279
+ "If aspirate is called without an explicit location, another"
280
+ " method that moves to a location (such as move_to or "
281
+ "dispense) must previously have been called so the robot "
282
+ "knows where it is."
283
+ ) from e
284
+
285
+ if isinstance(target, validation.DisposalTarget):
286
+ raise ValueError(
287
+ "Trash Bin and Waste Chute are not acceptable location parameters for Aspirate commands."
288
+ )
289
+ move_to_location, well, meniscus_tracking = self._handle_aspirate_target(
290
+ target=target
291
+ )
292
+ if self.api_version >= APIVersion(2, 11):
293
+ instrument.validate_takes_liquid(
294
+ location=move_to_location,
295
+ reject_module=self.api_version >= APIVersion(2, 13),
296
+ reject_adapter=self.api_version >= APIVersion(2, 15),
297
+ )
298
+
299
+ if self.api_version >= APIVersion(2, 16):
300
+ c_vol = self._core.get_available_volume() if volume is None else volume
301
+ else:
302
+ c_vol = self._core.get_available_volume() if not volume else volume
303
+
304
+ if (
305
+ self.api_version >= APIVersion(2, 20)
306
+ and well is not None
307
+ and self.liquid_presence_detection
308
+ and self._core.nozzle_configuration_valid_for_lld()
309
+ and self._core.get_current_volume() == 0
310
+ and self._core.get_has_clean_tip()
311
+ ):
312
+ self._raise_if_pressure_not_supported_by_pipette()
313
+ self.require_liquid_presence(well=well)
314
+
315
+ with publisher.publish_context(
316
+ broker=self.broker,
317
+ command=cmds.aspirate(
318
+ instrument=self,
319
+ volume=c_vol,
320
+ location=move_to_location,
321
+ flow_rate=flow_rate,
322
+ rate=rate,
323
+ ),
324
+ ):
325
+ self._core.aspirate(
326
+ location=move_to_location,
327
+ well_core=well._core if well is not None else None,
328
+ volume=c_vol,
329
+ rate=rate,
330
+ flow_rate=flow_rate,
331
+ in_place=target.in_place,
332
+ meniscus_tracking=meniscus_tracking,
333
+ )
334
+
335
+ return self
336
+
337
+ @requires_version(2, 0)
338
+ def dispense( # noqa: C901
339
+ self,
340
+ volume: Optional[float] = None,
341
+ location: Optional[
342
+ Union[types.Location, labware.Well, TrashBin, WasteChute]
343
+ ] = None,
344
+ rate: float = 1.0,
345
+ push_out: Optional[float] = None,
346
+ flow_rate: Optional[float] = None,
347
+ ) -> InstrumentContext:
348
+ """
349
+ Dispense liquid from a pipette tip.
350
+
351
+ See :ref:`new-dispense` for more details and examples.
352
+
353
+ :param volume: The volume to dispense, measured in µL.
354
+
355
+ - If unspecified or ``None``, dispense the :py:attr:`current_volume`.
356
+
357
+ - If 0, the behavior of ``dispense()`` depends on the API level
358
+ of the protocol. In API version 2.16 and earlier, dispense all
359
+ liquid in the pipette (same as unspecified or ``None``). In API
360
+ version 2.17 and later, dispense no liquid.
361
+
362
+ - If greater than :py:obj:`.current_volume`, the behavior of
363
+ ``dispense()`` depends on the API level of the protocol. In API
364
+ version 2.16 and earlier, dispense all liquid in the pipette.
365
+ In API version 2.17 and later, raise an error.
366
+
367
+ :type volume: int or float
368
+
369
+ :param location: Tells the robot where to dispense liquid held in the pipette.
370
+ The location can be a :py:class:`.Well`, :py:class:`.Location`,
371
+ :py:class:`.TrashBin`, or :py:class:`.WasteChute`.
372
+
373
+ - If a ``Well``, the pipette will dispense
374
+ at or above the bottom center of the well. The distance (in
375
+ mm) from the well bottom is specified by
376
+ :py:obj:`well_bottom_clearance.dispense
377
+ <well_bottom_clearance>`.
378
+
379
+ - If a ``Location`` (e.g., the result of
380
+ :py:meth:`.Well.top` or :py:meth:`.Well.bottom`), the pipette
381
+ will dispense at that specified position.
382
+
383
+ - If a trash container, the pipette will dispense at a location
384
+ relative to its center and the trash container's top center.
385
+ See :ref:`position-relative-trash` for details.
386
+
387
+ - If unspecified, the pipette will
388
+ dispense at its current position.
389
+
390
+ If only a ``location`` is passed (e.g.,
391
+ ``pipette.dispense(location=plate['A1'])``), all of the
392
+ liquid aspirated into the pipette will be dispensed (the
393
+ amount is accessible through :py:attr:`current_volume`).
394
+
395
+ .. versionchanged:: 2.16
396
+ Accepts ``TrashBin`` and ``WasteChute`` values.
397
+
398
+ :param rate: How quickly a pipette dispenses liquid. The speed in µL/s is
399
+ calculated as ``rate`` multiplied by :py:attr:`flow_rate.dispense
400
+ <flow_rate>`. If not specified, defaults to 1.0. See
401
+ :ref:`new-plunger-flow-rates`.
402
+ :type rate: float
403
+
404
+ :param push_out: Continue past the plunger bottom to help ensure all liquid
405
+ leaves the tip. Measured in µL. The default value is ``None``.
406
+
407
+ When not specified or set to ``None``, the plunger moves by a non-zero default amount.
408
+
409
+ For a table of default values, see :ref:`push-out-dispense`.
410
+ :type push_out: float
411
+
412
+ :param flow_rate: The absolute flow rate in µL/s. If ``flow_rate`` is specified,
413
+ ``rate`` must not be set.
414
+ :type flow_rate: float
415
+
416
+ :returns: This instance.
417
+
418
+ .. note::
419
+
420
+ If ``dispense`` is called with a single, unnamed argument, it will treat
421
+ that argument as ``volume``. If you want to call ``dispense`` with only
422
+ ``location``, specify it as a keyword argument:
423
+ ``pipette.dispense(location=plate['A1'])``.
424
+
425
+ .. versionchanged:: 2.15
426
+ Added the ``push_out`` parameter.
427
+
428
+ .. versionchanged:: 2.17
429
+ Behavior of the ``volume`` parameter.
430
+
431
+ .. versionchanged:: 2.24
432
+ Added the ``flow_rate`` parameter.
433
+
434
+ .. versionchanged:: 2.24
435
+ ``location`` is no longer required if the pipette just moved to, dispensed, or blew out
436
+ into a trash bin or waste chute.
437
+ """
438
+ if self.api_version < APIVersion(2, 15) and push_out:
439
+ raise APIVersionError(
440
+ api_element="Parameter push_out",
441
+ until_version="2.15",
442
+ current_version=f"{self.api_version}",
443
+ )
444
+
445
+ if flow_rate is not None:
446
+ if self.api_version < APIVersion(2, 24):
447
+ raise APIVersionError(
448
+ api_element="flow_rate",
449
+ until_version="2.24",
450
+ current_version=f"{self.api_version}",
451
+ )
452
+ if rate != 1.0:
453
+ raise ValueError("rate must not be set if flow_rate is specified")
454
+ rate = flow_rate / self._core.get_dispense_flow_rate()
455
+ else:
456
+ flow_rate = self._core.get_dispense_flow_rate(rate)
457
+
458
+ _log.debug(
459
+ "dispense {} from {} at {} µL/s".format(
460
+ volume, location if location else "current position", flow_rate
461
+ )
462
+ )
463
+
464
+ last_location = self._get_last_location_by_api_version()
465
+ try:
466
+ target = validation.validate_location(
467
+ location=location, last_location=last_location
468
+ )
469
+ except validation.NoLocationError as e:
470
+ raise RuntimeError(
471
+ "If dispense is called without an explicit location, another"
472
+ " method that moves to a location (such as move_to or "
473
+ "aspirate) must previously have been called so the robot "
474
+ "knows where it is."
475
+ ) from e
476
+
477
+ if self.api_version >= APIVersion(2, 16):
478
+ c_vol = self._core.get_current_volume() if volume is None else volume
479
+ else:
480
+ c_vol = self._core.get_current_volume() if not volume else volume
481
+
482
+ if isinstance(target, validation.DisposalTarget):
483
+ with publisher.publish_context(
484
+ broker=self.broker,
485
+ command=cmds.dispense_in_disposal_location(
486
+ instrument=self,
487
+ volume=c_vol,
488
+ location=target.location,
489
+ rate=rate,
490
+ flow_rate=flow_rate,
491
+ ),
492
+ ):
493
+ self._core.dispense(
494
+ volume=c_vol,
495
+ rate=rate,
496
+ location=target.location,
497
+ well_core=None,
498
+ flow_rate=flow_rate,
499
+ in_place=target.in_place,
500
+ push_out=push_out,
501
+ meniscus_tracking=None,
502
+ )
503
+ return self
504
+
505
+ move_to_location, well, meniscus_tracking = self._handle_dispense_target(
506
+ target=target
507
+ )
508
+
509
+ if self.api_version >= APIVersion(2, 11):
510
+ instrument.validate_takes_liquid(
511
+ location=move_to_location,
512
+ reject_module=self.api_version >= APIVersion(2, 13),
513
+ reject_adapter=self.api_version >= APIVersion(2, 15),
514
+ )
515
+
516
+ with publisher.publish_context(
517
+ broker=self.broker,
518
+ command=cmds.dispense(
519
+ instrument=self,
520
+ volume=c_vol,
521
+ location=move_to_location,
522
+ rate=rate,
523
+ flow_rate=flow_rate,
524
+ ),
525
+ ):
526
+ self._core.dispense(
527
+ volume=c_vol,
528
+ rate=rate,
529
+ location=move_to_location,
530
+ well_core=well._core if well is not None else None,
531
+ flow_rate=flow_rate,
532
+ in_place=target.in_place,
533
+ push_out=push_out,
534
+ meniscus_tracking=meniscus_tracking,
535
+ )
536
+
537
+ return self
538
+
539
+ @requires_version(2, 0)
540
+ def mix( # noqa: C901
541
+ self,
542
+ repetitions: int = 1,
543
+ volume: Optional[float] = None,
544
+ location: Optional[Union[types.Location, labware.Well]] = None,
545
+ rate: float = 1.0,
546
+ aspirate_flow_rate: Optional[float] = None,
547
+ dispense_flow_rate: Optional[float] = None,
548
+ aspirate_delay: Optional[float] = None,
549
+ dispense_delay: Optional[float] = None,
550
+ final_push_out: Optional[float] = None,
551
+ ) -> InstrumentContext:
552
+ """
553
+ Mix a volume of liquid by repeatedly aspirating and dispensing it in a single location.
554
+
555
+ See :ref:`mix` for examples.
556
+
557
+ :param repetitions: Number of times to mix (default is 1).
558
+ :param volume: The volume to mix, measured in µL. If unspecified, defaults
559
+ to the maximum volume for the pipette and its attached tip.
560
+
561
+ If ``mix`` is called with a volume of precisely 0, its behavior
562
+ depends on the API level of the protocol. On API levels below 2.16,
563
+ it will behave the same as a volume of ``None``/unspecified: mix
564
+ the full working volume of the pipette. On API levels at or above 2.16,
565
+ no liquid will be mixed.
566
+ :param location: The :py:class:`.Well` or :py:class:`~.types.Location` where the
567
+ pipette will mix. If unspecified, the pipette will mix at its
568
+ current position.
569
+ :param rate: How quickly the pipette aspirates and dispenses liquid while
570
+ mixing. The aspiration flow rate is calculated as ``rate``
571
+ multiplied by :py:attr:`flow_rate.aspirate <flow_rate>`. The
572
+ dispensing flow rate is calculated as ``rate`` multiplied by
573
+ :py:attr:`flow_rate.dispense <flow_rate>`. See
574
+ :ref:`new-plunger-flow-rates`.
575
+ :param aspirate_flow_rate: The absolute flow rate for each aspirate in the mix, in µL/s.
576
+ If this is specified, ``rate`` must not be set.
577
+ :param dispense_flow_rate: The absolute flow rate for each dispense in the mix, in µL/s.
578
+ If this is specified, ``rate`` must not be set.
579
+ :param aspirate_delay: How long to wait after each aspirate in the mix, in seconds.
580
+ :param dispense_delay: How long to wait after each dispense in the mix, in seconds.
581
+ :param final_push_out: How much volume to push out after the final mix repetition. The
582
+ pipette will not push out after earlier repetitions. If
583
+ not specified or ``None``, the pipette will push out the
584
+ default non-zero amount. See :ref:`push-out-dispense`.
585
+ :raises: ``UnexpectedTipRemovalError`` -- If no tip is attached to the pipette.
586
+ :returns: This instance.
587
+
588
+ .. note::
589
+
590
+ All the arguments of ``mix`` are optional. However, if you omit one of them,
591
+ all subsequent arguments must be passed as keyword arguments. For instance,
592
+ ``pipette.mix(1, location=wellplate['A1'])`` is a valid call, but
593
+ ``pipette.mix(1, wellplate['A1'])`` is not.
594
+
595
+ .. versionchanged:: 2.21
596
+ Does not repeatedly check for liquid presence.
597
+ .. versionchanged:: 2.24
598
+ Adds the ``aspirate_flow_rate``, ``dispense_flow_rate``, ``aspirate_delay``,
599
+ ``dispense_delay``, and ``final_push_out`` parameters.
600
+ """
601
+ _log.debug(
602
+ "mixing {}uL with {} repetitions in {} at rate={}".format(
603
+ volume, repetitions, location if location else "current position", rate
604
+ )
605
+ )
606
+ if not self._core.has_tip():
607
+ raise UnexpectedTipRemovalError("mix", self.name, self.mount)
608
+
609
+ if self.api_version >= APIVersion(2, 16):
610
+ c_vol = self._core.get_available_volume() if volume is None else volume
611
+ else:
612
+ c_vol = self._core.get_available_volume() if not volume else volume
613
+
614
+ if aspirate_flow_rate:
615
+ if self.api_version < APIVersion(2, 24):
616
+ raise APIVersionError(
617
+ api_element="aspirate_flow_rate",
618
+ until_version="2.24",
619
+ current_version=f"{self._api_version}",
620
+ )
621
+ if rate != 1.0:
622
+ raise ValueError(
623
+ "rate must not be set if aspirate_flow_rate is specified"
624
+ )
625
+ if dispense_flow_rate:
626
+ if self.api_version < APIVersion(2, 24):
627
+ raise APIVersionError(
628
+ api_element="dispense_flow_rate",
629
+ until_version="2.24",
630
+ current_version=f"{self._api_version}",
631
+ )
632
+ if rate != 1.0:
633
+ raise ValueError(
634
+ "rate must not be set if dispense_flow_rate is specified"
635
+ )
636
+ if aspirate_delay and self.api_version < APIVersion(2, 24):
637
+ raise APIVersionError(
638
+ api_element="aspirate_delay",
639
+ until_version="2.24",
640
+ current_version=f"{self._api_version}",
641
+ )
642
+ if dispense_delay and self.api_version < APIVersion(2, 24):
643
+ raise APIVersionError(
644
+ api_element="dispense_delay",
645
+ until_version="2.24",
646
+ current_version=f"{self._api_version}",
647
+ )
648
+ if final_push_out and self.api_version < APIVersion(2, 24):
649
+ raise APIVersionError(
650
+ api_element="final_push_out",
651
+ until_version="2.24",
652
+ current_version=f"{self._api_version}",
653
+ )
654
+
655
+ def delay_with_publish(seconds: float) -> None:
656
+ # We don't have access to ProtocolContext.delay() which would automatically
657
+ # publish a message to the broker, so we have to do it manually:
658
+ with publisher.publish_context(
659
+ broker=self.broker,
660
+ command=protocol_cmds.delay(seconds=seconds, minutes=0, msg=None),
661
+ ):
662
+ self._protocol_core.delay(seconds=seconds, msg=None)
663
+
664
+ def aspirate_with_delay(
665
+ location: Optional[types.Location | labware.Well],
666
+ ) -> None:
667
+ self.aspirate(volume, location, rate, flow_rate=aspirate_flow_rate)
668
+ if aspirate_delay:
669
+ delay_with_publish(aspirate_delay)
670
+
671
+ def dispense_with_delay(push_out: Optional[float]) -> None:
672
+ self.dispense(
673
+ volume, None, rate, flow_rate=dispense_flow_rate, push_out=push_out
674
+ )
675
+ if dispense_delay:
676
+ delay_with_publish(dispense_delay)
677
+
678
+ with publisher.publish_context(
679
+ broker=self.broker,
680
+ command=cmds.mix(
681
+ instrument=self,
682
+ repetitions=repetitions,
683
+ volume=c_vol,
684
+ location=location,
685
+ ),
686
+ ):
687
+ aspirate_with_delay(location=location)
688
+ with AutoProbeDisable(self):
689
+ while repetitions - 1 > 0:
690
+ # starting in 2.16, we disable push_out on all but the last
691
+ # dispense() to prevent the tip from jumping out of the liquid
692
+ # during the mix (PR #14004):
693
+ dispense_with_delay(
694
+ push_out=0 if self.api_version >= APIVersion(2, 16) else None
695
+ )
696
+ # aspirate location was set above, do subsequent aspirates in-place:
697
+ aspirate_with_delay(location=None)
698
+ repetitions -= 1
699
+ if final_push_out is not None:
700
+ dispense_with_delay(push_out=final_push_out)
701
+ else:
702
+ dispense_with_delay(push_out=None)
703
+ return self
704
+
705
+ @requires_version(2, 0)
706
+ def blow_out(
707
+ self,
708
+ location: Optional[
709
+ Union[types.Location, labware.Well, TrashBin, WasteChute]
710
+ ] = None,
711
+ ) -> InstrumentContext:
712
+ """
713
+ Blow an extra amount of air through a pipette's tip to clear it.
714
+
715
+ If :py:meth:`dispense` is used to empty a pipette, usually a small amount of
716
+ liquid remains in the tip. During a blowout, the pipette moves the plunger
717
+ beyond its normal limits to help remove all liquid from the pipette tip. See
718
+ :ref:`blow-out`.
719
+
720
+ :param location: The blowout location. If no location is specified, the pipette
721
+ will blow out from its current position.
722
+
723
+ .. versionchanged:: 2.16
724
+ Accepts ``TrashBin`` and ``WasteChute`` values.
725
+
726
+ :type location: :py:class:`.Well` or :py:class:`.Location` or ``None``
727
+
728
+ :raises RuntimeError: If no location is specified and the location cache is
729
+ ``None``. This should happen if ``blow_out()`` is called
730
+ without first calling a method that takes a location, like
731
+ :py:meth:`.aspirate` or :py:meth:`dispense`.
732
+ :returns: This instance.
733
+
734
+ .. versionchanged:: 2.24
735
+ ``location`` is no longer required if the pipette just moved to, dispensed, or blew out
736
+ into a trash bin or waste chute.
737
+ """
738
+ well: Optional[labware.Well] = None
739
+ move_to_location: types.Location
740
+
741
+ last_location = self._get_last_location_by_api_version()
742
+ try:
743
+ target = validation.validate_location(
744
+ location=location, last_location=last_location
745
+ )
746
+ except validation.NoLocationError as e:
747
+ raise RuntimeError(
748
+ "If blow out is called without an explicit location, another"
749
+ " method that moves to a location (such as move_to or "
750
+ "dispense) must previously have been called so the robot "
751
+ "knows where it is."
752
+ ) from e
753
+
754
+ if isinstance(target, validation.WellTarget):
755
+ if target.well.parent.is_tiprack:
756
+ _log.warning(
757
+ "Blow_out being performed on a tiprack. "
758
+ "Please re-check your code"
759
+ )
760
+ if target.location:
761
+ # because the lower levels of blowout don't handle LiquidHandlingWellLocation and
762
+ # there is no "operation_volume" for blowout we need to convert the relative location
763
+ # given with a .meniscus to an absolute point. To maintain the meniscus behavior
764
+ # we can just add the offset to the current liquid height.
765
+ if target.location.meniscus_tracking:
766
+ move_to_location = target.well.bottom(
767
+ target.well.current_liquid_height() # type: ignore [arg-type]
768
+ + target.location.point.z
769
+ )
770
+ else:
771
+ move_to_location = target.location
772
+ else:
773
+ move_to_location = target.well.top()
774
+ well = target.well
775
+ elif isinstance(target, validation.PointTarget):
776
+ move_to_location = target.location
777
+ elif isinstance(target, validation.DisposalTarget):
778
+ with publisher.publish_context(
779
+ broker=self.broker,
780
+ command=cmds.blow_out_in_disposal_location(
781
+ instrument=self, location=target.location
782
+ ),
783
+ ):
784
+ self._core.blow_out(
785
+ location=target.location,
786
+ well_core=None,
787
+ in_place=target.in_place,
788
+ )
789
+ return self
790
+
791
+ with publisher.publish_context(
792
+ broker=self.broker,
793
+ command=cmds.blow_out(instrument=self, location=move_to_location),
794
+ ):
795
+ self._core.blow_out(
796
+ location=move_to_location,
797
+ well_core=well._core if well is not None else None,
798
+ in_place=target.in_place,
799
+ )
800
+
801
+ return self
802
+
803
+ def _determine_speed(self, speed: float) -> float:
804
+ if self.api_version < APIVersion(2, 4):
805
+ return clamp_value(speed, 80, 20, "touch_tip:")
806
+ else:
807
+ return clamp_value(speed, 80, 1, "touch_tip:")
808
+
809
+ @publisher.publish(command=cmds.touch_tip)
810
+ @requires_version(2, 0)
811
+ def touch_tip( # noqa: C901
812
+ self,
813
+ location: Optional[labware.Well] = None,
814
+ radius: float = 1.0,
815
+ v_offset: float = -1.0,
816
+ speed: float = 60.0,
817
+ mm_from_edge: Union[float, _Unset] = _Unset(),
818
+ ) -> InstrumentContext:
819
+ """
820
+ Touch the pipette tip to the sides of a well, with the intent of removing leftover droplets.
821
+
822
+ See :ref:`touch-tip` for more details and examples.
823
+
824
+ :param location: If no location is passed, the pipette will touch its tip at the
825
+ edges of the current well.
826
+ :type location: :py:class:`.Well` or ``None``
827
+ :param radius: How far to move, as a proportion of the target well's radius.
828
+ When ``radius=1.0``, the pipette tip will move all the way to the
829
+ edge of the target well. When ``radius=0.5``, it will move to 50%
830
+ of the well's radius. Default is 1.0 (100%)
831
+ :type radius: float
832
+ :param v_offset: How far above or below the well to touch the tip, measured in mm.
833
+ A positive offset moves the tip higher above the well.
834
+ A negative offset moves the tip lower into the well.
835
+ Default is -1.0 mm.
836
+ :type v_offset: float
837
+ :param speed: The speed for touch tip motion, in mm/s.
838
+
839
+ - Default: 60.0 mm/s
840
+ - Maximum: 80.0 mm/s
841
+ - Minimum: 1.0 mm/s
842
+ :type speed: float
843
+ :param mm_from_edge: How far to move inside the well, as a distance from the
844
+ well's edge.
845
+ When ``mm_from_edge=0``, the pipette will move to the target well's edge to touch the tip. When ``mm_from_edge=1``,
846
+ the pipette will move to 1 mm from the target well's edge to touch the tip.
847
+ Values lower than 0 will press the tip harder into the target well's
848
+ walls; higher values will touch the well more lightly, or
849
+ not at all.
850
+ ``mm_from_edge`` and ``radius`` are mutually exclusive: to
851
+ use ``mm_from_edge``, ``radius`` must be unspecified (left
852
+ to its default value of 1.0).
853
+ :type mm_from_edge: float
854
+ :raises: ``UnexpectedTipRemovalError`` -- If no tip is attached to the pipette.
855
+ :raises RuntimeError: If no location is specified and the location cache is
856
+ ``None``. This should happen if ``touch_tip`` is called
857
+ without first calling a method that takes a location, like
858
+ :py:meth:`.aspirate` or :py:meth:`dispense`.
859
+ :raises: ValueError: If both ``mm_from_edge`` and ``radius`` are specified.
860
+ :returns: This instance.
861
+
862
+ .. versionchanged:: 2.24
863
+ Added the ``mm_from_edge`` parameter.
864
+ """
865
+ if not self._core.has_tip():
866
+ raise UnexpectedTipRemovalError("touch_tip", self.name, self.mount)
867
+
868
+ checked_speed = self._determine_speed(speed)
869
+
870
+ # If location is a valid well, move to the well first
871
+ if location is None:
872
+ last_location = self._protocol_core.get_last_location()
873
+ if last_location is None or isinstance(
874
+ last_location, (TrashBin, WasteChute)
875
+ ):
876
+ raise RuntimeError(
877
+ f"Cached location of {last_location} is not valid for touch tip."
878
+ )
879
+ parent_labware, well = last_location.labware.get_parent_labware_and_well()
880
+ if not well or not parent_labware:
881
+ raise RuntimeError(
882
+ f"Last location {location} has no associated well or labware."
883
+ )
884
+ elif isinstance(location, labware.Well):
885
+ well = location
886
+ parent_labware = well.parent
887
+ else:
888
+ raise TypeError(f"location should be a Well, but it is {location}")
889
+
890
+ if not isinstance(mm_from_edge, _Unset):
891
+ if self.api_version < APIVersion(2, 24):
892
+ raise APIVersionError(
893
+ api_element="mm_from_edge",
894
+ until_version="2.24",
895
+ current_version=f"{self.api_version}",
896
+ )
897
+ if radius != 1.0:
898
+ raise ValueError(
899
+ "radius must be set to 1.0 if mm_from_edge is specified"
900
+ )
901
+
902
+ if "touchTipDisabled" in parent_labware.quirks:
903
+ _log.info(f"Ignoring touch tip on labware {well}")
904
+ return self
905
+ if parent_labware.is_tiprack:
906
+ _log.warning(
907
+ "Touch_tip being performed on a tiprack. Please re-check your code"
908
+ )
909
+
910
+ if self.api_version < APIVersion(2, 4):
911
+ move_to_location = well.top()
912
+ else:
913
+ move_to_location = well.top(z=v_offset)
914
+
915
+ self._core.touch_tip(
916
+ location=move_to_location,
917
+ well_core=well._core,
918
+ radius=radius,
919
+ z_offset=v_offset,
920
+ speed=checked_speed,
921
+ mm_from_edge=mm_from_edge if not isinstance(mm_from_edge, _Unset) else None,
922
+ )
923
+ return self
924
+
925
+ @publisher.publish(command=cmds.air_gap)
926
+ @requires_version(2, 0)
927
+ def air_gap( # noqa: C901
928
+ self,
929
+ volume: Optional[float] = None,
930
+ height: Optional[float] = None,
931
+ in_place: Optional[bool] = None,
932
+ rate: Optional[float] = None,
933
+ flow_rate: Optional[float] = None,
934
+ ) -> InstrumentContext:
935
+ """
936
+ Draw air into the pipette's tip at the current well.
937
+
938
+ See :ref:`air-gap`.
939
+
940
+ :param volume: The amount of air, measured in µL. Calling ``air_gap()`` with no
941
+ arguments uses the entire remaining volume in the pipette.
942
+ :type volume: float
943
+
944
+ :param height: The height, in mm, to move above the current well before creating
945
+ the air gap. The default is 5 mm above the current well.
946
+ :type height: float
947
+
948
+ :param in_place: Air gap at the pipette's current position, without moving to
949
+ some height above the well. If ``in_place`` is specified,
950
+ ``height`` must be unset.
951
+ :type in_place: bool
952
+
953
+ :param rate: A multiplier for the default flow rate of the pipette. Calculated
954
+ as ``rate`` multiplied by :py:attr:`flow_rate.aspirate
955
+ <flow_rate>`. If neither rate nor flow_rate is specified, the pipette
956
+ will aspirate at a rate of 1.0 * InstrumentContext.flow_rate.aspirate. See
957
+ :ref:`new-plunger-flow-rates`.
958
+ :type rate: float
959
+
960
+ :param flow_rate: The rate, in µL/s, at which the pipette will draw in air.
961
+ :type flow_rate: float
962
+
963
+ :raises: ``UnexpectedTipRemovalError`` -- If no tip is attached to the pipette.
964
+
965
+ :raises RuntimeError: If location cache is ``None`` and the air gap is not
966
+ ``in_place``. This would happen if ``air_gap()`` is called
967
+ without first calling a method that takes a location (e.g.,
968
+ :py:meth:`.aspirate`, :py:meth:`dispense`)
969
+
970
+ :returns: This instance.
971
+
972
+ Both ``volume`` and ``height`` are optional, but if you want to specify only
973
+ ``height`` you must do it as a keyword argument:
974
+ ``pipette.air_gap(height=2)``. If you call ``air_gap`` with a single,
975
+ unnamed argument, it will always be interpreted as a volume.
976
+
977
+ .. note::
978
+
979
+ In API version 2.21 and earlier, this function was implemented as an aspirate, and
980
+ dispensing into a well would add the air gap volume to the liquid tracked in
981
+ the well. In API version 2.22 and later, air gap volume is not tracked as liquid
982
+ when dispensing into a well.
983
+
984
+ .. versionchanged:: 2.22
985
+ No longer implemented as an aspirate.
986
+ .. versionchanged:: 2.24
987
+ Added the ``in_place`` option.
988
+ .. versionchanged:: 2.24
989
+ Adds the ``rate`` and ``flow_rate`` parameter. You can only define one or the other. If
990
+ both are unspecified then ``rate`` is by default set to 1.0.
991
+ Can air gap over a trash bin or waste chute.
992
+ """
993
+ if not self._core.has_tip():
994
+ raise UnexpectedTipRemovalError("air_gap", self.name, self.mount)
995
+
996
+ if rate is not None and self.api_version < APIVersion(2, 24):
997
+ raise APIVersionError(
998
+ api_element="rate",
999
+ until_version="2.24",
1000
+ current_version=f"{self._api_version}",
1001
+ )
1002
+
1003
+ if flow_rate is not None and self.api_version < APIVersion(2, 24):
1004
+ raise APIVersionError(
1005
+ api_element="flow_rate",
1006
+ until_version="2.24",
1007
+ current_version=f"{self._api_version}",
1008
+ )
1009
+
1010
+ if flow_rate is not None and rate is not None:
1011
+ raise ValueError("Cannot define both flow_rate and rate.")
1012
+
1013
+ if in_place:
1014
+ if self.api_version < APIVersion(2, 24):
1015
+ raise APIVersionError(
1016
+ api_element="in_place",
1017
+ until_version="2.24",
1018
+ current_version=f"{self._api_version}",
1019
+ )
1020
+ if height is not None:
1021
+ raise ValueError("height must be unset if air gapping in_place")
1022
+ else:
1023
+ if height is None:
1024
+ height = 5
1025
+ last_location = self._protocol_core.get_last_location()
1026
+ if self.api_version < APIVersion(2, 24) and isinstance(
1027
+ last_location, (TrashBin, WasteChute)
1028
+ ):
1029
+ last_location = None
1030
+ if last_location is None or (
1031
+ isinstance(last_location, types.Location)
1032
+ and not last_location.labware.is_well
1033
+ ):
1034
+ raise RuntimeError(
1035
+ f"Cached location of {last_location} is not valid for air gap."
1036
+ )
1037
+ target: Union[types.Location, TrashBin, WasteChute]
1038
+ if isinstance(last_location, types.Location):
1039
+ target = last_location.labware.as_well().top(height)
1040
+ else:
1041
+ target = last_location.top(height)
1042
+ self.move_to(target, publish=False)
1043
+
1044
+ if self.api_version >= _AIR_GAP_TRACKING_ADDED_IN:
1045
+ self._core.prepare_to_aspirate()
1046
+ c_vol = self._core.get_available_volume() if volume is None else volume
1047
+ if flow_rate is not None:
1048
+ calculated_rate = flow_rate
1049
+ elif rate is not None:
1050
+ calculated_rate = rate * self._core.get_aspirate_flow_rate()
1051
+ else:
1052
+ calculated_rate = self._core.get_aspirate_flow_rate()
1053
+
1054
+ self._core.air_gap_in_place(c_vol, calculated_rate)
1055
+ else:
1056
+ self.aspirate(volume)
1057
+ return self
1058
+
1059
+ @publisher.publish(command=cmds.return_tip)
1060
+ @requires_version(2, 0)
1061
+ def return_tip(self, home_after: Optional[bool] = None) -> InstrumentContext:
1062
+ """
1063
+ Drop the currently attached tip in its original location in the tip rack.
1064
+
1065
+ Returning a tip does not reset tip tracking, so :py:obj:`.Well.has_tip` will
1066
+ remain ``False`` for the destination.
1067
+
1068
+ :returns: This instance.
1069
+
1070
+ :param home_after: See the ``home_after`` parameter of :py:meth:`drop_tip`.
1071
+ """
1072
+ if not self._core.has_tip():
1073
+ _log.warning("Pipette has no tip to return")
1074
+
1075
+ loc = self._get_current_tip_source_well()
1076
+
1077
+ # TODO rewrite this error message
1078
+ if not isinstance(loc, labware.Well):
1079
+ raise TypeError(f"Last tip location should be a Well but it is: {loc}")
1080
+
1081
+ self.drop_tip(loc, home_after=home_after)
1082
+
1083
+ return self
1084
+
1085
+ @requires_version(2, 0)
1086
+ def pick_up_tip( # noqa: C901
1087
+ self,
1088
+ location: Union[types.Location, labware.Well, labware.Labware, None] = None,
1089
+ presses: Optional[int] = None,
1090
+ increment: Optional[float] = None,
1091
+ prep_after: Optional[bool] = None,
1092
+ ) -> InstrumentContext:
1093
+ """
1094
+ Pick up a tip for the pipette to run liquid-handling commands.
1095
+
1096
+ See :ref:`basic-tip-pickup`.
1097
+
1098
+ If no location is passed, the pipette will pick up the next available tip in its
1099
+ :py:attr:`~.InstrumentContext.tip_racks` list. Within each tip rack, tips will
1100
+ be picked up in the order specified by the labware definition and
1101
+ :py:meth:`.Labware.wells`. To adjust where the sequence starts, use
1102
+ :py:obj:`.starting_tip`.
1103
+
1104
+ The exact position for tip pickup accounts for the length of the tip and how
1105
+ much the tip overlaps with the pipette nozzle. These measurements are fixed
1106
+ values on Flex, and are based on the results of tip length calibration on OT-2.
1107
+
1108
+ .. note::
1109
+ API version 2.19 updates the tip overlap values for Flex. When updating a
1110
+ protocol from 2.18 (or lower) to 2.19 (or higher), pipette performance
1111
+ should improve without additional changes to your protocol. Nevertheless, it
1112
+ is good practice after updating to do the following:
1113
+
1114
+ - Run Labware Position Check.
1115
+ - Perform a dry run of your protocol.
1116
+ - If tip position is slightly higher than expected, adjust the ``location``
1117
+ parameter of pipetting actions to achieve the desired result.
1118
+
1119
+ :param location: The location from which to pick up a tip. The ``location``
1120
+ argument can be specified in several ways:
1121
+
1122
+ * As a :py:class:`.Well`. For example,
1123
+ ``pipette.pick_up_tip(tiprack.wells()[0])`` will always pick
1124
+ up the first tip in ``tiprack``, even if the rack is not a
1125
+ member of :py:obj:`.InstrumentContext.tip_racks`.
1126
+
1127
+ * As a labware. ``pipette.pick_up_tip(tiprack)`` will pick up
1128
+ the next available tip in ``tiprack``, even if the rack is
1129
+ not a member of :py:obj:`.InstrumentContext.tip_racks`.
1130
+
1131
+ * As a :py:class:`~.types.Location`. Use this to make fine
1132
+ adjustments to the pickup location. For example, to tell
1133
+ the robot to start its pick up tip routine 1 mm closer to
1134
+ the top of the well in the tip rack, call
1135
+ ``pipette.pick_up_tip(tiprack["A1"].top(z=-1))``.
1136
+ :type location: :py:class:`.Well` or :py:class:`.Labware` or :py:class:`.types.Location`
1137
+ :param presses: The number of times to lower and then raise the pipette when
1138
+ picking up a tip, to ensure a good seal. Zero (``0``) will
1139
+ result in the pipette hovering over the tip but not picking it
1140
+ up (generally not desirable, but could be used for a dry run).
1141
+
1142
+ .. deprecated:: 2.14
1143
+ Use the Opentrons App to change pipette pick-up settings.
1144
+ :type presses: int
1145
+ :param increment: The additional distance to travel on each successive press.
1146
+ For example, if ``presses=3`` and ``increment=1.0``, then the
1147
+ first press will travel down into the tip by 3.5 mm, the
1148
+ second by 4.5 mm, and the third by 5.5 mm).
1149
+
1150
+ .. deprecated:: 2.14
1151
+ Use the Opentrons App to change pipette pick-up settings.
1152
+ :type increment: float
1153
+ :param prep_after: Whether the pipette plunger should prepare itself to aspirate
1154
+ immediately after picking up a tip.
1155
+
1156
+ If ``True``, the pipette will move its plunger position to
1157
+ bottom in preparation for any following calls to
1158
+ :py:meth:`.aspirate`.
1159
+
1160
+ If ``False``, the pipette will prepare its plunger later,
1161
+ during the next call to :py:meth:`.aspirate`. This is
1162
+ accomplished by moving the tip to the top of the well, and
1163
+ positioning the plunger outside any potential liquids.
1164
+
1165
+ .. warning::
1166
+ This is provided for compatibility with older Python
1167
+ Protocol API behavior. You should normally leave this
1168
+ unset.
1169
+
1170
+ Setting ``prep_after=False`` may create an unintended
1171
+ pipette movement, when the pipette automatically moves
1172
+ the tip to the top of the well to prepare the plunger.
1173
+ :type prep_after: bool
1174
+
1175
+ .. versionchanged:: 2.13
1176
+ Adds the ``prep_after`` argument. In version 2.12 and earlier, the plunger
1177
+ can't prepare itself for aspiration during :py:meth:`.pick_up_tip`, and will
1178
+ instead always prepare during :py:meth:`.aspirate`. Version 2.12 and earlier
1179
+ will raise an ``APIVersionError`` if a value is set for ``prep_after``.
1180
+
1181
+ .. versionchanged:: 2.19
1182
+ Uses new values for how much a tip overlaps with the pipette nozzle.
1183
+
1184
+ :returns: This instance.
1185
+ """
1186
+
1187
+ if presses is not None and self._api_version >= _PRESSES_INCREMENT_REMOVED_IN:
1188
+ raise UnsupportedAPIError(
1189
+ api_element="presses",
1190
+ since_version=f"{_PRESSES_INCREMENT_REMOVED_IN}",
1191
+ current_version=f"{self._api_version}",
1192
+ )
1193
+
1194
+ if increment is not None and self._api_version >= _PRESSES_INCREMENT_REMOVED_IN:
1195
+ raise UnsupportedAPIError(
1196
+ api_element="increment",
1197
+ since_version=f"{_PRESSES_INCREMENT_REMOVED_IN}",
1198
+ current_version=f"{self._api_version}",
1199
+ )
1200
+
1201
+ if prep_after is not None and self._api_version < _PREP_AFTER_ADDED_IN:
1202
+ raise APIVersionError(
1203
+ api_element="prep_after",
1204
+ until_version=f"{_PREP_AFTER_ADDED_IN}",
1205
+ current_version=f"{self._api_version}",
1206
+ )
1207
+
1208
+ well: labware.Well
1209
+ tip_rack: labware.Labware
1210
+ move_to_location: Optional[types.Location] = None
1211
+ active_channels = (
1212
+ self.active_channels
1213
+ if self._api_version >= _PARTIAL_NOZZLE_CONFIGURATION_ADDED_IN
1214
+ else self.channels
1215
+ )
1216
+ nozzle_map = (
1217
+ self._core.get_nozzle_map()
1218
+ if self._api_version
1219
+ >= _PARTIAL_NOZZLE_CONFIGURATION_AUTOMATIC_TIP_TRACKING_IN
1220
+ else None
1221
+ )
1222
+
1223
+ if location is None:
1224
+ if (
1225
+ nozzle_map is not None
1226
+ and nozzle_map.configuration != types.NozzleConfigurationType.FULL
1227
+ and self.starting_tip is not None
1228
+ ):
1229
+ # Disallowing this avoids concerning the system with the direction
1230
+ # in which self.starting_tip consumes tips. It would currently vary
1231
+ # depending on the configuration layout of a pipette at a given
1232
+ # time, which means that some combination of starting tip and partial
1233
+ # configuration are incompatible under the current understanding of
1234
+ # starting tip behavior. Replacing starting_tip with an un-deprecated
1235
+ # Labware.has_tip may solve this.
1236
+ raise CommandPreconditionViolated(
1237
+ "Automatic tip tracking is not available when using a partial pipette"
1238
+ " nozzle configuration and InstrumentContext.starting_tip."
1239
+ " Switch to a full configuration or set starting_tip to None."
1240
+ )
1241
+ if not self._core.is_tip_tracking_available():
1242
+ raise CommandPreconditionViolated(
1243
+ "Automatic tip tracking is not available for the current pipette"
1244
+ " nozzle configuration. We suggest switching to a configuration"
1245
+ " that supports automatic tip tracking or specifying the exact tip"
1246
+ " to pick up."
1247
+ )
1248
+ tip_rack, well = labware.next_available_tip(
1249
+ starting_tip=self.starting_tip,
1250
+ tip_racks=self.tip_racks,
1251
+ channels=active_channels,
1252
+ nozzle_map=nozzle_map,
1253
+ )
1254
+
1255
+ elif isinstance(location, labware.Well):
1256
+ well = location
1257
+ tip_rack = well.parent
1258
+
1259
+ elif isinstance(location, labware.Labware):
1260
+ tip_rack, well = labware.next_available_tip(
1261
+ starting_tip=None,
1262
+ tip_racks=[location],
1263
+ channels=active_channels,
1264
+ nozzle_map=nozzle_map,
1265
+ )
1266
+
1267
+ elif isinstance(location, types.Location):
1268
+ maybe_tip_rack, maybe_well = location.labware.get_parent_labware_and_well()
1269
+
1270
+ if maybe_well is not None:
1271
+ well = maybe_well
1272
+ tip_rack = well.parent
1273
+ move_to_location = location
1274
+
1275
+ elif maybe_tip_rack is not None:
1276
+ tip_rack, well = labware.next_available_tip(
1277
+ starting_tip=None,
1278
+ tip_racks=[maybe_tip_rack],
1279
+ channels=active_channels,
1280
+ nozzle_map=nozzle_map,
1281
+ )
1282
+ else:
1283
+ raise TypeError(
1284
+ "If specified as a `types.Location`,"
1285
+ " `location` should refer to a ``Labware` or `Well` location."
1286
+ f" However, it refers to {location.labware}"
1287
+ )
1288
+
1289
+ else:
1290
+ raise TypeError(
1291
+ "If specified, location should be an instance of"
1292
+ " `types.Location` (e.g. the return value from `Well.top()`),"
1293
+ " `Labware` or `Well` (e.g. `tiprack.wells()[0]`)."
1294
+ f" However, it is {location}"
1295
+ )
1296
+
1297
+ instrument.validate_tiprack(self.name, tip_rack, _log)
1298
+
1299
+ move_to_location = move_to_location or well.top()
1300
+ prep_after = (
1301
+ prep_after
1302
+ if prep_after is not None
1303
+ else self.api_version >= _PREP_AFTER_ADDED_IN
1304
+ )
1305
+
1306
+ with publisher.publish_context(
1307
+ broker=self.broker,
1308
+ command=cmds.pick_up_tip(instrument=self, location=well),
1309
+ ):
1310
+ self._core.pick_up_tip(
1311
+ location=move_to_location,
1312
+ well_core=well._core,
1313
+ presses=presses,
1314
+ increment=increment,
1315
+ prep_after=prep_after,
1316
+ )
1317
+
1318
+ return self
1319
+
1320
+ @requires_version(2, 0)
1321
+ def drop_tip(
1322
+ self,
1323
+ location: Optional[
1324
+ Union[
1325
+ types.Location,
1326
+ labware.Well,
1327
+ TrashBin,
1328
+ WasteChute,
1329
+ ]
1330
+ ] = None,
1331
+ home_after: Optional[bool] = None,
1332
+ ) -> InstrumentContext:
1333
+ """
1334
+ Drop the current tip.
1335
+
1336
+ See :ref:`pipette-drop-tip` for examples.
1337
+
1338
+ If no location is passed (e.g. ``pipette.drop_tip()``), the pipette will drop
1339
+ the attached tip into its :py:attr:`trash_container`.
1340
+
1341
+ The location in which to drop the tip can be manually specified with the
1342
+ ``location`` argument. The ``location`` argument can be specified in several
1343
+ ways:
1344
+
1345
+ - As a :py:class:`.Well`. This uses a default location relative to the well.
1346
+ This style of call can be used to make the robot drop a tip into labware
1347
+ like a well plate or a reservoir. For example,
1348
+ ``pipette.drop_tip(location=reservoir["A1"])``.
1349
+ - As a :py:class:`~.types.Location`. For example, to drop a tip from an
1350
+ unusually large height above the tip rack, you could call
1351
+ ``pipette.drop_tip(tip_rack["A1"].top(z=10))``.
1352
+ - As a :py:class:`.TrashBin`. This uses a default location relative to the
1353
+ ``TrashBin`` object. For example,
1354
+ ``pipette.drop_tip(location=trash_bin)``.
1355
+ - As a :py:class:`.WasteChute`. This uses a default location relative to
1356
+ the ``WasteChute`` object. For example,
1357
+ ``pipette.drop_tip(location=waste_chute)``.
1358
+
1359
+ In API versions 2.15 to 2.17, if ``location`` is a ``TrashBin`` or not
1360
+ specified, the API will instruct the pipette to drop tips in different locations
1361
+ within the bin. Varying the tip drop location helps prevent tips
1362
+ from piling up in a single location.
1363
+
1364
+ Starting with API version 2.18, the API will only vary the tip drop location if
1365
+ ``location`` is not specified. Specifying a ``TrashBin`` as the ``location``
1366
+ behaves the same as specifying :py:meth:`.TrashBin.top`, which is a fixed position.
1367
+
1368
+ :param location:
1369
+ Where to drop the tip.
1370
+
1371
+ .. versionchanged:: 2.16
1372
+ Accepts ``TrashBin`` and ``WasteChute`` values.
1373
+
1374
+ :type location:
1375
+ :py:class:`~.types.Location` or :py:class:`.Well` or ``None``
1376
+ :param home_after:
1377
+ Whether to home the pipette's plunger after dropping the tip. If not
1378
+ specified, defaults to ``True`` on an OT-2.
1379
+
1380
+ When ``False``, the pipette does not home its plunger. This can save a few
1381
+ seconds, but is not recommended. Homing helps the robot track the pipette's
1382
+ position.
1383
+
1384
+ :returns: This instance.
1385
+ """
1386
+ alternate_drop_location: bool = False
1387
+ if location is None:
1388
+ trash_container = self.trash_container
1389
+ if self.api_version >= _DROP_TIP_LOCATION_ALTERNATING_ADDED_IN:
1390
+ alternate_drop_location = True
1391
+ if isinstance(trash_container, labware.Labware):
1392
+ well = trash_container.wells()[0]
1393
+ else: # implicit drop tip in disposal location, not well
1394
+ with publisher.publish_context(
1395
+ broker=self.broker,
1396
+ command=cmds.drop_tip_in_disposal_location(
1397
+ instrument=self, location=trash_container
1398
+ ),
1399
+ ):
1400
+ self._core.drop_tip_in_disposal_location(
1401
+ trash_container,
1402
+ home_after=home_after,
1403
+ alternate_tip_drop=True,
1404
+ )
1405
+ return self
1406
+
1407
+ elif isinstance(location, labware.Well):
1408
+ well = location
1409
+ location = None
1410
+
1411
+ elif isinstance(location, types.Location):
1412
+ _, maybe_well = location.labware.get_parent_labware_and_well()
1413
+
1414
+ if maybe_well is None:
1415
+ raise TypeError(
1416
+ "If a location is specified as a `types.Location`"
1417
+ " (for instance, as the result of a call to `Well.top()`),"
1418
+ " it must be a location relative to a well,"
1419
+ " since that is where a tip is dropped."
1420
+ f" However, the given location refers to {location.labware}"
1421
+ )
1422
+
1423
+ well = maybe_well
1424
+
1425
+ elif isinstance(location, (TrashBin, WasteChute)):
1426
+ # In 2.16 and 2.17, we would always automatically use automatic alternate tip drop locations regardless
1427
+ # of whether you explicitly passed the disposal location as a location or if none was provided. Now, in
1428
+ # 2.18 and moving forward, passing it in will bypass the automatic behavior and instead go to the set
1429
+ # offset or the XY center if none is provided.
1430
+ if self.api_version < _DISPOSAL_LOCATION_OFFSET_ADDED_IN:
1431
+ alternate_drop_location = True
1432
+ with publisher.publish_context(
1433
+ broker=self.broker,
1434
+ command=cmds.drop_tip_in_disposal_location(
1435
+ instrument=self, location=location
1436
+ ),
1437
+ ):
1438
+ self._core.drop_tip_in_disposal_location(
1439
+ location,
1440
+ home_after=home_after,
1441
+ alternate_tip_drop=alternate_drop_location,
1442
+ )
1443
+ return self
1444
+
1445
+ else:
1446
+ raise TypeError(
1447
+ "If specified, location should be an instance of"
1448
+ " `types.Location` (e.g. the return value from `Well.top()`)"
1449
+ " or `Well` (e.g. `tiprack.wells()[0]`)."
1450
+ f" However, it is {location}"
1451
+ )
1452
+
1453
+ with publisher.publish_context(
1454
+ broker=self.broker,
1455
+ command=cmds.drop_tip(instrument=self, location=well),
1456
+ ):
1457
+ self._core.drop_tip(
1458
+ location=location,
1459
+ well_core=well._core,
1460
+ home_after=home_after,
1461
+ alternate_drop_location=alternate_drop_location,
1462
+ )
1463
+
1464
+ return self
1465
+
1466
+ @requires_version(2, 0)
1467
+ def home(self) -> InstrumentContext:
1468
+ """Home the robot.
1469
+
1470
+ See :ref:`utility-homing`.
1471
+
1472
+ :returns: This instance.
1473
+ """
1474
+
1475
+ mount_name = self._core.get_mount().name.lower()
1476
+
1477
+ with publisher.publish_context(
1478
+ broker=self.broker, command=cmds.home(mount_name)
1479
+ ):
1480
+ self._core.home()
1481
+
1482
+ return self
1483
+
1484
+ @requires_version(2, 0)
1485
+ def home_plunger(self) -> InstrumentContext:
1486
+ """Home the plunger associated with this mount.
1487
+
1488
+ :returns: This instance.
1489
+ """
1490
+ self._core.home_plunger()
1491
+ return self
1492
+
1493
+ @publisher.publish(command=cmds.distribute)
1494
+ @requires_version(2, 0)
1495
+ def distribute(
1496
+ self,
1497
+ volume: Union[float, Sequence[float]],
1498
+ source: labware.Well,
1499
+ dest: List[labware.Well],
1500
+ *args: Any,
1501
+ **kwargs: Any,
1502
+ ) -> InstrumentContext:
1503
+ """
1504
+ Move a volume of liquid from one source to multiple destinations.
1505
+
1506
+ :param volume: The amount, in µL, to dispense into each destination well.
1507
+ :param source: A single well to aspirate liquid from.
1508
+ :param dest: A list of wells to dispense liquid into.
1509
+ :param kwargs: See :py:meth:`transfer` and the :ref:`complex_params` page.
1510
+ Some parameters behave differently than when transferring.
1511
+
1512
+ - ``disposal_volume`` aspirates additional liquid to improve the accuracy
1513
+ of each dispense. Defaults to the minimum volume of the pipette. See
1514
+ :ref:`param-disposal-volume` for details.
1515
+
1516
+ - ``mix_after`` is ignored.
1517
+
1518
+
1519
+ :returns: This instance.
1520
+ """
1521
+ _log.debug("Distributing {} from {} to {}".format(volume, source, dest))
1522
+ kwargs["mode"] = "distribute"
1523
+ kwargs["disposal_volume"] = kwargs.get("disposal_volume", self.min_volume)
1524
+ kwargs["mix_after"] = (0, 0)
1525
+ blowout_location = kwargs.get("blowout_location")
1526
+ instrument.validate_blowout_location(
1527
+ self.api_version, "distribute", blowout_location
1528
+ )
1529
+
1530
+ return self.transfer(volume, source, dest, **kwargs)
1531
+
1532
+ @publisher.publish(command=cmds.consolidate)
1533
+ @requires_version(2, 0)
1534
+ def consolidate(
1535
+ self,
1536
+ volume: Union[float, Sequence[float]],
1537
+ source: List[labware.Well],
1538
+ dest: labware.Well,
1539
+ *args: Any,
1540
+ **kwargs: Any,
1541
+ ) -> InstrumentContext:
1542
+ """
1543
+ Move liquid from multiple source wells to a single destination well.
1544
+
1545
+ :param volume: The amount, in µL, to aspirate from each source well.
1546
+ :param source: A list of wells to aspirate liquid from.
1547
+ :param dest: A single well to dispense liquid into.
1548
+ :param kwargs: See :py:meth:`transfer` and the :ref:`complex_params` page.
1549
+ Some parameters behave differently than when transferring.
1550
+ ``disposal_volume`` and ``mix_before`` are ignored.
1551
+ :returns: This instance.
1552
+ """
1553
+ _log.debug("Consolidate {} from {} to {}".format(volume, source, dest))
1554
+ kwargs["mode"] = "consolidate"
1555
+ kwargs["mix_before"] = (0, 0)
1556
+ kwargs["disposal_volume"] = 0
1557
+ blowout_location = kwargs.get("blowout_location")
1558
+ instrument.validate_blowout_location(
1559
+ self.api_version, "consolidate", blowout_location
1560
+ )
1561
+
1562
+ return self.transfer(volume, source, dest, **kwargs)
1563
+
1564
+ @publisher.publish(command=cmds.transfer)
1565
+ @requires_version(2, 0)
1566
+ def transfer( # noqa: C901
1567
+ self,
1568
+ volume: Union[float, Sequence[float]],
1569
+ source: AdvancedLiquidHandling,
1570
+ dest: AdvancedLiquidHandling,
1571
+ trash: bool = True,
1572
+ **kwargs: Any,
1573
+ ) -> InstrumentContext:
1574
+ # source: Union[Well, List[Well], List[List[Well]]],
1575
+ # dest: Union[Well, List[Well], List[List[Well]]],
1576
+ # TODO: Reach consensus on kwargs
1577
+ # TODO: Decide if to use a disposal_volume
1578
+ # TODO: Accordingly decide if remaining liquid should be blown out to
1579
+ # TODO: ..trash or the original well.
1580
+ # TODO: What should happen if the user passes a non-first-row well
1581
+ # TODO: ..as src/dest *while using multichannel pipette?
1582
+ """
1583
+ Move liquid from one well or group of wells to another.
1584
+
1585
+ Transfer is a higher-level command, incorporating other
1586
+ :py:class:`InstrumentContext` commands, like :py:meth:`aspirate` and
1587
+ :py:meth:`dispense`. It makes writing a protocol easier at the cost of
1588
+ specificity. See :ref:`v2-complex-commands` for details on how transfer and
1589
+ other complex commands perform their component steps.
1590
+
1591
+ :param volume: The amount, in µL, to aspirate from each source and dispense to
1592
+ each destination. If ``volume`` is a list, each amount will be
1593
+ used for the source and destination at the matching index. A list
1594
+ item of ``0`` will skip the corresponding wells entirely. See
1595
+ :ref:`complex-list-volumes` for details and examples.
1596
+ :param source: A single well or a list of wells to aspirate liquid from.
1597
+ :param dest: A single well or a list of wells to dispense liquid into.
1598
+
1599
+ :Keyword Arguments: Transfer accepts a number of optional parameters that give
1600
+ you greater control over the exact steps it performs. See
1601
+ :ref:`complex_params` or the links under each argument's entry below for
1602
+ additional details and examples.
1603
+
1604
+ * **new_tip** (*string*) --
1605
+ When to pick up and drop tips during the command. Defaults to ``"once"``.
1606
+
1607
+ - ``"once"``: Use one tip for the entire command.
1608
+ - ``"always"``: Use a new tip for each set of aspirate and dispense steps.
1609
+ - ``"never"``: Do not pick up or drop tips at all.
1610
+
1611
+ See :ref:`param-tip-handling` for details.
1612
+
1613
+ * **trash** (*boolean*) --
1614
+ If ``True`` (default), the pipette will drop tips in its
1615
+ :py:meth:`~.InstrumentContext.trash_container`.
1616
+ If ``False``, the pipette will return tips to their tip rack.
1617
+
1618
+ See :ref:`param-trash` for details.
1619
+
1620
+ * **touch_tip** (*boolean*) --
1621
+ If ``True``, perform a :py:meth:`touch_tip` following each
1622
+ :py:meth:`aspirate` and :py:meth:`dispense`. Defaults to ``False``.
1623
+
1624
+ See :ref:`param-touch-tip` for details.
1625
+
1626
+ * **blow_out** (*boolean*) --
1627
+ If ``True``, a :py:meth:`blow_out` will occur following each
1628
+ :py:meth:`dispense`, but only if the pipette has no liquid left
1629
+ in it. If ``False`` (default), the pipette will not blow out liquid.
1630
+
1631
+ See :ref:`param-blow-out` for details.
1632
+
1633
+ * **blowout_location** (*string*) --
1634
+ Accepts one of three string values: ``"trash"``, ``"source well"``, or
1635
+ ``"destination well"``.
1636
+
1637
+ If ``blow_out`` is ``False`` (its default), this parameter is ignored.
1638
+
1639
+ If ``blow_out`` is ``True`` and this parameter is not set:
1640
+
1641
+ - Blow out into the trash, if the pipette is empty or only contains the
1642
+ disposal volume.
1643
+
1644
+ - Blow out into the source well, if the pipette otherwise contains liquid.
1645
+
1646
+ * **mix_before** (*tuple*) --
1647
+ Perform a :py:meth:`mix` before each :py:meth:`aspirate` during the
1648
+ transfer. The first value of the tuple is the number of repetitions, and
1649
+ the second value is the amount of liquid to mix in µL.
1650
+
1651
+ See :ref:`param-mix-before` for details.
1652
+
1653
+ * **mix_after** (*tuple*) --
1654
+ Perform a :py:meth:`mix` after each :py:meth:`dispense` during the
1655
+ transfer. The first value of the tuple is the number of repetitions, and
1656
+ the second value is the amount of liquid to mix in µL.
1657
+
1658
+ See :ref:`param-mix-after` for details.
1659
+
1660
+ * **disposal_volume** (*float*) --
1661
+ Transfer ignores the numeric value of this parameter. If set, the pipette
1662
+ will not aspirate additional liquid, but it will perform a very small blow
1663
+ out after each dispense.
1664
+
1665
+ See :ref:`param-disposal-volume` for details.
1666
+
1667
+ :returns: This instance.
1668
+ """
1669
+ _log.debug("Transfer {} from {} to {}".format(volume, source, dest))
1670
+
1671
+ blowout_location = kwargs.get("blowout_location")
1672
+ instrument.validate_blowout_location(
1673
+ self.api_version, "transfer", blowout_location
1674
+ )
1675
+
1676
+ kwargs["mode"] = kwargs.get("mode", "transfer")
1677
+
1678
+ mix_strategy, mix_opts = mix_from_kwargs(kwargs)
1679
+
1680
+ if trash:
1681
+ drop_tip = v1_transfer.DropTipStrategy.TRASH
1682
+ else:
1683
+ drop_tip = v1_transfer.DropTipStrategy.RETURN
1684
+
1685
+ new_tip = kwargs.get("new_tip")
1686
+ if isinstance(new_tip, str):
1687
+ new_tip = types.TransferTipPolicy[new_tip.upper()]
1688
+
1689
+ blow_out = kwargs.get("blow_out")
1690
+ blow_out_strategy = None
1691
+ active_channels = (
1692
+ self.active_channels
1693
+ if self._api_version >= _PARTIAL_NOZZLE_CONFIGURATION_ADDED_IN
1694
+ else self.channels
1695
+ )
1696
+ nozzle_map = (
1697
+ self._core.get_nozzle_map()
1698
+ if self._api_version
1699
+ >= _PARTIAL_NOZZLE_CONFIGURATION_AUTOMATIC_TIP_TRACKING_IN
1700
+ else None
1701
+ )
1702
+
1703
+ if blow_out and not blowout_location:
1704
+ if self.current_volume:
1705
+ blow_out_strategy = v1_transfer.BlowOutStrategy.SOURCE
1706
+ else:
1707
+ blow_out_strategy = v1_transfer.BlowOutStrategy.TRASH
1708
+ elif blow_out and blowout_location:
1709
+ if blowout_location == "source well":
1710
+ blow_out_strategy = v1_transfer.BlowOutStrategy.SOURCE
1711
+ elif blowout_location == "destination well":
1712
+ blow_out_strategy = v1_transfer.BlowOutStrategy.DEST
1713
+ elif blowout_location == "trash":
1714
+ blow_out_strategy = v1_transfer.BlowOutStrategy.TRASH
1715
+
1716
+ if new_tip != types.TransferTipPolicy.NEVER:
1717
+ _, next_tip = labware.next_available_tip(
1718
+ self.starting_tip,
1719
+ self.tip_racks,
1720
+ active_channels,
1721
+ nozzle_map=nozzle_map,
1722
+ )
1723
+ max_volume = min(next_tip.max_volume, self.max_volume)
1724
+ else:
1725
+ max_volume = self._core.get_working_volume()
1726
+
1727
+ touch_tip = None
1728
+ if kwargs.get("touch_tip"):
1729
+ touch_tip = v1_transfer.TouchTipStrategy.ALWAYS
1730
+
1731
+ default_args = v1_transfer.Transfer()
1732
+
1733
+ disposal = kwargs.get("disposal_volume")
1734
+ if disposal is None:
1735
+ disposal = default_args.disposal_volume
1736
+
1737
+ air_gap = kwargs.get("air_gap", default_args.air_gap)
1738
+ if air_gap < 0 or air_gap >= max_volume:
1739
+ raise ValueError(
1740
+ "air_gap must be between 0uL and the pipette's expected "
1741
+ f"working volume, {max_volume}uL"
1742
+ )
1743
+
1744
+ transfer_args = v1_transfer.Transfer(
1745
+ new_tip=new_tip or default_args.new_tip,
1746
+ air_gap=air_gap,
1747
+ carryover=kwargs.get("carryover") or default_args.carryover,
1748
+ gradient_function=(
1749
+ kwargs.get("gradient_function") or default_args.gradient_function
1750
+ ),
1751
+ disposal_volume=disposal,
1752
+ mix_strategy=mix_strategy,
1753
+ drop_tip_strategy=drop_tip,
1754
+ blow_out_strategy=blow_out_strategy or default_args.blow_out_strategy,
1755
+ touch_tip_strategy=(touch_tip or default_args.touch_tip_strategy),
1756
+ )
1757
+ transfer_options = v1_transfer.TransferOptions(
1758
+ transfer=transfer_args, mix=mix_opts
1759
+ )
1760
+ plan = v1_transfer.TransferPlan(
1761
+ volume,
1762
+ source,
1763
+ dest,
1764
+ self,
1765
+ max_volume,
1766
+ self.api_version,
1767
+ kwargs["mode"],
1768
+ transfer_options,
1769
+ )
1770
+ self._execute_transfer(plan)
1771
+ return self
1772
+
1773
+ def _execute_transfer(self, plan: v1_transfer.TransferPlan) -> None:
1774
+ for cmd in plan:
1775
+ getattr(self, cmd["method"])(*cmd["args"], **cmd["kwargs"])
1776
+
1777
+ @requires_version(2, 24)
1778
+ def transfer_with_liquid_class(
1779
+ self,
1780
+ liquid_class: LiquidClass,
1781
+ volume: float,
1782
+ source: Union[
1783
+ labware.Well, Sequence[labware.Well], Sequence[Sequence[labware.Well]]
1784
+ ],
1785
+ dest: Union[
1786
+ labware.Well,
1787
+ Sequence[labware.Well],
1788
+ Sequence[Sequence[labware.Well]],
1789
+ TrashBin,
1790
+ WasteChute,
1791
+ ],
1792
+ new_tip: TransferTipPolicyV2Type = "once",
1793
+ trash_location: Optional[
1794
+ Union[types.Location, labware.Well, TrashBin, WasteChute]
1795
+ ] = None,
1796
+ return_tip: bool = False,
1797
+ group_wells: bool = True,
1798
+ keep_last_tip: Optional[bool] = None,
1799
+ ) -> InstrumentContext:
1800
+ """Move a particular type of liquid from one well or group of wells to another.
1801
+
1802
+ :param liquid_class: The type of liquid to move. You must specify the liquid class,
1803
+ even if you have used :py:meth:`.Labware.load_liquid` to indicate what liquid the
1804
+ source contains.
1805
+ :type liquid_class: :py:class:`.LiquidClass`
1806
+
1807
+ :param volume: The amount, in µL, to aspirate from each source and dispense to
1808
+ each destination.
1809
+ :param source: A single well or a list of wells to aspirate liquid from.
1810
+ :param dest: A single well, list of wells, trash bin, or waste chute to dispense liquid into.
1811
+ :param new_tip: When to pick up and drop tips during the command.
1812
+ Defaults to ``"once"``.
1813
+
1814
+ - ``"once"``: Use one tip for the entire command.
1815
+ - ``"always"``: Use a new tip for each set of aspirate and dispense steps.
1816
+ - ``"per source"``: Use one tip for each source well, even if
1817
+ :ref:`tip refilling <complex-tip-refilling>` is required.
1818
+ - ``"per destination"``: Use one tip for each destination well, even if
1819
+ :ref:`tip refilling <complex-tip-refilling>` is required.
1820
+ - ``"never"``: Do not pick up or drop tips at all.
1821
+
1822
+ See :ref:`param-tip-handling` for details.
1823
+
1824
+ :param trash_location: A trash container, well, or other location to dispose of
1825
+ tips. Depending on the liquid class, the pipette may also blow out liquid here.
1826
+ If not specified, the pipette will dispose of tips in its :py:obj:`~.InstrumentContext.trash_container`.
1827
+ :param return_tip: Whether to drop used tips in their original locations
1828
+ in the tip rack, instead of the trash.
1829
+ :param group_wells: For multi-channel transfers only. If set to ``True``, group together contiguous wells
1830
+ given into a single transfer step, taking into account the tip configuration. If ``False``, target
1831
+ each well given with the primary nozzle. Defaults to ``True``.
1832
+ :param keep_last_tip: When ``True``, the pipette keeps the last tip used in the transfer attached. When
1833
+ ``False``, the last tip will be dropped or returned. If not set, behavior depends on the value of
1834
+ ``new_tip``. ``new_tip="never"`` keeps the tip, and all other values of ``new_tip`` drop or return the tip.
1835
+
1836
+ """
1837
+ if volume == 0.0:
1838
+ _log.info(
1839
+ f"Transfer of {liquid_class.name} specified with a volume of 0uL."
1840
+ f" Skipping."
1841
+ )
1842
+ return self
1843
+
1844
+ transfer_args = verify_and_normalize_transfer_args(
1845
+ source=source,
1846
+ dest=dest,
1847
+ tip_policy=new_tip,
1848
+ last_tip_well=self._get_current_tip_source_well(),
1849
+ tip_racks=self._tip_racks,
1850
+ nozzle_map=self._core.get_nozzle_map(),
1851
+ group_wells_for_multi_channel=group_wells,
1852
+ current_volume=self.current_volume,
1853
+ trash_location=(
1854
+ trash_location if trash_location is not None else self.trash_container
1855
+ ),
1856
+ )
1857
+ verified_keep_last_tip = resolve_keep_last_tip(
1858
+ keep_last_tip, transfer_args.tip_policy
1859
+ )
1860
+
1861
+ verified_dest: Union[
1862
+ List[Tuple[types.Location, WellCore]], TrashBin, WasteChute
1863
+ ]
1864
+ if isinstance(transfer_args.dest, (TrashBin, WasteChute)):
1865
+ verified_dest = transfer_args.dest
1866
+ else:
1867
+ if len(transfer_args.source) != len(transfer_args.dest):
1868
+ raise ValueError(
1869
+ "Sources and destinations should be of the same length in order to perform a transfer."
1870
+ " To transfer liquid from one source to many destinations, use 'distribute_liquid',"
1871
+ " to transfer liquid to one destination from many sources, use 'consolidate_liquid'."
1872
+ )
1873
+ verified_dest = [
1874
+ (types.Location(types.Point(), labware=well), well._core)
1875
+ for well in transfer_args.dest
1876
+ ]
1877
+
1878
+ with publisher.publish_context(
1879
+ broker=self.broker,
1880
+ command=cmds.transfer_with_liquid_class(
1881
+ instrument=self,
1882
+ liquid_class=liquid_class,
1883
+ volume=volume,
1884
+ source=source,
1885
+ destination=dest,
1886
+ ),
1887
+ ):
1888
+ self._core.transfer_with_liquid_class(
1889
+ liquid_class=liquid_class,
1890
+ volume=volume,
1891
+ source=[
1892
+ (types.Location(types.Point(), labware=well), well._core)
1893
+ for well in transfer_args.source
1894
+ ],
1895
+ dest=verified_dest,
1896
+ new_tip=transfer_args.tip_policy,
1897
+ tip_racks=[
1898
+ (types.Location(types.Point(), labware=rack), rack._core)
1899
+ for rack in transfer_args.tip_racks
1900
+ ],
1901
+ starting_tip=(
1902
+ self.starting_tip._core if self.starting_tip is not None else None
1903
+ ),
1904
+ trash_location=transfer_args.trash_location,
1905
+ return_tip=return_tip,
1906
+ keep_last_tip=verified_keep_last_tip,
1907
+ )
1908
+
1909
+ return self
1910
+
1911
+ @requires_version(2, 24)
1912
+ def distribute_with_liquid_class(
1913
+ self,
1914
+ liquid_class: LiquidClass,
1915
+ volume: float,
1916
+ source: Union[labware.Well, Sequence[labware.Well]],
1917
+ dest: Union[
1918
+ labware.Well, Sequence[labware.Well], Sequence[Sequence[labware.Well]]
1919
+ ],
1920
+ new_tip: TransferTipPolicyV2Type = "once",
1921
+ trash_location: Optional[
1922
+ Union[types.Location, labware.Well, TrashBin, WasteChute]
1923
+ ] = None,
1924
+ return_tip: bool = False,
1925
+ group_wells: bool = True,
1926
+ keep_last_tip: Optional[bool] = None,
1927
+ ) -> InstrumentContext:
1928
+ """
1929
+ Distribute a particular type of liquid from one well to a group of wells.
1930
+
1931
+ :param liquid_class: The type of liquid to move. You must specify the liquid class,
1932
+ even if you have used :py:meth:`.Labware.load_liquid` to indicate what liquid the
1933
+ source contains.
1934
+ :type liquid_class: :py:class:`.LiquidClass`
1935
+
1936
+ :param volume: The amount, in µL, to dispense to each destination.
1937
+ :param source: A single well for the pipette to target, or a group of wells to
1938
+ target in a single aspirate for a multi-channel pipette.
1939
+ :param dest: A list of wells to dispense liquid into.
1940
+ :param new_tip: When to pick up and drop tips during the command.
1941
+ Defaults to ``"once"``.
1942
+
1943
+ - ``"once"``: Use one tip for the entire command.
1944
+ - ``"always"``: Use a new tip before each aspirate.
1945
+ - ``"never"``: Do not pick up or drop tips at all.
1946
+
1947
+ See :ref:`param-tip-handling` for details.
1948
+
1949
+ :param trash_location: A trash container, well, or other location to dispose of
1950
+ tips. Depending on the liquid class, the pipette may also blow out liquid here.
1951
+ If not specified, the pipette will dispose of tips in its :py:obj:`~.InstrumentContext.trash_container`.
1952
+ :param return_tip: Whether to drop used tips in their original locations
1953
+ in the tip rack, instead of the trash.
1954
+ :param group_wells: For multi-channel transfers only. If set to ``True``, group together contiguous wells
1955
+ given into a single transfer step, taking into account the tip configuration. If ``False``, target
1956
+ each well given with the primary nozzle. Defaults to ``True``.
1957
+ :param keep_last_tip: When ``True``, the pipette keeps the last tip used in the distribute attached. When
1958
+ ``False``, the last tip will be dropped or returned. If not set, behavior depends on the value of
1959
+ ``new_tip``. ``new_tip="never"`` keeps the tip, and all other values of ``new_tip`` drop or return the tip.
1960
+
1961
+ """
1962
+ if volume == 0.0:
1963
+ _log.info(
1964
+ f"Distribution of {liquid_class.name} specified with a volume of 0uL."
1965
+ f" Skipping."
1966
+ )
1967
+ return self
1968
+
1969
+ transfer_args = verify_and_normalize_transfer_args(
1970
+ source=source,
1971
+ dest=dest,
1972
+ tip_policy=new_tip,
1973
+ last_tip_well=self._get_current_tip_source_well(),
1974
+ tip_racks=self._tip_racks,
1975
+ nozzle_map=self._core.get_nozzle_map(),
1976
+ group_wells_for_multi_channel=group_wells,
1977
+ current_volume=self.current_volume,
1978
+ trash_location=(
1979
+ trash_location if trash_location is not None else self.trash_container
1980
+ ),
1981
+ )
1982
+ verified_keep_last_tip = resolve_keep_last_tip(
1983
+ keep_last_tip, transfer_args.tip_policy
1984
+ )
1985
+
1986
+ if isinstance(transfer_args.dest, (TrashBin, WasteChute)):
1987
+ raise ValueError(
1988
+ "distribute_with_liquid_class() does not support trash bin or waste chute"
1989
+ " as a destination."
1990
+ )
1991
+ if len(transfer_args.source) != 1:
1992
+ raise ValueError(
1993
+ f"Source should be a single well (or resolve to a single transfer for multi-channel) "
1994
+ f"but received {transfer_args.source}."
1995
+ )
1996
+ if transfer_args.tip_policy not in [
1997
+ TransferTipPolicyV2.ONCE,
1998
+ TransferTipPolicyV2.NEVER,
1999
+ TransferTipPolicyV2.ALWAYS,
2000
+ ]:
2001
+ raise ValueError(
2002
+ f"Incompatible `new_tip` value of {new_tip}."
2003
+ f" `distribute_with_liquid_class()` only supports `new_tip` values of"
2004
+ f" 'once', 'never' and 'always'."
2005
+ )
2006
+
2007
+ verified_source = transfer_args.source[0]
2008
+ with publisher.publish_context(
2009
+ broker=self.broker,
2010
+ command=cmds.distribute_with_liquid_class(
2011
+ instrument=self,
2012
+ liquid_class=liquid_class,
2013
+ volume=volume,
2014
+ source=source,
2015
+ destination=dest,
2016
+ ),
2017
+ ):
2018
+ self._core.distribute_with_liquid_class(
2019
+ liquid_class=liquid_class,
2020
+ volume=volume,
2021
+ source=(
2022
+ types.Location(types.Point(), labware=verified_source),
2023
+ verified_source._core,
2024
+ ),
2025
+ dest=[
2026
+ (types.Location(types.Point(), labware=well), well._core)
2027
+ for well in transfer_args.dest
2028
+ ],
2029
+ new_tip=transfer_args.tip_policy, # type: ignore[arg-type]
2030
+ tip_racks=[
2031
+ (types.Location(types.Point(), labware=rack), rack._core)
2032
+ for rack in transfer_args.tip_racks
2033
+ ],
2034
+ starting_tip=(
2035
+ self.starting_tip._core if self.starting_tip is not None else None
2036
+ ),
2037
+ trash_location=transfer_args.trash_location,
2038
+ return_tip=return_tip,
2039
+ keep_last_tip=verified_keep_last_tip,
2040
+ )
2041
+
2042
+ return self
2043
+
2044
+ @requires_version(2, 24)
2045
+ def consolidate_with_liquid_class(
2046
+ self,
2047
+ liquid_class: LiquidClass,
2048
+ volume: float,
2049
+ source: Union[
2050
+ labware.Well, Sequence[labware.Well], Sequence[Sequence[labware.Well]]
2051
+ ],
2052
+ dest: Union[labware.Well, Sequence[labware.Well], TrashBin, WasteChute],
2053
+ new_tip: TransferTipPolicyV2Type = "once",
2054
+ trash_location: Optional[
2055
+ Union[types.Location, labware.Well, TrashBin, WasteChute]
2056
+ ] = None,
2057
+ return_tip: bool = False,
2058
+ group_wells: bool = True,
2059
+ keep_last_tip: Optional[bool] = None,
2060
+ ) -> InstrumentContext:
2061
+ """
2062
+ Consolidate a particular type of liquid from a group of wells to one well.
2063
+
2064
+ :param liquid_class: The type of liquid to move. You must specify the liquid class,
2065
+ even if you have used :py:meth:`.Labware.load_liquid` to indicate what liquid the
2066
+ source contains.
2067
+ :type liquid_class: :py:class:`.LiquidClass`
2068
+
2069
+ :param volume: The amount, in µL, to aspirate from each source well.
2070
+ :param source: A list of wells to aspirate liquid from.
2071
+ :param dest: A single well, list of wells, trash bin, or waste chute to dispense liquid into.
2072
+ Multiple wells can only be given for multi-channel pipette configurations, and
2073
+ must be able to be dispensed to in a single dispense.
2074
+ :param new_tip: When to pick up and drop tips during the command.
2075
+ Defaults to ``"once"``.
2076
+
2077
+ - ``"once"``: Use one tip for the entire command.
2078
+ - ``"always"``: Use a new tip after each aspirate and dispense, even when visiting the same source again.
2079
+ - ``"never"``: Do not pick up or drop tips at all.
2080
+
2081
+ See :ref:`param-tip-handling` for details.
2082
+
2083
+ :param trash_location: A trash container, well, or other location to dispose of
2084
+ tips. Depending on the liquid class, the pipette may also blow out liquid here.
2085
+ If not specified, the pipette will dispose of tips in its :py:obj:`~.InstrumentContext.trash_container`.
2086
+ :param return_tip: Whether to drop used tips in their original locations
2087
+ in the tip rack, instead of the trash.
2088
+ :param group_wells: For multi-channel transfers only. If set to ``True``, group together contiguous wells
2089
+ given into a single transfer step, taking into account the tip configuration. If ``False``, target
2090
+ each well given with the primary nozzle. Defaults to ``True``.
2091
+ :param keep_last_tip: When ``True``, the pipette keeps the last tip used in the consolidate attached. When
2092
+ ``False``, the last tip will be dropped or returned. If not set, behavior depends on the value of
2093
+ ``new_tip``. ``new_tip="never"`` keeps the tip, and all other values of ``new_tip`` drop or return the tip.
2094
+
2095
+ """
2096
+ if volume == 0.0:
2097
+ _log.info(
2098
+ f"Consolidation of {liquid_class.name} specified with a volume of 0uL."
2099
+ f" Skipping."
2100
+ )
2101
+ return self
2102
+
2103
+ transfer_args = verify_and_normalize_transfer_args(
2104
+ source=source,
2105
+ dest=dest,
2106
+ tip_policy=new_tip,
2107
+ last_tip_well=self._get_current_tip_source_well(),
2108
+ tip_racks=self._tip_racks,
2109
+ nozzle_map=self._core.get_nozzle_map(),
2110
+ group_wells_for_multi_channel=group_wells,
2111
+ current_volume=self.current_volume,
2112
+ trash_location=(
2113
+ trash_location if trash_location is not None else self.trash_container
2114
+ ),
2115
+ )
2116
+ verified_keep_last_tip = resolve_keep_last_tip(
2117
+ keep_last_tip, transfer_args.tip_policy
2118
+ )
2119
+
2120
+ verified_dest: Union[Tuple[types.Location, WellCore], TrashBin, WasteChute]
2121
+ if isinstance(transfer_args.dest, (TrashBin, WasteChute)):
2122
+ verified_dest = transfer_args.dest
2123
+ else:
2124
+ if len(transfer_args.dest) != 1:
2125
+ raise ValueError(
2126
+ f"Destination should be a single well (or resolve to a single transfer for multi-channel) "
2127
+ f"but received {transfer_args.dest}."
2128
+ )
2129
+ verified_dest = (
2130
+ types.Location(types.Point(), labware=transfer_args.dest[0]),
2131
+ transfer_args.dest[0]._core,
2132
+ )
2133
+ if transfer_args.tip_policy not in [
2134
+ TransferTipPolicyV2.ONCE,
2135
+ TransferTipPolicyV2.NEVER,
2136
+ TransferTipPolicyV2.ALWAYS,
2137
+ ]:
2138
+ raise ValueError(
2139
+ f"Incompatible `new_tip` value of {new_tip}."
2140
+ f" `consolidate_with_liquid_class()` only supports `new_tip` values of"
2141
+ f" 'once', 'never' and 'always'."
2142
+ )
2143
+
2144
+ with publisher.publish_context(
2145
+ broker=self.broker,
2146
+ command=cmds.consolidate_with_liquid_class(
2147
+ instrument=self,
2148
+ liquid_class=liquid_class,
2149
+ volume=volume,
2150
+ source=source,
2151
+ destination=dest,
2152
+ ),
2153
+ ):
2154
+ self._core.consolidate_with_liquid_class(
2155
+ liquid_class=liquid_class,
2156
+ volume=volume,
2157
+ source=[
2158
+ (types.Location(types.Point(), labware=well), well._core)
2159
+ for well in transfer_args.source
2160
+ ],
2161
+ dest=verified_dest,
2162
+ new_tip=transfer_args.tip_policy, # type: ignore[arg-type]
2163
+ tip_racks=[
2164
+ (types.Location(types.Point(), labware=rack), rack._core)
2165
+ for rack in transfer_args.tip_racks
2166
+ ],
2167
+ starting_tip=(
2168
+ self.starting_tip._core if self.starting_tip is not None else None
2169
+ ),
2170
+ trash_location=transfer_args.trash_location,
2171
+ return_tip=return_tip,
2172
+ keep_last_tip=verified_keep_last_tip,
2173
+ )
2174
+
2175
+ return self
2176
+
2177
+ @requires_version(2, 0)
2178
+ def delay(self, *args: Any, **kwargs: Any) -> None:
2179
+ """
2180
+ .. deprecated:: 2.0
2181
+ Use :py:obj:`ProtocolContext.delay` instead.
2182
+ This method does nothing.
2183
+ It will be removed from a future version of the Python Protocol API.
2184
+ """
2185
+ if args or kwargs:
2186
+ # Former implementations of this method did not take any args, so users
2187
+ # would get a TypeError if they tried to call it like delay(minutes=10).
2188
+ # Without changing the ultimate behavior that such a call fails the
2189
+ # protocol, we can provide a more descriptive message as a courtesy.
2190
+ raise UnsupportedAPIError(
2191
+ message="InstrumentContext.delay() is not supported in Python Protocol API v2. Use ProtocolContext.delay() instead."
2192
+ )
2193
+ else:
2194
+ # Former implementations of this method, when called without any args,
2195
+ # called ProtocolContext.delay() with a duration of 0, which was
2196
+ # approximately a no-op.
2197
+ # Preserve that allowed way to call this method for the very remote chance
2198
+ # that a protocol out in the wild does it, for some reason.
2199
+ pass
2200
+
2201
+ @requires_version(2, 0)
2202
+ def move_to(
2203
+ self,
2204
+ location: Union[types.Location, TrashBin, WasteChute],
2205
+ force_direct: bool = False,
2206
+ minimum_z_height: Optional[float] = None,
2207
+ speed: Optional[float] = None,
2208
+ publish: bool = True,
2209
+ ) -> InstrumentContext:
2210
+ """Move the instrument.
2211
+
2212
+ See :ref:`move-to` for examples.
2213
+
2214
+ :param location: Where to move to.
2215
+
2216
+ .. versionchanged:: 2.16
2217
+ Accepts ``TrashBin`` and ``WasteChute`` values.
2218
+
2219
+ :type location: :py:class:`~.types.Location`
2220
+ :param force_direct: If ``True``, move directly to the destination without arc
2221
+ motion.
2222
+
2223
+ .. warning::
2224
+ Forcing direct motion can cause the pipette to crash
2225
+ into labware, modules, or other objects on the deck.
2226
+
2227
+ :param minimum_z_height: An amount, measured in mm, to raise the mid-arc height.
2228
+ The mid-arc height can't be lowered.
2229
+ :param speed: The speed at which to move. By default,
2230
+ :py:attr:`InstrumentContext.default_speed`. This controls the
2231
+ straight linear speed of the motion. To limit individual axis
2232
+ speeds, use :py:obj:`.ProtocolContext.max_speeds`.
2233
+
2234
+ :param publish: Whether to list this function call in the run preview.
2235
+ Default is ``True``.
2236
+ """
2237
+ with ExitStack() as contexts:
2238
+ if isinstance(location, (TrashBin, WasteChute)):
2239
+ if publish:
2240
+ contexts.enter_context(
2241
+ publisher.publish_context(
2242
+ broker=self.broker,
2243
+ command=cmds.move_to_disposal_location(
2244
+ instrument=self, location=location
2245
+ ),
2246
+ )
2247
+ )
2248
+
2249
+ self._core.move_to(
2250
+ location=location,
2251
+ well_core=None,
2252
+ force_direct=force_direct,
2253
+ minimum_z_height=minimum_z_height,
2254
+ speed=speed,
2255
+ check_for_movement_conflicts=False,
2256
+ )
2257
+ else:
2258
+ if publish:
2259
+ contexts.enter_context(
2260
+ publisher.publish_context(
2261
+ broker=self.broker,
2262
+ command=cmds.move_to(instrument=self, location=location),
2263
+ )
2264
+ )
2265
+
2266
+ _, well = location.labware.get_parent_labware_and_well()
2267
+
2268
+ self._core.move_to(
2269
+ location=location,
2270
+ well_core=well._core if well is not None else None,
2271
+ force_direct=force_direct,
2272
+ minimum_z_height=minimum_z_height,
2273
+ speed=speed,
2274
+ check_for_movement_conflicts=False,
2275
+ )
2276
+
2277
+ return self
2278
+
2279
+ @requires_version(2, 23)
2280
+ def resin_tip_seal(
2281
+ self,
2282
+ location: Union[labware.Well, labware.Labware],
2283
+ ) -> InstrumentContext:
2284
+ """Seal resin tips onto the pipette.
2285
+
2286
+ The location provided should contain resin tips. The pipette will attach itself
2287
+ to the resin tips but does not check any tip presence sensors. Before the pipette
2288
+ seals to the tips, the plunger will rise to the top of its working range so that
2289
+ it can perform a :py:func:`resin_tip_dispense` immediately.
2290
+
2291
+ :param location: A location containing resin tips, must be a Labware or a Well.
2292
+ :type location: :py:class:`~.types.Location`
2293
+ """
2294
+ if isinstance(location, labware.Labware):
2295
+ well = location.wells()[0]
2296
+ else:
2297
+ well = location
2298
+
2299
+ with publisher.publish_context(
2300
+ broker=self.broker,
2301
+ command=cmds.seal(
2302
+ instrument=self,
2303
+ location=well,
2304
+ ),
2305
+ ):
2306
+ self._core.resin_tip_seal(
2307
+ location=well.top(), well_core=well._core, in_place=False
2308
+ )
2309
+ return self
2310
+
2311
+ @requires_version(2, 23)
2312
+ def resin_tip_unseal(
2313
+ self,
2314
+ location: Union[labware.Well, labware.Labware],
2315
+ ) -> InstrumentContext:
2316
+ """Release resin tips from the pipette.
2317
+
2318
+ The location provided should be a valid location to drop resin tips.
2319
+
2320
+ :param location: A location containing that can accept tips.
2321
+
2322
+ :type location: :py:class:`~.types.Location`
2323
+
2324
+ :param home_after:
2325
+ Whether to home the pipette after dropping the tip. If not specified
2326
+ defaults to ``True`` on a Flex. The plunger will not home on an unseal.
2327
+
2328
+ When ``False``, the pipette does not home its plunger. This can save a few
2329
+ seconds, but is not recommended. Homing helps the robot track the pipette's
2330
+ position.
2331
+
2332
+ """
2333
+ if isinstance(location, labware.Labware):
2334
+ well = location.wells()[0]
2335
+ else:
2336
+ well = location
2337
+
2338
+ with publisher.publish_context(
2339
+ broker=self.broker,
2340
+ command=cmds.unseal(
2341
+ instrument=self,
2342
+ location=well,
2343
+ ),
2344
+ ):
2345
+ self._core.resin_tip_unseal(location=None, well_core=well._core)
2346
+
2347
+ return self
2348
+
2349
+ @requires_version(2, 23)
2350
+ def resin_tip_dispense(
2351
+ self,
2352
+ location: types.Location,
2353
+ volume: Optional[float] = None,
2354
+ rate: Optional[float] = None,
2355
+ ) -> InstrumentContext:
2356
+ """Push liquid out of resin tips that are currently sealed to a pipette.
2357
+
2358
+ The volume and rate parameters for this function control the motion of the plunger
2359
+ to create a desired pressure profile inside the pipette chamber. Unlike a regular
2360
+ dispense action, the volume and rate do not correspond to liquid volume or flow rate
2361
+ dispensed from the resin tips. Select your values for volume and flow rate based on
2362
+ experimentation with the resin tips to create a pressure profile.
2363
+
2364
+ The common way to use this function is as follows:
2365
+
2366
+ #. Seal resin tips to the pipette using :py:meth:`InstrumentContext.resin_tip_seal`.
2367
+
2368
+ #. Use :py:meth:`InstrumentContext.resin_tip_dispense` to displace an experimentally
2369
+ derived volume at an experimentally derived rate to create an experimentally derived
2370
+ target pressure inside the pipette.
2371
+
2372
+ #. Use :py:meth:`ProtocolContext.delay` to wait an experimentally derived amount of
2373
+ time for the pressure inside the pipette to push liquid into and through the resin tip
2374
+ and out the other side.
2375
+
2376
+ #. As liquid passes through the resin tip, the pressure inside the pipette will
2377
+ fall. If not all liquid has been dispensed from the resin tip, repeat steps 2
2378
+ and 3.
2379
+
2380
+ #. Unseal resin tips from the pipette using :py:meth:`InstrumentContext.resin_tip_unseal`.
2381
+
2382
+ Flex pipette pressure sensors will raise an overpressure when a differential pressure
2383
+ inside the pipette chamber above sensor limits is detected. You may need to disable the
2384
+ pressure sensor to create the required pressure profile.
2385
+
2386
+ .. warning::
2387
+ Building excessive pressure inside the pipette chamber (significantly above the sensor
2388
+ limit) with the pressure sensors disabled can damage the pipette.
2389
+
2390
+
2391
+ :param location: Tells the robot where to dispense.
2392
+ :type location: :py:class:`~.types.Location`
2393
+
2394
+ :param volume: The volume that the plunger should displace, in µL. Does not directly relate
2395
+ to the volume of liquid that will be dispensed.
2396
+ :type volume: float
2397
+
2398
+ :param rate: How quickly the plunger moves to displace the commanded volume, in µL/s. This rate does not directly relate to
2399
+ the flow rate of liquid out of the resin tip.
2400
+
2401
+ Defaults to ``10.0`` µL/s.
2402
+ :type rate: float
2403
+ """
2404
+ well: Optional[labware.Well] = None
2405
+ last_location = self._get_last_location_by_api_version()
2406
+
2407
+ try:
2408
+ target = validation.validate_location(
2409
+ location=location, last_location=last_location
2410
+ )
2411
+ except validation.NoLocationError as e:
2412
+ raise RuntimeError(
2413
+ "If dispense is called without an explicit location, another"
2414
+ " method that moves to a location (such as move_to or "
2415
+ "aspirate) must previously have been called so the robot "
2416
+ "knows where it is."
2417
+ ) from e
2418
+
2419
+ if isinstance(target, validation.WellTarget):
2420
+ well = target.well
2421
+ if target.location:
2422
+ move_to_location = target.location
2423
+ elif well.parent._core.is_fixed_trash():
2424
+ move_to_location = target.well.top()
2425
+ else:
2426
+ move_to_location = target.well.bottom(
2427
+ z=self._well_bottom_clearances.dispense
2428
+ )
2429
+ else:
2430
+ raise RuntimeError(
2431
+ "A well must be specified when using `resin_tip_dispense`."
2432
+ )
2433
+
2434
+ with publisher.publish_context(
2435
+ broker=self.broker,
2436
+ command=cmds.resin_tip_dispense(
2437
+ instrument=self,
2438
+ flow_rate=rate,
2439
+ ),
2440
+ ):
2441
+ self._core.resin_tip_dispense(
2442
+ move_to_location,
2443
+ well_core=well._core,
2444
+ volume=volume,
2445
+ flow_rate=rate,
2446
+ )
2447
+ return self
2448
+
2449
+ @requires_version(2, 18)
2450
+ def _retract(
2451
+ self,
2452
+ ) -> None:
2453
+ self._core.retract()
2454
+
2455
+ @property
2456
+ @requires_version(2, 0)
2457
+ def mount(self) -> str:
2458
+ """
2459
+ Return the name of the mount the pipette is attached to.
2460
+
2461
+ The possible names are ``"left"`` and ``"right"``.
2462
+ """
2463
+ return self._core.get_mount().name.lower()
2464
+
2465
+ @property
2466
+ @requires_version(2, 0)
2467
+ def speed(self) -> "PlungerSpeeds":
2468
+ """The speeds (in mm/s) configured for the pipette plunger.
2469
+
2470
+ This is an object with attributes ``aspirate``, ``dispense``, and ``blow_out``
2471
+ holding the plunger speeds for the corresponding operation.
2472
+
2473
+ .. note::
2474
+ Setting values of :py:attr:`flow_rate` will override the values in
2475
+ :py:attr:`speed`.
2476
+
2477
+ .. versionchanged:: 2.14
2478
+ This property has been removed because it's fundamentally misaligned with
2479
+ the step-wise nature of a pipette's plunger speed configuration. Use
2480
+ :py:attr:`.flow_rate` instead.
2481
+ """
2482
+ if self._api_version >= ENGINE_CORE_API_VERSION:
2483
+ raise UnsupportedAPIError(
2484
+ message="InstrumentContext.speed has been removed. Use InstrumentContext.flow_rate, instead."
2485
+ )
2486
+
2487
+ # TODO(mc, 2023-02-13): this assert should be enough for mypy
2488
+ # investigate if upgrading mypy allows the `cast` to be removed
2489
+ assert isinstance(self._core, LegacyInstrumentCore)
2490
+ return cast(LegacyInstrumentCore, self._core).get_speed()
2491
+
2492
+ @property
2493
+ @requires_version(2, 0)
2494
+ def flow_rate(self) -> "FlowRates":
2495
+ """The speeds, in µL/s, configured for the pipette.
2496
+
2497
+ See :ref:`new-plunger-flow-rates`.
2498
+
2499
+ This is an object with attributes ``aspirate``, ``dispense``, and ``blow_out``
2500
+ holding the flow rate for the corresponding operation.
2501
+
2502
+ .. note::
2503
+ Setting values of :py:attr:`speed`, which is deprecated, will override the
2504
+ values in :py:attr:`flow_rate`.
2505
+
2506
+ """
2507
+ return self._core.get_flow_rate()
2508
+
2509
+ @property
2510
+ @requires_version(2, 0)
2511
+ def type(self) -> str:
2512
+ """``'single'`` if this is a 1-channel pipette, or ``'multi'`` otherwise.
2513
+
2514
+ See also :py:obj:`.channels`, which can distinguish between 8-channel and 96-channel
2515
+ pipettes.
2516
+ """
2517
+ if self.channels == 1:
2518
+ return "single"
2519
+ else:
2520
+ return "multi"
2521
+
2522
+ @property
2523
+ @requires_version(2, 0)
2524
+ def tip_racks(self) -> List[labware.Labware]:
2525
+ """
2526
+ The tip racks that have been linked to this pipette.
2527
+
2528
+ This is the property used to determine which tips to pick up next when calling
2529
+ :py:meth:`pick_up_tip` without arguments. See :ref:`basic-tip-pickup`.
2530
+ """
2531
+ return self._tip_racks
2532
+
2533
+ @tip_racks.setter
2534
+ def tip_racks(self, racks: List[labware.Labware]) -> None:
2535
+ self._tip_racks = racks
2536
+
2537
+ @property
2538
+ @requires_version(2, 20)
2539
+ def liquid_presence_detection(self) -> bool:
2540
+ """
2541
+ Whether the pipette will perform automatic liquid presence detection.
2542
+
2543
+ When ``True``, the pipette will check for liquid on every aspiration.
2544
+ Defaults to ``False``. See :ref:`lpd`.
2545
+ """
2546
+ return self._core.get_liquid_presence_detection()
2547
+
2548
+ @liquid_presence_detection.setter
2549
+ @requires_version(2, 20)
2550
+ def liquid_presence_detection(self, enable: bool) -> None:
2551
+ if enable:
2552
+ self._raise_if_pressure_not_supported_by_pipette()
2553
+ self._core.set_liquid_presence_detection(enable)
2554
+
2555
+ @property
2556
+ @requires_version(2, 0)
2557
+ def trash_container(self) -> Union[labware.Labware, TrashBin, WasteChute]:
2558
+ """The trash container associated with this pipette.
2559
+
2560
+ This is the property used to determine where to drop tips and blow out liquids
2561
+ when calling :py:meth:`drop_tip` or :py:meth:`blow_out` without arguments.
2562
+
2563
+ You can set this to a :py:obj:`Labware`, :py:class:`.TrashBin`, or :py:class:`.WasteChute`.
2564
+
2565
+ The default value depends on the robot type and API version:
2566
+
2567
+ - :py:obj:`ProtocolContext.fixed_trash`, if it exists.
2568
+ - Otherwise, the first item previously loaded with
2569
+ :py:obj:`ProtocolContext.load_trash_bin()` or
2570
+ :py:obj:`ProtocolContext.load_waste_chute()`.
2571
+
2572
+ .. versionchanged:: 2.16
2573
+ Added support for ``TrashBin`` and ``WasteChute`` objects.
2574
+ """
2575
+ if self._user_specified_trash is None:
2576
+ disposal_locations = self._protocol_core.get_disposal_locations()
2577
+ if len(disposal_locations) == 0:
2578
+ raise NoTrashDefinedError(
2579
+ "No trash container has been defined in this protocol."
2580
+ )
2581
+ return disposal_locations[0]
2582
+ return self._user_specified_trash
2583
+
2584
+ @trash_container.setter
2585
+ def trash_container(
2586
+ self, trash: Union[labware.Labware, TrashBin, WasteChute]
2587
+ ) -> None:
2588
+ self._user_specified_trash = trash
2589
+
2590
+ @property
2591
+ @requires_version(2, 0)
2592
+ def name(self) -> str:
2593
+ """
2594
+ The name string for the pipette.
2595
+
2596
+ From API version 2.15 to 2.22, this property returned an internal name for Flex
2597
+ pipettes. (e.g., ``"p1000_single_flex"``).
2598
+
2599
+ In API version 2.23 and later, this property returns the Python Protocol API
2600
+ :ref:`load name <new-pipette-models>` of Flex pipettes (e.g.,
2601
+ ``"flex_1channel_1000"``).
2602
+ """
2603
+ return self._core.get_pipette_name()
2604
+
2605
+ @property
2606
+ @requires_version(2, 0)
2607
+ def model(self) -> str:
2608
+ """
2609
+ The model string for the pipette (e.g., ``'p300_single_v1.3'``)
2610
+ """
2611
+ return self._core.get_model()
2612
+
2613
+ @property
2614
+ @requires_version(2, 0)
2615
+ def min_volume(self) -> float:
2616
+ """
2617
+ The minimum volume, in µL, that the pipette can hold. This value may change
2618
+ based on the :ref:`volume mode <pipette-volume-modes>` that the pipette is
2619
+ currently configured for.
2620
+ """
2621
+ return self._core.get_min_volume()
2622
+
2623
+ @property
2624
+ @requires_version(2, 0)
2625
+ def max_volume(self) -> float:
2626
+ """
2627
+ The maximum volume, in µL, that the pipette can hold.
2628
+
2629
+ The maximum volume that you can actually aspirate might be lower than this,
2630
+ depending on what kind of tip is attached to this pipette. For example, a P300
2631
+ Single-Channel pipette always has a ``max_volume`` of 300 µL, but if it's using
2632
+ a 200 µL filter tip, its usable volume would be limited to 200 µL.
2633
+ """
2634
+ return self._core.get_max_volume()
2635
+
2636
+ @property
2637
+ @requires_version(2, 0)
2638
+ def current_volume(self) -> float:
2639
+ """
2640
+ The current amount of liquid held in the pipette, measured in µL.
2641
+ """
2642
+ return self._core.get_current_volume()
2643
+
2644
+ @property
2645
+ @requires_version(2, 7)
2646
+ def has_tip(self) -> bool:
2647
+ """Whether this instrument has a tip attached or not.
2648
+
2649
+ The value of this property is determined logically by the API, not by detecting
2650
+ the physical presence of a tip. This is the case even on Flex, which has sensors
2651
+ to detect tip attachment.
2652
+ """
2653
+ return self._core.has_tip()
2654
+
2655
+ @property
2656
+ def _has_tip(self) -> bool:
2657
+ """
2658
+ Internal function used to check whether this instrument has a
2659
+ tip attached or not.
2660
+ """
2661
+ return self._core.has_tip()
2662
+
2663
+ @property
2664
+ @requires_version(2, 0)
2665
+ def hw_pipette(self) -> PipetteDict:
2666
+ """View the information returned by the hardware API directly.
2667
+
2668
+ :raises: :py:class:`.types.PipetteNotAttachedError` if the pipette is
2669
+ no longer attached (should not happen).
2670
+ """
2671
+ return self._core.get_hardware_state()
2672
+
2673
+ @property
2674
+ @requires_version(2, 0)
2675
+ def channels(self) -> int:
2676
+ """The number of channels on the pipette.
2677
+
2678
+ Possible values are 1, 8, or 96.
2679
+
2680
+ See also :py:obj:`.type`.
2681
+ """
2682
+ return self._core.get_channels()
2683
+
2684
+ @property
2685
+ @requires_version(2, 16)
2686
+ def active_channels(self) -> int:
2687
+ """The number of channels the pipette will use to pick up tips.
2688
+
2689
+ By default, all channels on the pipette. Use :py:meth:`.configure_nozzle_layout`
2690
+ to set the pipette to use fewer channels.
2691
+ """
2692
+ return self._core.get_active_channels()
2693
+
2694
+ @property
2695
+ @requires_version(2, 2)
2696
+ def return_height(self) -> float:
2697
+ """The height to return a tip to its tip rack.
2698
+
2699
+ :returns: A scaling factor to apply to the tip length.
2700
+ During :py:meth:`.drop_tip`, this factor is multiplied by the tip
2701
+ length to get the distance from the top of the well to drop the tip.
2702
+ """
2703
+ return self._core.get_return_height()
2704
+
2705
+ @property
2706
+ @requires_version(2, 0)
2707
+ def well_bottom_clearance(self) -> "Clearances":
2708
+ """The distance above the bottom of a well to aspirate or dispense.
2709
+
2710
+ This is an object with attributes ``aspirate`` and ``dispense``, describing the
2711
+ default height of the corresponding operation. The default is 1.0 mm for both
2712
+ aspirate and dispense.
2713
+
2714
+ When :py:meth:`aspirate` or :py:meth:`dispense` is given a :py:class:`.Well`
2715
+ rather than a full :py:class:`.Location`, the robot will move this distance
2716
+ above the bottom of the well to aspirate or dispense.
2717
+
2718
+ To change, set the corresponding attribute::
2719
+
2720
+ pipette.well_bottom_clearance.aspirate = 2
2721
+
2722
+ """
2723
+ return self._well_bottom_clearances
2724
+
2725
+ def _get_last_location_by_api_version(
2726
+ self,
2727
+ ) -> Optional[Union[types.Location, TrashBin, WasteChute]]:
2728
+ """Get the last location accessed by this pipette, if any.
2729
+
2730
+ In pre-engine Protocol API versions, this call omits the pipette mount.
2731
+ Between 2.14 (first engine PAPI version) and 2.23 this only returns None or a Location object.
2732
+ This is to preserve pre-existing, potentially buggy behavior.
2733
+ """
2734
+ if self._api_version >= APIVersion(2, 24):
2735
+ return self._protocol_core.get_last_location(mount=self._core.get_mount())
2736
+ elif self._api_version >= ENGINE_CORE_API_VERSION:
2737
+ last_location = self._protocol_core.get_last_location(
2738
+ mount=self._core.get_mount()
2739
+ )
2740
+ return last_location if isinstance(last_location, types.Location) else None
2741
+ else:
2742
+ return self._protocol_core.get_last_location()
2743
+
2744
+ def __repr__(self) -> str:
2745
+ return "<{}: {} in {}>".format(
2746
+ self.__class__.__name__,
2747
+ self._core.get_model(),
2748
+ self._core.get_mount().name,
2749
+ )
2750
+
2751
+ def __str__(self) -> str:
2752
+ return "{} on {} mount".format(self._core.get_display_name(), self.mount)
2753
+
2754
+ @publisher.publish(command=cmds.configure_for_volume)
2755
+ @requires_version(2, 15)
2756
+ def configure_for_volume(self, volume: float) -> None:
2757
+ """Configure a pipette to handle a specific volume of liquid, measured in µL.
2758
+ The pipette enters a volume mode depending on the volume provided. Changing
2759
+ pipette modes alters properties of the instance of
2760
+ :py:class:`.InstrumentContext`, such as default flow rate, minimum volume, and
2761
+ maximum volume. The pipette remains in the mode set by this function until it is
2762
+ called again.
2763
+
2764
+ The Flex 1-Channel 50 µL and Flex 8-Channel 50 µL pipettes must operate in a
2765
+ low-volume mode to accurately dispense very small volumes of liquid. Low-volume
2766
+ mode can only be set by calling ``configure_for_volume()``. See
2767
+ :ref:`pipette-volume-modes`.
2768
+
2769
+ .. note ::
2770
+
2771
+ Changing a pipette's mode will reset its :ref:`flow rates
2772
+ <new-plunger-flow-rates>`.
2773
+
2774
+ This function will raise an error if called when the pipette's tip contains
2775
+ liquid. It won't raise an error if a tip is not attached, but changing modes may
2776
+ affect which tips the pipette can subsequently pick up without raising an error.
2777
+
2778
+ This function will also raise an error if ``volume`` is outside of the
2779
+ :ref:`minimum and maximum capacities <new-pipette-models>` of the pipette (e.g.,
2780
+ setting ``volume=1`` for a Flex 1000 µL pipette).
2781
+
2782
+ :param volume: The volume, in µL, that the pipette will prepare to handle.
2783
+ :type volume: float
2784
+ """
2785
+ if self._core.get_current_volume():
2786
+ raise CommandPreconditionViolated(
2787
+ message=f"Cannot switch modes of {str(self)} while it contains liquid"
2788
+ )
2789
+ if volume < 0:
2790
+ raise CommandParameterLimitViolated(
2791
+ command_name="configure_for_volume",
2792
+ parameter_name="volume",
2793
+ limit_statement="must be greater than 0",
2794
+ actual_value=str(volume),
2795
+ )
2796
+ last_location = self._get_last_location_by_api_version()
2797
+ if (
2798
+ last_location
2799
+ and isinstance(last_location, types.Location)
2800
+ and isinstance(last_location.labware, labware.Well)
2801
+ ):
2802
+ self.move_to(last_location.labware.top())
2803
+ self._core.configure_for_volume(volume)
2804
+
2805
+ @requires_version(2, 16)
2806
+ def prepare_to_aspirate(self) -> None:
2807
+ """Prepare a pipette for aspiration.
2808
+
2809
+ Before a pipette can aspirate into an empty tip, the plunger must be in its
2810
+ bottom position. After dropping a tip or blowing out, the plunger will be in a
2811
+ different position. This function moves the plunger to the bottom position,
2812
+ regardless of its current position, to make sure that the pipette is ready to
2813
+ aspirate.
2814
+
2815
+ You rarely need to call this function. The API automatically prepares the
2816
+ pipette for aspiration as part of other commands:
2817
+
2818
+ - After picking up a tip with :py:meth:`.pick_up_tip`.
2819
+ - When calling :py:meth:`.aspirate`, if the pipette isn't already prepared.
2820
+ If the pipette is in a well, it will move out of the well, move the plunger,
2821
+ and then move back.
2822
+
2823
+ Use ``prepare_to_aspirate()`` when you need to control exactly when the plunger
2824
+ motion will happen. A common use case is a pre-wetting routine, which requires
2825
+ preparing for aspiration, moving into a well, and then aspirating *without
2826
+ leaving the well*::
2827
+
2828
+ pipette.move_to(well.bottom(z=2))
2829
+ protocol.delay(5)
2830
+ pipette.mix(10, 10)
2831
+ pipette.move_to(well.top(z=5))
2832
+ pipette.blow_out()
2833
+ pipette.prepare_to_aspirate()
2834
+ pipette.move_to(well.bottom(z=2))
2835
+ protocol.delay(5)
2836
+ pipette.aspirate(10, well.bottom(z=2))
2837
+
2838
+ The call to ``prepare_to_aspirate()`` means that the plunger will be in the
2839
+ bottom position before the call to ``aspirate()``. Since it doesn't need to
2840
+ prepare again, it will not move up out of the well to move the plunger. It will
2841
+ aspirate in place.
2842
+ """
2843
+ if self._core.get_current_volume():
2844
+ raise CommandPreconditionViolated(
2845
+ message=f"Cannot prepare {str(self)} for aspirate while it contains liquid."
2846
+ )
2847
+ self._core.prepare_to_aspirate()
2848
+
2849
+ @publisher.publish(command=cmds.configure_nozzle_layout)
2850
+ @requires_version(2, 16)
2851
+ def configure_nozzle_layout(
2852
+ self,
2853
+ style: NozzleLayout,
2854
+ start: Optional[str] = None,
2855
+ end: Optional[str] = None,
2856
+ front_right: Optional[str] = None,
2857
+ back_left: Optional[str] = None,
2858
+ tip_racks: Optional[List[labware.Labware]] = None,
2859
+ ) -> None:
2860
+ """Configure how many tips the 8-channel or 96-channel pipette will pick up.
2861
+
2862
+ Changing the nozzle layout will affect gantry movement for all subsequent
2863
+ pipetting actions that the pipette performs. It also alters the pipette's
2864
+ behavior for picking up tips. The pipette will continue to use the specified
2865
+ layout until this function is called again.
2866
+
2867
+ .. note::
2868
+ When picking up fewer than 96 tips at once, the tip rack *must not* be
2869
+ placed in a tip rack adapter in the deck. If you try to pick up fewer than 96
2870
+ tips from a tip rack that is in an adapter, the API will raise an error.
2871
+
2872
+ :param style: The shape of the nozzle layout.
2873
+ You must :ref:`import the layout constant <nozzle-layouts>` in order to use it.
2874
+
2875
+ - ``ALL`` resets the pipette to use all of its nozzles. Calling
2876
+ ``configure_nozzle_layout`` with no arguments also resets the pipette.
2877
+ - ``COLUMN`` sets a 96-channel pipette to use 8 nozzles, aligned from front to back
2878
+ with respect to the deck. This corresponds to a column of wells on labware.
2879
+ For 8-channel pipettes, use ``ALL`` instead.
2880
+ - ``PARTIAL_COLUMN`` sets an 8-channel pipette to use 2--7 nozzles, aligned from front to back
2881
+ with respect to the deck. Not compatible with the 96-channel pipette.
2882
+ - ``ROW`` sets a 96-channel pipette to use 12 nozzles, aligned from left to right
2883
+ with respect to the deck. This corresponds to a row of wells on labware.
2884
+ Not compatible with 8-channel pipettes.
2885
+ - ``SINGLE`` sets the pipette to use 1 nozzle. This corresponds to a single well on labware.
2886
+
2887
+ :type style: ``NozzleLayout`` or ``None``
2888
+ :param start: The primary nozzle of the layout, which the robot uses
2889
+ to determine how it will move to different locations on the deck. The string
2890
+ should be of the same format used when identifying wells by name.
2891
+ Required unless setting ``style=ALL``.
2892
+
2893
+ .. note::
2894
+ If possible, don't use both ``start="A1"`` and ``start="A12"`` to pick up
2895
+ tips *from the same rack*. Doing so can affect positional accuracy.
2896
+
2897
+ :type start: str or ``None``
2898
+ :param end: The nozzle at the end of a linear layout, which is used
2899
+ to determine how many tips will be picked up by a pipette. The string
2900
+ should be of the same format used when identifying wells by name.
2901
+ Required when setting ``style=PARTIAL_COLUMN``.
2902
+
2903
+ :type end: str or ``None``
2904
+ :param tip_racks: Behaves the same as setting the ``tip_racks`` parameter of
2905
+ :py:meth:`.load_instrument`. If not specified, the new configuration resets
2906
+ :py:obj:`.InstrumentContext.tip_racks` and you must specify the location
2907
+ every time you call :py:meth:`~.InstrumentContext.pick_up_tip`.
2908
+ :type tip_racks: List[:py:class:`.Labware`]
2909
+
2910
+ .. versionchanged:: 2.20
2911
+ Added partial column, row, and single layouts.
2912
+ """
2913
+ # TODO: add the following back into the docstring when QUADRANT is supported
2914
+ #
2915
+ # :param front_right: The nozzle at the front left of the layout. Only used for
2916
+ # NozzleLayout.QUADRANT configurations.
2917
+ # :type front_right: str or ``None``
2918
+ #
2919
+ # NOTE: Disabled layouts error case can be removed once desired map configurations
2920
+ # have appropriate data regarding tip-type to map current values added to the
2921
+ # pipette definitions.
2922
+
2923
+ disabled_layouts = [
2924
+ NozzleLayout.QUADRANT,
2925
+ ]
2926
+ if style in disabled_layouts:
2927
+ # todo(mm, 2024-08-20): UnsupportedAPIError boils down to an API_REMOVED
2928
+ # error code, which is not correct here.
2929
+ raise UnsupportedAPIError(
2930
+ message=f"Nozzle layout configuration of style {style.value} is currently unsupported."
2931
+ )
2932
+
2933
+ original_enabled_layouts = [NozzleLayout.COLUMN, NozzleLayout.ALL]
2934
+ if (
2935
+ self._api_version
2936
+ < _PARTIAL_NOZZLE_CONFIGURATION_SINGLE_ROW_PARTIAL_COLUMN_ADDED_IN
2937
+ ) and (style not in original_enabled_layouts):
2938
+ raise APIVersionError(
2939
+ api_element=f"Nozzle layout configuration of style {style.value}",
2940
+ until_version=str(
2941
+ _PARTIAL_NOZZLE_CONFIGURATION_SINGLE_ROW_PARTIAL_COLUMN_ADDED_IN
2942
+ ),
2943
+ current_version=str(self._api_version),
2944
+ )
2945
+
2946
+ front_right_resolved = front_right
2947
+ back_left_resolved = back_left
2948
+ validated_start: Optional[str] = None
2949
+ match style:
2950
+ case NozzleLayout.SINGLE:
2951
+ validated_start = _check_valid_start_nozzle(style, start)
2952
+ _raise_if_has_end_or_front_right_or_back_left(
2953
+ style, end, front_right, back_left
2954
+ )
2955
+ case NozzleLayout.COLUMN | NozzleLayout.ROW:
2956
+ self._raise_if_configuration_not_supported_by_pipette(style)
2957
+ validated_start = _check_valid_start_nozzle(style, start)
2958
+ _raise_if_has_end_or_front_right_or_back_left(
2959
+ style, end, front_right, back_left
2960
+ )
2961
+ case NozzleLayout.PARTIAL_COLUMN:
2962
+ self._raise_if_configuration_not_supported_by_pipette(style)
2963
+ validated_start = _check_valid_start_nozzle(style, start)
2964
+ validated_end = _check_valid_end_nozzle(validated_start, end)
2965
+ _raise_if_has_front_right_or_back_left_for_partial_column(
2966
+ front_right, back_left
2967
+ )
2968
+ # Convert 'validated_end' to front_right or back_left as appropriate
2969
+ if validated_start == "H1" or validated_start == "H12":
2970
+ back_left_resolved = validated_end
2971
+ front_right_resolved = validated_start
2972
+ elif start == "A1" or start == "A12":
2973
+ front_right_resolved = validated_end
2974
+ back_left_resolved = validated_start
2975
+ case NozzleLayout.QUADRANT:
2976
+ validated_start = _check_valid_start_nozzle(style, start)
2977
+ _raise_if_has_end_nozzle_for_quadrant(end)
2978
+ _raise_if_no_front_right_or_back_left_for_quadrant(
2979
+ front_right, back_left
2980
+ )
2981
+ if front_right is None:
2982
+ front_right_resolved = validated_start
2983
+ elif back_left is None:
2984
+ back_left_resolved = validated_start
2985
+ case NozzleLayout.ALL:
2986
+ validated_start = start
2987
+ if any([start, end, front_right, back_left]):
2988
+ _log.warning(
2989
+ "Parameters 'start', 'end', 'front_right', 'back_left' specified"
2990
+ " for ALL nozzle configuration will be ignored."
2991
+ )
2992
+
2993
+ self._core.configure_nozzle_layout(
2994
+ style,
2995
+ primary_nozzle=validated_start,
2996
+ front_right_nozzle=front_right_resolved,
2997
+ back_left_nozzle=back_left_resolved,
2998
+ )
2999
+ self._tip_racks = tip_racks or []
3000
+
3001
+ @requires_version(2, 20)
3002
+ def detect_liquid_presence(self, well: labware.Well) -> bool:
3003
+ """Checks for liquid in a well.
3004
+
3005
+ Returns ``True`` if liquid is present and ``False`` if liquid is not present. Will not raise an error if it does not detect liquid. When simulating a protocol, the check always succeeds (returns ``True``). Works with Flex 1-, 8-, and 96-channel pipettes. See :ref:`detect-liquid-presence`.
3006
+
3007
+ .. note::
3008
+ The pressure sensors for the Flex 8-channel pipette are on channels 1 and 8 (positions A1 and H1). For the Flex 96-channel pipette, the pressure sensors are on channels 1 and 96 (positions A1 and H12). Other channels on multi-channel pipettes do not have sensors and cannot detect liquid.
3009
+ """
3010
+ self._raise_if_pressure_not_supported_by_pipette()
3011
+ loc = well.top()
3012
+ return self._core.detect_liquid_presence(well._core, loc)
3013
+
3014
+ @requires_version(2, 20)
3015
+ def require_liquid_presence(self, well: labware.Well) -> None:
3016
+ """Check for liquid in a well and raises an error if none is detected.
3017
+
3018
+ When this method raises an error, Flex will offer the opportunity to enter recovery mode. In recovery mode, you can manually add liquid to resolve the error. When simulating a protocol, the check always succeeds (does not raise an error). Works with Flex 1-, 8-, and 96-channel pipettes. See :ref:`lpd` and :ref:`require-liquid-presence`.
3019
+
3020
+ .. note::
3021
+ The pressure sensors for the Flex 8-channel pipette are on channels 1 and 8 (positions A1 and H1). For the Flex 96-channel pipette, the pressure sensors are on channels 1 and 96 (positions A1 and H12). Other channels on multi-channel pipettes do not have sensors and cannot detect liquid.
3022
+ """
3023
+ self._raise_if_pressure_not_supported_by_pipette()
3024
+ loc = well.top()
3025
+ self._core.liquid_probe_with_recovery(well._core, loc)
3026
+
3027
+ @requires_version(2, 20)
3028
+ def measure_liquid_height(self, well: labware.Well) -> LiquidTrackingType:
3029
+ """Check the height of the liquid within a well.
3030
+
3031
+ :returns: The height, in mm, of the liquid from the bottom of the well.
3032
+ """
3033
+ self._raise_if_pressure_not_supported_by_pipette()
3034
+ loc = well.top()
3035
+ self._core.liquid_probe_with_recovery(well._core, loc)
3036
+ return well.current_liquid_height()
3037
+
3038
+ def _raise_if_configuration_not_supported_by_pipette(
3039
+ self, style: NozzleLayout
3040
+ ) -> None:
3041
+ match style:
3042
+ case NozzleLayout.COLUMN | NozzleLayout.ROW:
3043
+ if self.channels != 96:
3044
+ raise ValueError(
3045
+ f"{style.value} configuration is only supported on 96-Channel pipettes."
3046
+ )
3047
+ case NozzleLayout.PARTIAL_COLUMN:
3048
+ if self.channels != 8:
3049
+ raise ValueError(
3050
+ "Partial column configuration is only supported on 8-Channel pipettes."
3051
+ )
3052
+ # SINGLE, QUADRANT and ALL are supported by all pipettes
3053
+
3054
+ def _raise_if_pressure_not_supported_by_pipette(self) -> None:
3055
+ if not self._core._pressure_supported_by_pipette():
3056
+ raise UnsupportedHardwareCommand(
3057
+ "Pressure sensor not available for this pipette"
3058
+ )
3059
+
3060
+ def _handle_aspirate_target(
3061
+ self, target: Union[validation.WellTarget, validation.PointTarget]
3062
+ ) -> tuple[
3063
+ types.Location, Optional[labware.Well], Optional[types.MeniscusTrackingTarget]
3064
+ ]:
3065
+ if isinstance(target, validation.WellTarget):
3066
+ if target.location:
3067
+ return target.location, target.well, target.location.meniscus_tracking
3068
+
3069
+ else:
3070
+ return (
3071
+ target.well.bottom(z=self._well_bottom_clearances.aspirate),
3072
+ target.well,
3073
+ None,
3074
+ )
3075
+ if isinstance(target, validation.PointTarget):
3076
+ return target.location, None, None
3077
+
3078
+ def _handle_dispense_target(
3079
+ self, target: Union[validation.WellTarget, validation.PointTarget]
3080
+ ) -> tuple[
3081
+ types.Location, Optional[labware.Well], Optional[types.MeniscusTrackingTarget]
3082
+ ]:
3083
+ if isinstance(target, validation.WellTarget):
3084
+ if target.location:
3085
+ return target.location, target.well, target.location.meniscus_tracking
3086
+ elif target.well.parent._core.is_fixed_trash():
3087
+ return target.well.top(), target.well, None
3088
+ else:
3089
+ return (
3090
+ target.well.bottom(z=self._well_bottom_clearances.dispense),
3091
+ target.well,
3092
+ None,
3093
+ )
3094
+ if isinstance(target, validation.PointTarget):
3095
+ return target.location, None, None
3096
+
3097
+ def _get_current_tip_source_well(self) -> Optional[labware.Well]:
3098
+ tip_rack_cores = self._core.get_tip_origin()
3099
+ if tip_rack_cores is None:
3100
+ return None
3101
+ labware_core, well_core = tip_rack_cores
3102
+ tip_rack_labware = self._core_map.get(labware_core)
3103
+ return labware.Well(
3104
+ parent=tip_rack_labware, core=well_core, api_version=self._api_version
3105
+ )
3106
+
3107
+ @property
3108
+ def _last_tip_picked_up_from(self) -> Optional[labware.Well]:
3109
+ """
3110
+ .. deprecated:: 2.25
3111
+ Use :py:obj:`ProtocolContext.current_tip_source_well` instead.
3112
+
3113
+ If the pipette has a tip on it, returns the tip rack well it was picked up from.
3114
+ Otherwise will return ``None``.
3115
+ """
3116
+ return self._get_current_tip_source_well()
3117
+
3118
+ @requires_version(2, 25)
3119
+ def current_tip_source_well(self) -> Optional[labware.Well]:
3120
+ """Returns the tip rack well the current tip has been picked up from.
3121
+
3122
+ If there is no tip currently on the pipette, this will return ``None``.
3123
+ """
3124
+ return self._get_current_tip_source_well()
3125
+
3126
+
3127
+ class AutoProbeDisable:
3128
+ """Use this class to temporarily disable automatic liquid presence detection."""
3129
+
3130
+ def __init__(self, instrument: InstrumentContext):
3131
+ self.instrument = instrument
3132
+
3133
+ def __enter__(self) -> None:
3134
+ if self.instrument.api_version >= APIVersion(2, 21):
3135
+ self.auto_presence = self.instrument.liquid_presence_detection
3136
+ self.instrument.liquid_presence_detection = False
3137
+
3138
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
3139
+ if self.instrument.api_version >= APIVersion(2, 21):
3140
+ self.instrument.liquid_presence_detection = self.auto_presence
3141
+
3142
+
3143
+ def _raise_if_has_end_or_front_right_or_back_left(
3144
+ style: NozzleLayout,
3145
+ end: Optional[str],
3146
+ front_right: Optional[str],
3147
+ back_left: Optional[str],
3148
+ ) -> None:
3149
+ if any([end, front_right, back_left]):
3150
+ raise ValueError(
3151
+ f"Parameters 'end', 'front_right' and 'back_left' cannot be used with "
3152
+ f"the {style.name} nozzle configuration."
3153
+ )
3154
+
3155
+
3156
+ def _check_valid_start_nozzle(style: NozzleLayout, start: Optional[str]) -> str:
3157
+ if start is None:
3158
+ raise ValueError(
3159
+ f"Cannot configure a nozzle layout of style {style.value} without a starting nozzle."
3160
+ )
3161
+ if start not in types.ALLOWED_PRIMARY_NOZZLES:
3162
+ raise ValueError(
3163
+ f"Starting nozzle specified is not one of {types.ALLOWED_PRIMARY_NOZZLES}."
3164
+ )
3165
+ return start
3166
+
3167
+
3168
+ def _check_valid_end_nozzle(start: str, end: Optional[str]) -> str:
3169
+ if end is None:
3170
+ raise ValueError("Partial column configurations require the 'end' parameter.")
3171
+ if start[0] in end:
3172
+ raise ValueError(
3173
+ "The 'start' and 'end' parameters of a partial column configuration cannot be in the same row."
3174
+ )
3175
+ if start == "H1" or start == "H12":
3176
+ if "A" in end:
3177
+ raise ValueError(
3178
+ f"A partial column configuration with 'start'={start} cannot have its 'end' parameter be in row A. Use `ALL` configuration to utilize all nozzles."
3179
+ )
3180
+ elif start == "A1" or start == "A12":
3181
+ if "H" in end:
3182
+ raise ValueError(
3183
+ f"A partial column configuration with 'start'={start} cannot have its 'end' parameter be in row H. Use `ALL` configuration to utilize all nozzles."
3184
+ )
3185
+ return end
3186
+
3187
+
3188
+ def _raise_if_no_front_right_or_back_left_for_quadrant(
3189
+ front_right: Optional[str], back_left: Optional[str]
3190
+ ) -> None:
3191
+ if front_right is None and back_left is None:
3192
+ raise ValueError(
3193
+ "Cannot configure a QUADRANT layout without a front right or back left nozzle."
3194
+ )
3195
+
3196
+
3197
+ def _raise_if_has_end_nozzle_for_quadrant(end: Optional[str]) -> None:
3198
+ if end is not None:
3199
+ raise ValueError(
3200
+ "Parameter 'end' is not supported for QUADRANT configuration."
3201
+ " Use 'front_right' and 'back_left' arguments to specify the quadrant nozzle map instead."
3202
+ )
3203
+
3204
+
3205
+ def _raise_if_has_front_right_or_back_left_for_partial_column(
3206
+ front_right: Optional[str], back_left: Optional[str]
3207
+ ) -> None:
3208
+ if any([front_right, back_left]):
3209
+ raise ValueError(
3210
+ "Parameters 'front_right' and 'back_left' cannot be used with "
3211
+ "the PARTIAL_COLUMN configuration."
3212
+ )