Skip to content

Commit 5e7f450

Browse files
dont default file version to 1.json
1 parent 204abed commit 5e7f450

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

api/src/opentrons/protocols/labware.py

+23-18
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def _get_standard_labware_definition(
240240
)
241241

242242
namespace = namespace.lower()
243-
def_path = _get_path_to_labware(load_name, namespace, checked_version)
243+
def_path = _get_path_to_labware(load_name, namespace, version)
244244

245245
try:
246246
with open(def_path, "rb") as f:
@@ -254,26 +254,31 @@ def _get_standard_labware_definition(
254254

255255

256256
def _get_path_to_labware(
257-
load_name: str, namespace: str, version: int, base_path: Optional[Path] = None
257+
load_name: str,
258+
namespace: str,
259+
version: Optional[int] = None,
260+
base_path: Optional[Path] = None,
258261
) -> Path:
259262
if namespace == OPENTRONS_NAMESPACE:
260263
# all labware in OPENTRONS_NAMESPACE is stored in shared data
261-
schema_3_path = (
262-
get_shared_data_root()
263-
/ STANDARD_DEFS_PATH
264-
/ "3"
265-
/ load_name
266-
/ f"{version}.json"
267-
)
268-
schema_2_path = (
269-
get_shared_data_root()
270-
/ STANDARD_DEFS_PATH
271-
/ "2"
272-
/ load_name
273-
/ f"{version}.json"
274-
)
275-
return schema_3_path if schema_3_path.exists() else schema_2_path
264+
schema_3_dir = get_shared_data_root() / STANDARD_DEFS_PATH / "3" / load_name
265+
if schema_3_dir.exists():
266+
schema_3_files = os.listdir(schema_3_dir)
267+
version_filename = f"{version}.json" if version else max(schema_3_files)
268+
schema_3_path = schema_3_dir / version_filename
269+
return schema_3_path
270+
else:
271+
version_filename = f"{version}.json" if version else "1.json"
272+
schema_2_path = (
273+
get_shared_data_root()
274+
/ STANDARD_DEFS_PATH
275+
/ "2"
276+
/ load_name
277+
/ f"{version_filename}.json"
278+
)
279+
return schema_2_path
276280
if not base_path:
277281
base_path = USER_DEFS_PATH
278-
def_path = base_path / namespace / load_name / f"{version}.json"
282+
version_filename = f"{version}.json" if version else "1.json"
283+
def_path = base_path / namespace / load_name / f"{version_filename}.json"
279284
return def_path

0 commit comments

Comments
 (0)