Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(robot-server): Reuse existing TypeAdapter for Command #17144

Open
wants to merge 1 commit into
base: edge
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions robot-server/robot_server/runs/run_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
CommandErrorSlice,
CommandStatus,
)
from opentrons.protocol_engine.commands import Command
from opentrons.protocol_engine.commands import Command, CommandAdapter
from opentrons.protocol_engine.types import RunTimeParameter

from opentrons_shared_data.errors.exceptions import (
Expand Down Expand Up @@ -51,6 +51,8 @@

_CACHE_ENTRIES = 32

_rtp_list_adapter = TypeAdapter(list[RunTimeParameter])


@dataclass(frozen=True)
class RunResource:
Expand Down Expand Up @@ -828,13 +830,9 @@ def _convert_state_to_sql_values(
}


_command_type_adapter: TypeAdapter[Command] = TypeAdapter(Command)
_rtp_list_adapter = TypeAdapter(list[RunTimeParameter])


def _parse_command(json_str: str) -> Command:
"""Parse a JSON string from the database into a `Command`."""
return json_to_pydantic(_command_type_adapter, json_str)
return json_to_pydantic(CommandAdapter, json_str)


def _convert_commands_status_to_sql_command_status(
Expand Down