diff --git a/api/src/opentrons/protocol_api/labware.py b/api/src/opentrons/protocol_api/labware.py index 1e26342b61e..480af5fd009 100644 --- a/api/src/opentrons/protocol_api/labware.py +++ b/api/src/opentrons/protocol_api/labware.py @@ -30,7 +30,6 @@ # remove when their usage is no longer needed from opentrons.protocols.labware import ( # noqa: F401 get_labware_definition as get_labware_definition, - get_all_labware_definitions as get_all_labware_definitions, verify_definition as verify_definition, save_definition as save_definition, ) diff --git a/api/src/opentrons/protocols/api_support/constants.py b/api/src/opentrons/protocols/api_support/constants.py index b350d970055..8da286acb62 100644 --- a/api/src/opentrons/protocols/api_support/constants.py +++ b/api/src/opentrons/protocols/api_support/constants.py @@ -4,5 +4,5 @@ OPENTRONS_NAMESPACE = "opentrons" CUSTOM_NAMESPACE = "custom_beta" -STANDARD_DEFS_PATH = Path("labware/definitions/2") +STANDARD_DEFS_PATH = Path("labware/definitions") USER_DEFS_PATH = get_opentrons_path("labware_user_definitions_dir_v2") diff --git a/api/src/opentrons/protocols/api_support/util.py b/api/src/opentrons/protocols/api_support/util.py index 3438692de2f..da4ceff7360 100644 --- a/api/src/opentrons/protocols/api_support/util.py +++ b/api/src/opentrons/protocols/api_support/util.py @@ -391,13 +391,3 @@ def _check_version_wrapper(*args: Any, **kwargs: Any) -> Any: return cast(FuncT, _check_version_wrapper) return _set_version - - -class ModifiedList(list[str]): - def __contains__(self, item: object) -> bool: - if not isinstance(item, str): - return False - for name in self: - if name == item.replace("-", "_").lower(): - return True - return False diff --git a/api/src/opentrons/protocols/labware.py b/api/src/opentrons/protocols/labware.py index 02f617fd72c..ed1b7d15219 100644 --- a/api/src/opentrons/protocols/labware.py +++ b/api/src/opentrons/protocols/labware.py @@ -2,14 +2,12 @@ import logging import json -import os from pathlib import Path -from typing import Any, AnyStr, List, Dict, Optional, Union +from typing import Any, AnyStr, Dict, Optional, Union import jsonschema # type: ignore -from opentrons.protocols.api_support.util import ModifiedList from opentrons_shared_data import load_shared_data, get_shared_data_root from opentrons.protocols.api_support.constants import ( OPENTRONS_NAMESPACE, @@ -63,29 +61,6 @@ def get_labware_definition( return _get_standard_labware_definition(load_name, namespace, version) -def get_all_labware_definitions() -> List[str]: - """ - Return a list of standard and custom labware definitions with load_name + - name_space + version existing on the robot - """ - labware_list = ModifiedList() - - def _check_for_subdirectories(path: Union[str, Path, os.DirEntry[str]]) -> None: - with os.scandir(path) as top_path: - for sub_dir in top_path: - if sub_dir.is_dir(): - labware_list.append(sub_dir.name) - - # check for standard labware - _check_for_subdirectories(get_shared_data_root() / STANDARD_DEFS_PATH) - - # check for custom labware - for namespace in os.scandir(USER_DEFS_PATH): - _check_for_subdirectories(namespace) - - return labware_list - - def save_definition( labware_def: LabwareDefinition, force: bool = False, location: Optional[Path] = None ) -> None: @@ -114,7 +89,6 @@ def save_definition( f'Saving definitions to the "{OPENTRONS_NAMESPACE}" namespace ' + "is not permitted" ) - def_path = _get_path_to_labware(load_name, namespace, version, location) if not force and def_path.is_file(): @@ -219,7 +193,6 @@ def _get_standard_labware_definition( Definitions Folder from the Opentrons App before uploading your protocol. """ - if namespace is None: for fallback_namespace in [OPENTRONS_NAMESPACE, CUSTOM_NAMESPACE]: try: @@ -252,9 +225,21 @@ def _get_path_to_labware( ) -> Path: if namespace == OPENTRONS_NAMESPACE: # all labware in OPENTRONS_NAMESPACE is stored in shared data - return ( - get_shared_data_root() / STANDARD_DEFS_PATH / load_name / f"{version}.json" + schema_3_path = ( + get_shared_data_root() + / STANDARD_DEFS_PATH + / "3" + / load_name + / f"{version}.json" + ) + schema_2_path = ( + get_shared_data_root() + / STANDARD_DEFS_PATH + / "2" + / load_name + / f"{version}.json" ) + return schema_3_path if schema_3_path.exists() else schema_2_path if not base_path: base_path = USER_DEFS_PATH def_path = base_path / namespace / load_name / f"{version}.json"