-
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.
- Loading branch information
Showing
50 changed files
with
1,332 additions
and
1,761 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
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
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
28 changes: 27 additions & 1 deletion
28
api/src/opentrons/protocol_engine/commands/command_mapper.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,5 +1,31 @@ | ||
"""Map command request and model types to other values.""" | ||
from datetime import datetime | ||
from typing import Any | ||
|
||
from .command import CommandStatus | ||
from .command_unions import Command, CommandRequest | ||
|
||
|
||
class CommandMapper: | ||
pass | ||
"""Static methods to map and modify command models.""" | ||
|
||
@staticmethod | ||
def map_request_to_command( | ||
request: CommandRequest, | ||
command_id: str, | ||
created_at: datetime, | ||
) -> Command: | ||
"""Map a CommandRequest instance to a full command.""" | ||
# NOTE(mc, 2021-06-22): mypy has trouble with this automatic | ||
# request > command routing, but behavior is covered by unit tests | ||
return request._CommandCls( | ||
id=command_id, | ||
createdAt=created_at, | ||
status=CommandStatus.QUEUED, | ||
data=request.data, # type: ignore[arg-type] | ||
) | ||
|
||
@staticmethod | ||
def update_command(command: Command, **update: Any) -> Command: | ||
"""Map a Command to a new Command instance with a different status.""" | ||
return command.copy(update=update) |
Oops, something went wrong.