-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(robot-server): Robot server protocol session model (#6371)
* ProtocolSessionEvent model created * rename ProtocolCommandExecutor.commands to events. * unit tests for protocol command executer * use timestamp instead of startedAt and completedAt. add '.start' to before and '.end' to after event. * generate unique ids for protocol sourced events * use utc_now * who knew that the 'text' field in the payload of a command could be a format string using the other keys in payload closes #6225
- Loading branch information
amitlissack
authored
Aug 19, 2020
1 parent
516783a
commit 973ee18
Showing
5 changed files
with
264 additions
and
32 deletions.
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
31 changes: 27 additions & 4 deletions
31
robot-server/robot_server/service/session/session_types/protocol/models.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 |
---|---|---|
@@ -1,9 +1,32 @@ | ||
import typing | ||
from pydantic import BaseModel | ||
from datetime import datetime | ||
from enum import Enum | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class EventSource(str, Enum): | ||
session_command = "sessionCommand" | ||
protocol_event = "protocol" | ||
|
||
|
||
class ProtocolSessionEvent(BaseModel): | ||
"""An event occurring during a protocol session""" | ||
source: EventSource = \ | ||
Field(..., description="Initiator of this event") | ||
event: str = \ | ||
Field(..., description="The event that occurred") | ||
timestamp: datetime | ||
commandId: typing.Optional[str] = None | ||
params: typing.Optional[typing.Dict[str, typing.Any]] = None | ||
result: typing.Optional[str] = None | ||
|
||
|
||
class ProtocolSessionDetails(BaseModel): | ||
protocolId: str | ||
protocolId: str = \ | ||
Field(..., | ||
description="The protocol used by this session") | ||
currentState: typing.Optional[str] | ||
# TODO: Amit 8/3/2020 - proper schema for command types | ||
commands: typing.List[typing.Any] | ||
events: typing.List[ProtocolSessionEvent] =\ | ||
Field(..., | ||
description="The events that have occurred thus far") |
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
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
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