55from typing import Dict , List , cast
66
77from pylabrobot .resources import Coordinate , Tip , TipRack , TipSpot
8+ from pylabrobot .resources .carrier import PlateHolder
89from pylabrobot .resources .resource_holder import ResourceHolder
910from pylabrobot .resources .tube_rack import TubeRack
1011
@@ -26,7 +27,10 @@ def _download_ot_resource_file(ot_name: str, force_download: bool):
2627 The labware definition as a dictionary.
2728 """
2829 url = f"https://raw.githubusercontent.com/Opentrons/opentrons/5b51a98ce736b2bb5aff780bf3fdf91941a038fa/shared-data/labware/definitions/2/{ ot_name } /1.json"
29- path = f"/tmp/{ ot_name } .json"
30+ if os .path .exists ("/tmp" ):
31+ path = f"/tmp/{ ot_name } .json" # only works with linux/mac systems
32+ else :
33+ path = f"C:/Windows/Temp/{ ot_name } .json"
3034 if force_download or not os .path .exists (path ):
3135 data = _download_file (url = url , local_path = path )
3236 else :
@@ -147,3 +151,27 @@ def load_ot_tube_rack(
147151 ordered_items = cast (Dict [str , ResourceHolder ], ordered_items ),
148152 model = data ["metadata" ]["displayName" ],
149153 )
154+
155+
156+ def load_ot_plate_holder (
157+ ot_name : str , plr_resource_name : str , z_offset : float , force_download : bool = False
158+ ) -> PlateHolder :
159+ """Convert an Opentrons adapter definition file to a PyLabRobot PlateHolder resource."""
160+
161+ data = _download_ot_resource_file (ot_name = ot_name , force_download = force_download )
162+
163+ display_category = data ["metadata" ]["displayCategory" ]
164+ if display_category not in {"adapter" , "aluminumBlock" }:
165+ raise ValueError ("Not a plate adapter definition file." )
166+
167+ location = data ["cornerOffsetFromSlot" ]
168+
169+ return PlateHolder (
170+ name = plr_resource_name ,
171+ size_x = data ["dimensions" ]["xDimension" ],
172+ size_y = data ["dimensions" ]["yDimension" ],
173+ size_z = data ["dimensions" ]["zDimension" ],
174+ child_location = Coordinate (location ["x" ], location ["y" ], z_offset ),
175+ pedestal_size_z = 0 ,
176+ model = data ["metadata" ]["displayName" ],
177+ )
0 commit comments