-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shared-data): add robot definitions (#11428)
Add some quick and small json files that can represent kinds of robot, primarily as a thing for other files to reference. Closes RCORE-126
- Loading branch information
Showing
9 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
shared-data/python/opentrons_shared_data/robot/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""opentrons_shared_data.robot: Submodule for handling robot definition data.""" | ||
from pathlib import Path | ||
from typing import cast | ||
from typing_extensions import Final | ||
|
||
import json | ||
|
||
from .. import get_shared_data_root | ||
|
||
from .dev_types import RobotDefinition, RobotName | ||
|
||
DEFAULT_ROBOT_DEFINITION_VERSION: Final = 1 | ||
|
||
|
||
def load( | ||
robot_name: RobotName, version: int = DEFAULT_ROBOT_DEFINITION_VERSION | ||
) -> RobotDefinition: | ||
"""Load the definition for the specified robot id.""" | ||
for fi in Path( | ||
get_shared_data_root() / "robot" / "definitions" / f"{version}" | ||
).iterdir(): | ||
defn = json.load(fi.open("r")) | ||
if defn["robotName"] == robot_name: | ||
return cast(RobotDefinition, defn) | ||
raise KeyError(robot_name) |
17 changes: 17 additions & 0 deletions
17
shared-data/python/opentrons_shared_data/robot/dev_types.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""opentrons_shared_data.robot.dev_types: types for robot def.""" | ||
from typing import NewType, List, Dict, Any | ||
from typing_extensions import Literal, TypedDict | ||
|
||
RobotSchemaVersion1 = Literal[1] | ||
|
||
RobotSchema = NewType("RobotSchema", Dict[str, Any]) | ||
|
||
RobotName = Literal["OT-2 Standard", "OT-3 Standard"] | ||
|
||
|
||
class RobotDefinition(TypedDict): | ||
"""A python version of the robot definition type.""" | ||
|
||
displayName: str | ||
robotName: RobotName | ||
models: List[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import sys | ||
|
||
import pytest | ||
import typeguard | ||
|
||
|
||
from opentrons_shared_data.robot import load | ||
from opentrons_shared_data.robot.dev_types import RobotDefinition, RobotName | ||
|
||
pytestmark = pytest.mark.xfail( | ||
condition=sys.version_info >= (3, 10), | ||
reason="https://github.com/agronholm/typeguard/issues/242", | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("defname", ["OT-2 Standard", "OT-3 Standard"]) | ||
def test_v1_defs(defname: RobotName) -> None: | ||
defn = load(robot_name=defname, version=1) | ||
typeguard.check_type("defn", defn, RobotDefinition) | ||
assert defn["robotName"] == defname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"displayName": "OT-2", | ||
"robotName": "OT-2 Standard", | ||
"models": ["OT-2 Standard", "OT-2 Refresh"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"displayName": "OT-3", | ||
"robotName": "OT-3 Standard", | ||
"models": ["OT-3 Standard"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"$id": "opentronsRobotSchemaV1", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"robotName": { | ||
"type": "string", | ||
"enum": ["OT-2 Standard", "OT-3 Standard"] | ||
} | ||
}, | ||
"description": "Describes an Opentrons liquid handling robot.", | ||
"type": "object", | ||
"required": ["displayName", "robotName", "models"], | ||
"properties": { | ||
"displayName": { | ||
"description": "A user-facing friendly name for the machine.", | ||
"type": "string" | ||
}, | ||
"robotName": { | ||
"description": "A machine-readable but still printable name for the machine.", | ||
"type": "#/definitions/robotName" | ||
}, | ||
"models": { | ||
"description": "A list of robot models.", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |