Skip to content

Commit

Permalink
Rename FastBuildRouter -> LightRouter.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Dec 21, 2024
1 parent 06bb3f6 commit 7eb4185
Show file tree
Hide file tree
Showing 26 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion robot-server/robot_server/client_data/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Annotated, Literal

import fastapi
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.client_data.store import (
ClientData,
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/commands/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Annotated, Final, List, Literal, Optional, cast

from fastapi import Depends, Query, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_engine import CommandIntent
from opentrons.protocol_engine.errors import CommandDoesNotExistError
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/data_files/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from fastapi import UploadFile, File, Form, Depends, Response, status
from opentrons.protocol_reader import FileHasher, FileReaderWriter
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.service.json_api import (
SimpleBody,
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/deck_configuration/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import fastapi
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons_shared_data.deck.types import DeckDefinitionV5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Annotated

import fastapi
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.service.json_api import PydanticResponse, RequestModel, SimpleBody
from .models import RequestData, ResponseData
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/instruments/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Annotated, Optional, Dict, List, cast

from fastapi import status, Depends
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.hardware_control.instruments.ot3.instrument_calibration import (
PipetteOffsetSummary,
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/labware_offsets/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Annotated, Literal

import fastapi
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_engine import LabwareOffset, LabwareOffsetCreate, ModuleModel
from opentrons.types import DeckSlotName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Maintenance Runs router."""
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from .base_router import base_router

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from fastapi import Depends, status
from pydantic import BaseModel, Field
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.errors.error_responses import ErrorDetails, ErrorBody
from robot_server.service.dependencies import get_current_time, get_unique_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing_extensions import Final, Literal

from fastapi import Depends, Query, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_engine import (
CommandPointer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging

from fastapi import Depends, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_engine import LabwareOffsetCreate, LabwareOffset
from opentrons.protocols.models import LabwareDefinition
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/modules/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Annotated, List, Dict

from fastapi import Depends, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.hardware_control import HardwareControlAPI
from opentrons.hardware_control.modules import module_calibration
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/protocols/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from fastapi.responses import PlainTextResponse
from pydantic import BaseModel, Field
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_reader import (
ProtocolReader,
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/robot/control/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Annotated, TYPE_CHECKING

from fastapi import status, Depends
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons_shared_data.robot.types import RobotType
from opentrons_shared_data.robot.types import RobotTypeEnum
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/robot/router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Router for /robot endpoints."""
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from .control.router import control_router

Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Application routes."""
from fastapi import Depends, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter


from .constants import V1_TAG
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/runs/router/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Runs router."""
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from .base_router import base_router
from .commands_router import commands_router
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/runs/router/actions_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Annotated, Literal, Union

from fastapi import Depends, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.errors.error_responses import ErrorDetails, ErrorBody
from robot_server.service.dependencies import get_current_time, get_unique_id
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/runs/router/base_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from fastapi import Depends, status, Query
from pydantic import BaseModel, Field
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter


from opentrons_shared_data.errors import ErrorCodes
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/runs/router/commands_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Annotated, Final, Literal, Optional, Union

from fastapi import Depends, Query, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_engine import (
CommandPointer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Annotated

from fastapi import status, Depends
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.errors.error_responses import ErrorBody
from robot_server.service.json_api.request import RequestModel
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/runs/router/labware_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LabwareDefinition as SD_LabwareDefinition,
)

from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons.protocol_engine import LabwareOffsetCreate, LabwareOffset
from opentrons.protocols.models import LabwareDefinition
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/service/labware/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing_extensions import Literal, NoReturn

from fastapi import Depends, status
from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from opentrons_shared_data.errors import ErrorCodes
from robot_server.errors.error_responses import ErrorDetails, ErrorBody
Expand Down
2 changes: 1 addition & 1 deletion robot-server/robot_server/subsystems/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fastapi import status, Depends, Response, Request
from typing_extensions import Literal

from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import FastBuildRouter

from robot_server.service.json_api import (
SimpleMultiBody,
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/system/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"""
from datetime import datetime

from server_utils.fastapi_utils.fast_build_router import FastBuildRouter
from server_utils.fastapi_utils.light_router import LightRouter

from robot_server.service.json_api.resource_links import ResourceLinkKey, ResourceLink

from .models import SystemTimeRequest, SystemTimeResponse, SystemTimeResponseAttributes
from .time_utils import get_system_time, set_system_time


system_router = FastBuildRouter()
system_router = LightRouter()
"""Router for /system endpoints."""


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""See the `FastBuildRouter` class."""
"""See the `LightRouter` class."""

from __future__ import annotations

Expand Down Expand Up @@ -64,20 +64,20 @@ class _FastAPIRouteMethods:
pass


class FastBuildRouter(_FastAPIRouteMethods):
"""An optimized drop-in replacement for `fastapi.APIRouter`.
class LightRouter(_FastAPIRouteMethods):
"""A lightweight drop-in replacement for `fastapi.APIRouter`.
Use it like `fastapi.APIRouter`:
foo_router = FastBuildRouter()
foo_router = LightRouter()
@router.get("/foo/{id}")
def get_health(id: str) -> Response:
...
bar_router = ...
root_router = FastBuildRouter()
root_router = LightRouter()
root_router.include_router(foo_router)
root_router.include_router(bar_router)
Expand Down Expand Up @@ -118,7 +118,7 @@ def __getattr__(self, name: str) -> object:

def include_router(
self,
router: FastBuildRouter | fastapi.APIRouter,
router: LightRouter | fastapi.APIRouter,
**kwargs: typing_extensions.Unpack[_RouterIncludeKwargs],
) -> None:
"""The optimized version of `fastapi.APIRouter.include_router()`.
Expand All @@ -142,7 +142,7 @@ def install_on_app(
combined_kwargs = _merge_kwargs(kwargs, route.inclusion_kwargs)
if isinstance(router, fastapi.APIRouter):
app.include_router(router, **combined_kwargs)
elif isinstance(route.router, FastBuildRouter):
elif isinstance(route.router, LightRouter):
router.install_on_app(app, **combined_kwargs)
else:
typing_extensions.assert_type(route, _Endpoint)
Expand Down Expand Up @@ -237,7 +237,7 @@ def _merge_kwargs(

@dataclasses.dataclass
class _IncludedRouter:
router: fastapi.APIRouter | FastBuildRouter
router: fastapi.APIRouter | LightRouter
inclusion_kwargs: _RouterIncludeKwargs


Expand Down

0 comments on commit 7eb4185

Please sign in to comment.