Skip to content

Commit

Permalink
fixed confition to raise fixit commands
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Oct 1, 2024
1 parent 10ee57a commit 117596f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
13 changes: 9 additions & 4 deletions api/src/opentrons/protocol_engine/state/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,8 @@ def validate_action_allowed( # noqa: C901
return action

elif isinstance(action, QueueCommandAction):
print(self.get_status())
print(action.request.commandType)
if (
action.request.intent == CommandIntent.SETUP
and self._state.queue_status != QueueStatus.SETUP
Expand All @@ -975,14 +977,17 @@ def validate_action_allowed( # noqa: C901
"Setup commands are not allowed after run has started."
)
elif action.request.intent == CommandIntent.FIXIT:
if (
self._state.queue_status != QueueStatus.AWAITING_RECOVERY
or self.get_status()
allowed_while_door_open = (
self.get_status()
in (
EngineStatus.BLOCKED_BY_OPEN_DOOR,
EngineStatus.AWAITING_RECOVERY_BLOCKED_BY_OPEN_DOOR,
)
and action.request.commandType != "unsafe/ungripLabware"
and action.request.commandType == "unsafe/ungripLabware"
)
if (
self._state.queue_status != QueueStatus.AWAITING_RECOVERY
and not allowed_while_door_open
):
raise FixitCommandNotAllowedError(
"Fixit commands are not allowed when the run is not in a recoverable state."
Expand Down
15 changes: 15 additions & 0 deletions api/tests/opentrons/protocol_engine/state/test_command_view_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,21 @@ class ActionAllowedSpec(NamedTuple):
action=ResumeFromRecoveryAction(),
expected_error=errors.ResumeFromRecoveryNotAllowedError,
),
ActionAllowedSpec(
subject=get_command_view(
queue_status=QueueStatus.PAUSED, is_door_blocking=True
),
action=QueueCommandAction(
request=cmd.unsafe.UnsafeUngripLabwareCreate(
params=cmd.unsafe.UnsafeUngripLabwareParams(),
intent=cmd.CommandIntent.FIXIT,
),
request_hash=None,
command_id="command-id",
created_at=datetime(year=2021, month=1, day=1),
),
expected_error=None,
),
]


Expand Down

0 comments on commit 117596f

Please sign in to comment.