Skip to content

Commit 873e375

Browse files
feat(robot-server): Add skeleton for /labwareOffsets routes (#17051)
1 parent 704d32c commit 873e375

File tree

3 files changed

+141
-1
lines changed

3 files changed

+141
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Endpoints for storing and retrieving labware offsets."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"""FastAPI endpoint functions for the `/labwareOffsets` endpoints."""
2+
3+
4+
import textwrap
5+
from typing import Annotated, Literal
6+
7+
import fastapi
8+
from opentrons.protocol_engine import LabwareOffset, LabwareOffsetCreate
9+
10+
from robot_server.service.json_api.request import RequestModel
11+
from robot_server.service.json_api.response import (
12+
PydanticResponse,
13+
SimpleBody,
14+
SimpleEmptyBody,
15+
SimpleMultiBody,
16+
)
17+
18+
19+
router = fastapi.APIRouter(prefix="/labwareOffsets")
20+
21+
22+
@PydanticResponse.wrap_route(
23+
router.post,
24+
path="",
25+
summary="Store a labware offset",
26+
description=textwrap.dedent(
27+
"""\
28+
Store a labware offset for later retrieval through `GET /labwareOffsets`.
29+
30+
On its own, this does not affect robot motion.
31+
To do that, you must add the offset to a run, through the `/runs` endpoints.
32+
"""
33+
),
34+
)
35+
def post_labware_offset( # noqa: D103
36+
new_offset: Annotated[RequestModel[LabwareOffsetCreate], fastapi.Body()]
37+
) -> PydanticResponse[SimpleEmptyBody]:
38+
raise NotImplementedError()
39+
40+
41+
@PydanticResponse.wrap_route(
42+
router.get,
43+
path="",
44+
summary="Search for labware offsets",
45+
description=(
46+
"Get a filtered list of all the labware offsets currently stored on the robot."
47+
" Filters are ANDed together."
48+
" Results are returned in order from oldest to newest."
49+
),
50+
)
51+
def get_labware_offsets( # noqa: D103
52+
id: Annotated[
53+
str | None,
54+
fastapi.Query(description="Filter for exact matches on the `id` field."),
55+
] = None,
56+
definition_uri: Annotated[
57+
str | None,
58+
fastapi.Query(
59+
alias="definitionUri",
60+
description=(
61+
"Filter for exact matches on the `definitionUri` field."
62+
" (Not to be confused with `location.definitionUri`.)"
63+
),
64+
),
65+
] = None,
66+
location_slot_name: Annotated[
67+
str | None,
68+
fastapi.Query(
69+
alias="location.slotName",
70+
description="Filter for exact matches on the `location.slotName` field.",
71+
),
72+
] = None,
73+
location_module_model: Annotated[
74+
str | None,
75+
fastapi.Query(
76+
alias="location.moduleModel",
77+
description="Filter for exact matches on the `location.moduleModel` field.",
78+
),
79+
] = None,
80+
location_definition_uri: Annotated[
81+
str | None,
82+
fastapi.Query(
83+
alias="location.definitionUri",
84+
description=(
85+
"Filter for exact matches on the `location.definitionUri` field."
86+
" (Not to be confused with just `definitionUri`.)"
87+
),
88+
),
89+
] = None,
90+
cursor: Annotated[
91+
int | None,
92+
fastapi.Query(
93+
description=(
94+
"The first index to return out of the overall filtered result list."
95+
" If unspecified, defaults to returning `pageLength` elements from"
96+
" the end of the list."
97+
)
98+
),
99+
] = None,
100+
page_length: Annotated[
101+
int | Literal["unlimited"],
102+
fastapi.Query(
103+
alias="pageLength", description="The maximum number of entries to return."
104+
),
105+
] = "unlimited",
106+
) -> PydanticResponse[SimpleMultiBody[LabwareOffset]]:
107+
raise NotImplementedError()
108+
109+
110+
@PydanticResponse.wrap_route(
111+
router.delete,
112+
path="/{id}",
113+
summary="Delete a single labware offset",
114+
description="Delete a single labware offset. The deleted offset is returned.",
115+
)
116+
def delete_labware_offset( # noqa: D103
117+
id: Annotated[
118+
str,
119+
fastapi.Path(description="The `id` field of the offset to delete."),
120+
],
121+
) -> PydanticResponse[SimpleBody[LabwareOffset]]:
122+
raise NotImplementedError()
123+
124+
125+
@PydanticResponse.wrap_route(
126+
router.delete,
127+
path="",
128+
summary="Delete all labware offsets",
129+
)
130+
def delete_all_labware_offsets() -> PydanticResponse[SimpleEmptyBody]: # noqa: D103
131+
raise NotImplementedError()

robot-server/robot_server/router.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
from .client_data.router import router as client_data_router
99
from .commands.router import commands_router
10+
from .data_files.router import datafiles_router
1011
from .deck_configuration.router import router as deck_configuration_router
1112
from .error_recovery.settings.router import router as error_recovery_settings_router
1213
from .health.router import health_router
1314
from .instruments.router import instruments_router
15+
from .labware_offsets.router import router as labware_offset_router
1416
from .maintenance_runs.router import maintenance_runs_router
1517
from .modules.router import modules_router
1618
from .protocols.router import protocols_router
17-
from .data_files.router import datafiles_router
1819
from .robot.router import robot_router
1920
from .runs.router import runs_router
2021
from .service.labware.router import router as labware_router
@@ -55,6 +56,12 @@
5556
dependencies=[Depends(check_version_header)],
5657
)
5758

59+
router.include_router(
60+
router=labware_offset_router,
61+
tags=["Labware Offset Management"],
62+
dependencies=[Depends(check_version_header)],
63+
)
64+
5865
router.include_router(
5966
router=runs_router,
6067
tags=["Run Management"],
@@ -78,6 +85,7 @@
7885
tags=["Data files Management"],
7986
dependencies=[Depends(check_version_header)],
8087
)
88+
8189
router.include_router(
8290
router=commands_router,
8391
tags=["Simple Commands"],

0 commit comments

Comments
 (0)