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

feat(api): allow ungrip gripper labware while door is open #16394

Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4aaaeb4
unsafe ungrip and get next command WIP
TamarZanzouri Sep 30, 2024
472540f
commands init and linting
TamarZanzouri Sep 30, 2024
b43e17c
docstring and playing with fixit commands
TamarZanzouri Sep 30, 2024
65d1f1e
removed check from ungrip
TamarZanzouri Oct 1, 2024
10ee57a
commands schema and logic in validate action
TamarZanzouri Oct 1, 2024
117596f
fixed confition to raise fixit commands
TamarZanzouri Oct 1, 2024
09703e8
removed comments
TamarZanzouri Oct 1, 2024
62e1a88
added tests
TamarZanzouri Oct 1, 2024
6f6b27d
linting and tests
TamarZanzouri Oct 1, 2024
5d5cc13
raise if no gripper attached
TamarZanzouri Oct 2, 2024
48e0bd4
remove print
TamarZanzouri Oct 2, 2024
722ebc1
gripper instrument
TamarZanzouri Oct 2, 2024
e1d66e6
Merge branch 'edge' into EXEC-734-allow-the-gripper-to-be-opened-whil…
TamarZanzouri Oct 2, 2024
5ede81a
command schema 10
TamarZanzouri Oct 2, 2024
b55da53
error message and removed not ER door statue
TamarZanzouri Oct 2, 2024
9cc14e9
linting
TamarZanzouri Oct 2, 2024
5b49230
Merge branch 'edge' into EXEC-734-allow-the-gripper-to-be-opened-whil…
SyntaxColoring Oct 4, 2024
4e7f5eb
Revert changes to schema 9.
SyntaxColoring Oct 4, 2024
0f74ded
Typo.
SyntaxColoring Oct 4, 2024
ecc63db
Merge branch 'edge' into EXEC-734-allow-the-gripper-to-be-opened-whil…
SyntaxColoring Oct 4, 2024
94c0589
Various readability refactors, per feedback.
SyntaxColoring Oct 4, 2024
9056123
Fix test?
SyntaxColoring Oct 4, 2024
f4562bc
Update test_door_ungrip_labware().
SyntaxColoring Oct 5, 2024
d792ca6
make format-js
SyntaxColoring Oct 5, 2024
b9a6797
Minor simplification.
SyntaxColoring Oct 5, 2024
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
Prev Previous commit
Next Next commit
Update test_door_ungrip_labware().
  • Loading branch information
SyntaxColoring committed Oct 5, 2024
commit f4562bc69b02f716a4112e660e74837fcbbe5e76
76 changes: 35 additions & 41 deletions api/tests/opentrons/protocol_engine/state/test_command_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,9 @@ def test_door_during_error_recovery() -> None:
assert subject.state.failed_command_errors == [expected_error_occurance]


def test_door_ungrip_labware() -> None:
"""Test behavior when the door is opened during error recovery ungrip."""
@pytest.mark.parametrize("close_door_before_queueing", [False, True])
def test_door_ungrip_labware(close_door_before_queueing: bool) -> None:
"""Ungrip commands should be able to run even when the door is open."""
subject = CommandStore(
is_door_open=False,
error_recovery_policy=_placeholder_error_recovery_policy,
Expand All @@ -572,68 +573,61 @@ def test_door_ungrip_labware() -> None:
subject_view = CommandView(subject.state)

# Fail a command to put the subject in recovery mode.
queue_1 = actions.QueueCommandAction(
queue_failing = actions.QueueCommandAction(
request=commands.CommentCreate(
params=commands.CommentParams(message=""), key="command-key-1"
),
request_hash=None,
created_at=datetime(year=2021, month=1, day=1),
command_id="command-id-1",
command_id="failing-command-id",
)
subject.handle_action(queue_1)
run_1 = actions.RunCommandAction(
command_id="command-id-1",
subject.handle_action(queue_failing)
run_failing = actions.RunCommandAction(
command_id="failing-command-id",
started_at=datetime(year=2022, month=2, day=2),
)
subject.handle_action(run_1)
subject.handle_action(run_failing)
expected_error = errors.ProtocolEngineError(message="oh no")
expected_error_occurance = errors.ErrorOccurrence(
id="error-id",
errorType="ProtocolEngineError",
createdAt=datetime(year=2023, month=3, day=3),
detail="oh no",
errorCode=ErrorCodes.GENERAL_ERROR.value.code,
)
fail_1 = actions.FailCommandAction(
command_id="command-id-1",
running_command=subject_view.get("command-id-1"),
fail_failing = actions.FailCommandAction(
command_id="failing-command-id",
running_command=subject_view.get("failing-command-id"),
error_id="error-id",
failed_at=datetime(year=2023, month=3, day=3),
error=expected_error,
notes=[],
type=ErrorRecoveryType.WAIT_FOR_RECOVERY,
)
subject.handle_action(fail_1)
subject.handle_action(fail_failing)

queue_2 = actions.QueueCommandAction(
# Open the door:
subject.handle_action(actions.DoorChangeAction(DoorState.OPEN))
assert (
subject_view.get_status() == EngineStatus.AWAITING_RECOVERY_BLOCKED_BY_OPEN_DOOR
)
assert subject_view.get_next_to_execute() is None

if close_door_before_queueing:
subject.handle_action(actions.DoorChangeAction(DoorState.CLOSED))

assert subject_view.get_status() in (
EngineStatus.AWAITING_RECOVERY_PAUSED, # If we closed the door.
EngineStatus.AWAITING_RECOVERY_BLOCKED_BY_OPEN_DOOR, # If we didn't.
)

# Make sure the special ungrip command can be queued and that it will be returned
# as next to execute:
queue_fixit = actions.QueueCommandAction(
request=commands.unsafe.UnsafeUngripLabwareCreate(
params=commands.unsafe.UnsafeUngripLabwareParams(),
intent=CommandIntent.FIXIT,
),
request_hash=None,
created_at=datetime(year=2021, month=1, day=1),
command_id="command-id-2",
command_id="fixit-command-id",
)
subject.handle_action(queue_2)
assert subject_view.get_status() == EngineStatus.AWAITING_RECOVERY
assert subject_view.get_next_to_execute() == "command-id-2"

# Test state after we open the door:
subject.handle_action(actions.DoorChangeAction(DoorState.OPEN))
assert (
subject_view.get_status() == EngineStatus.AWAITING_RECOVERY_BLOCKED_BY_OPEN_DOOR
)
assert subject_view.get_next_to_execute() == "command-id-2"
play = actions.PlayAction(requested_at=datetime.now())
action = subject_view.validate_action_allowed(play)

assert action == play

# Test state when we resume recovery mode:
subject.handle_action(play)
assert subject_view.get_status() == EngineStatus.AWAITING_RECOVERY
assert subject_view.get_next_to_execute() == "command-id-2"
assert subject.state.failed_command_errors == [expected_error_occurance]
subject_view.validate_action_allowed(queue_fixit)
subject.handle_action(queue_fixit)
assert subject_view.get_next_to_execute() == "fixit-command-id"


@pytest.mark.parametrize(
Expand Down
Loading