Skip to content

Commit

Permalink
Merge branch 'edge' into pd_flex_main
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-sancheti committed Apr 13, 2023
2 parents df31a44 + 44daef5 commit 26f9ca4
Show file tree
Hide file tree
Showing 183 changed files with 1,972 additions and 1,097 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/api-test-lint-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
with:
python-version: ${{ matrix.python }}
- name: 'set complex environment variables'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
with:
python-version: '3.7'
- name: 'set complex environment variables'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/app-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down Expand Up @@ -220,7 +220,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install libudev-dev libsystemd-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/components-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
node-version: '16'
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
with:
project: 'api'
- name: 'set complex environment variables'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/g-code-testing-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
node-version: '16'
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/js-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
node-version: '16'
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ll-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pd-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/shared-data-test-lint-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
project: 'shared-data/python'
python-version: ${{ matrix.python }}
- name: 'set complex environment variables'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
with:
project: 'shared-data/python'
- name: 'set complex environment variables'
uses: actions/github-script@v6.1.1
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
Expand Down
16 changes: 14 additions & 2 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
create_tip_action_group,
PipetteAction,
sub_system_to_node_id,
NODEID_SUBSYSTEM,
USBTARGET_SUBSYSTEM,
)

try:
Expand Down Expand Up @@ -112,6 +114,7 @@
UpdateStatus,
mount_to_subsystem,
DoorState,
OT3SubSystem,
)
from opentrons.hardware_control.errors import (
MustHomeError,
Expand Down Expand Up @@ -244,9 +247,18 @@ def initialized(self, value: bool) -> None:
self._initialized = value

@property
def fw_version(self) -> Optional[str]:
def fw_version(self) -> Dict[OT3SubSystem, int]:
"""Get the firmware version."""
return None
subsystem_map: Dict[Union[NodeId, USBTarget], OT3SubSystem] = deepcopy(
cast(Dict[Union[NodeId, USBTarget], OT3SubSystem], USBTARGET_SUBSYSTEM)
)
subsystem_map.update(
cast(Dict[Union[NodeId, USBTarget], OT3SubSystem], NODEID_SUBSYSTEM)
)
return {
subsystem_map[node.application_for()]: device.version
for node, device in self._network_info.device_info.items()
}

@property
def update_required(self) -> bool:
Expand Down
8 changes: 6 additions & 2 deletions api/src/opentrons/hardware_control/backends/ot3simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
create_gripper_jaw_home_group,
create_tip_action_group,
PipetteAction,
NODEID_SUBSYSTEM,
)

from opentrons_hardware.firmware_bindings.constants import (
Expand All @@ -56,6 +57,7 @@
MotorStatus,
PipetteSubType,
UpdateStatus,
OT3SubSystem,
)
from opentrons_hardware.hardware_control.motion import MoveStopCondition
from opentrons_hardware.hardware_control import status_bar
Expand Down Expand Up @@ -483,9 +485,11 @@ def axis_bounds(self) -> OT3AxisMap[Tuple[float, float]]:
}

@property
def fw_version(self) -> Optional[str]:
def fw_version(self) -> Dict[OT3SubSystem, int]:
"""Get the firmware version."""
return None
return {
NODEID_SUBSYSTEM[node.application_for()]: 0 for node in self._present_nodes
}

@property
def update_required(self) -> bool:
Expand Down
20 changes: 20 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
PipetteType,
SensorId,
PipetteTipActionType,
USBTarget,
)
from opentrons_hardware.firmware_update.types import FirmwareUpdateStatus, StatusElement
from opentrons_hardware.hardware_control.motion_planning import (
Expand Down Expand Up @@ -68,6 +69,25 @@
OT3SubSystem.gripper: NodeId.gripper,
}

NODEID_SUBSYSTEM: Dict[NodeId, OT3SubSystem] = {
NodeId.gantry_x: OT3SubSystem.gantry_x,
NodeId.gantry_x_bootloader: OT3SubSystem.gantry_x,
NodeId.gantry_y: OT3SubSystem.gantry_y,
NodeId.gantry_y_bootloader: OT3SubSystem.gantry_y,
NodeId.head: OT3SubSystem.head,
NodeId.head_bootloader: OT3SubSystem.head,
NodeId.pipette_left: OT3SubSystem.pipette_left,
NodeId.pipette_left_bootloader: OT3SubSystem.pipette_left,
NodeId.pipette_right: OT3SubSystem.pipette_right,
NodeId.pipette_right_bootloader: OT3SubSystem.pipette_right,
NodeId.gripper: OT3SubSystem.gripper,
NodeId.gripper_bootloader: OT3SubSystem.gripper,
}

USBTARGET_SUBSYSTEM: Dict[USBTarget, OT3SubSystem] = {
USBTarget.rear_panel: OT3SubSystem.rear_panel
}


def axis_nodes() -> List["NodeId"]:
return [
Expand Down
5 changes: 3 additions & 2 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,11 @@ def get_fw_version(self) -> str:
Return the firmware version of the connected hardware.
"""
from_backend = self._backend.fw_version
if from_backend is None:
uniques = set(version for version in from_backend.values())
if not from_backend:
return "unknown"
else:
return from_backend
return ", ".join(str(version) for version in uniques)

@property
def fw_version(self) -> str:
Expand Down
11 changes: 11 additions & 0 deletions api/src/opentrons/protocol_engine/clients/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ def execute_command(self, request: CommandCreate) -> CommandResult:
error = command.error
raise ProtocolEngineError(f"{error.errorType}: {error.detail}")

# FIXME(mm, 2023-04-10): This assert can easily trigger from this sequence:
#
# 1. The engine is paused.
# 2. The user's Python script calls this method to start a new command,
# which remains `queued` because of the pause.
# 3. The engine is stopped.
#
# The returned command will be `queued`, so it won't have a result.
#
# We need to figure out a proper way to report this condition to callers
# so they correctly interpret it as an intentional stop, not an internal error.
assert command.result is not None, f"Expected Command {command} to have result"

return command.result
Expand Down
26 changes: 15 additions & 11 deletions api/src/opentrons/protocol_engine/execution/queue_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,24 @@ async def join(self) -> None:

try:
await worker_task
except (RunStoppedError, asyncio.CancelledError):
except asyncio.CancelledError: # From self.cancel().
pass
except Exception as e:
log.error("Unhandled exception in QueueWorker job", exc_info=e)
raise e

async def _run_commands(self) -> None:
while not self._state_store.commands.get_stop_requested():
command_id = await self._state_store.wait_for(
condition=self._state_store.commands.get_next_queued
)

await self._command_executor.execute(command_id=command_id)

# Yield to the event loop in case we're executing a long run of commands
# that never yields internally. For example, a long run of comment commands.
await asyncio.sleep(0)
while True:
try:
command_id = await self._state_store.wait_for(
condition=self._state_store.commands.get_next_to_execute
)
except RunStoppedError:
# There are no more commands that we should execute, either because the run has
# completed on its own, or because a client requested it to stop.
break
else:
await self._command_executor.execute(command_id=command_id)
# Yield to the event loop in case we're executing a long sequence of commands
# that never yields internally. For example, a long sequence of comment commands.
await asyncio.sleep(0)
13 changes: 9 additions & 4 deletions api/src/opentrons/protocol_engine/protocol_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ def add_command(self, request: commands.CommandCreate) -> commands.Command:
return self._state_store.commands.get(command_id)

async def wait_for_command(self, command_id: str) -> None:
"""Wait for a command to be completed."""
"""Wait for a command to be completed.
Will also return if the engine was stopped before it reached the command.
"""
await self._state_store.wait_for(
self._state_store.commands.get_is_complete,
self._state_store.commands.get_command_is_final,
command_id=command_id,
)

Expand All @@ -185,7 +188,9 @@ async def add_and_execute_command(
the command in state.
Returns:
The completed command, whether it succeeded or failed.
The command. If the command completed, it will be succeeded or failed.
If the engine was stopped before it reached the command,
the command will be queued.
"""
command = self.add_command(request)
await self.wait_for_command(command.id)
Expand All @@ -211,7 +216,7 @@ async def wait_until_complete(self) -> None:
CommandExecutionFailedError: if any protocol command failed.
"""
await self._state_store.wait_for(
condition=self._state_store.commands.get_all_complete
condition=self._state_store.commands.get_all_commands_final
)

async def finish(
Expand Down
Loading

0 comments on commit 26f9ca4

Please sign in to comment.