-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(api): Ensure we handle state updates even for failed commands (
- Loading branch information
1 parent
1e7577e
commit ae463ff
Showing
4 changed files
with
89 additions
and
107 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
18 changes: 18 additions & 0 deletions
18
api/src/opentrons/protocol_engine/actions/get_state_update.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# noqa: D100 | ||
|
||
|
||
from .actions import Action, SucceedCommandAction, FailCommandAction | ||
from ..commands.command import DefinedErrorData | ||
from ..state.update_types import StateUpdate | ||
|
||
|
||
def get_state_update(action: Action) -> StateUpdate | None: | ||
"""Extract the StateUpdate from an action, if there is one.""" | ||
if isinstance(action, SucceedCommandAction): | ||
return action.state_update | ||
elif isinstance(action, FailCommandAction) and isinstance( | ||
action.error, DefinedErrorData | ||
): | ||
return action.error.state_update | ||
else: | ||
return None |
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