armnet-runtime 0.3.3__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/PKG-INFO +2 -2
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/pyproject.toml +2 -2
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/context.py +89 -11
- armnet_runtime-0.3.4/tests/test_completion.py +134 -0
- armnet_runtime-0.3.3/tests/test_completion.py +0 -37
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/.gitignore +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/LICENSE +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/README.md +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/proto/rerun.proto +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/scripts/gen_proto.sh +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/__init__.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/_rerun_pb2.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/cli.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/decorator.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/depth_view.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/env.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/leaderboard.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/__init__.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/_remote_protocol.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/_robot_link.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/import_swap.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_arx5.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_camera.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_feetech.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/remote_yam.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/so101.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/yam.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/markers.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/rerun.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/variation.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/volume_sync.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_armnet_robots.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_cell_instrument.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_confirm_scene_reset.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_context_arms.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_context_camera_mounts.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_depth_view.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_edge_goal_clamp.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_embodiment.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_leaderboard.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_persistent_connection.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_proxy_method_cache.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_rail_recovery.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_rail_reset_restore.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_remote_yam.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_robot_telemetry.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_scene_calibration_context.py +0 -0
- {armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/tests/test_variation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: armnet-runtime
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: armnet runtime SDK — used by code running inside customer containers on a cell.
|
|
5
5
|
Project-URL: Homepage, https://armnet.dev
|
|
6
6
|
Project-URL: Documentation, https://docs.armnet.dev/packages/runtime/
|
|
@@ -8,7 +8,7 @@ Author: Ville Kuosmanen
|
|
|
8
8
|
License-Expression: Apache-2.0
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Python: <3.13,>=3.12
|
|
11
|
-
Requires-Dist: armnet-core>=0.3.
|
|
11
|
+
Requires-Dist: armnet-core>=0.3.3
|
|
12
12
|
Requires-Dist: protobuf<7,>=5
|
|
13
13
|
Requires-Dist: pydantic<3,>=2.6
|
|
14
14
|
Provides-Extra: dev
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
name = "armnet-runtime"
|
|
7
7
|
# 0.2.0 follows armnet-core: ctx.cell now carries an environment and hands
|
|
8
8
|
# reset/scoring to it, and CompletionStatus moved to armnet-core.
|
|
9
|
-
version = "0.3.
|
|
9
|
+
version = "0.3.4"
|
|
10
10
|
description = "armnet runtime SDK \u2014 used by code running inside customer containers on a cell."
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.12,<3.13"
|
|
@@ -15,7 +15,7 @@ license-files = ["LICENSE"]
|
|
|
15
15
|
authors = [{ name = "Ville Kuosmanen" }]
|
|
16
16
|
|
|
17
17
|
dependencies = [
|
|
18
|
-
"armnet-core>=0.3.
|
|
18
|
+
"armnet-core>=0.3.3",
|
|
19
19
|
"pydantic>=2.6,<3",
|
|
20
20
|
# Wire format for Rerun visualization packets (armnet_runtime.rerun).
|
|
21
21
|
"protobuf>=5,<7",
|
|
@@ -122,6 +122,15 @@ _ROBOT_TELEMETRY_READ_TIMEOUT_S = 1.0
|
|
|
122
122
|
# Throttle interval for teleop-channel error logs (they'd otherwise repeat at
|
|
123
123
|
# the control-loop rate while the channel is down).
|
|
124
124
|
_TELEOP_ERROR_LOG_INTERVAL_S = 5.0
|
|
125
|
+
# The monitor's verdict is in memory on the connector, so a per-tick poll that
|
|
126
|
+
# takes longer than this is treated as "not decided yet" rather than stalling
|
|
127
|
+
# the control loop.
|
|
128
|
+
_COMPLETION_READ_TIMEOUT_S = 1.0
|
|
129
|
+
# The final, blocking completion check is the episode's score, so a transient
|
|
130
|
+
# network failure (a slow name lookup, a dropped connection) is retried rather
|
|
131
|
+
# than failing the episode.
|
|
132
|
+
_FINAL_COMPLETION_ATTEMPTS = 3
|
|
133
|
+
_FINAL_COMPLETION_RETRY_DELAY_S = 1.0
|
|
125
134
|
|
|
126
135
|
|
|
127
136
|
@dataclass
|
|
@@ -218,6 +227,14 @@ class RuntimeRail(_CellDevice):
|
|
|
218
227
|
# job may be running somewhere else entirely (job_position), so keep both:
|
|
219
228
|
# this one is what a varied position is measured against.
|
|
220
229
|
default_position: float = 0.5
|
|
230
|
+
# The last 0-1 position commanded to this carriage through
|
|
231
|
+
# ``_set_rail_targets`` — job start, between-episode reset, or per-episode
|
|
232
|
+
# variation. Every positioning path funnels through that one call, and reset
|
|
233
|
+
# runs before variation, so this is the per-episode "commanded truth"
|
|
234
|
+
# recorded beside the episode. Initialised to ``job_position`` in
|
|
235
|
+
# ``_build_runtime_rails`` so a rail positioned only at job start (no runtime
|
|
236
|
+
# move yet) still reports correctly; updated on every move.
|
|
237
|
+
last_commanded_position: float = 0.5
|
|
221
238
|
|
|
222
239
|
def set(self, position: float) -> None:
|
|
223
240
|
"""Move this rail alone to ``position`` (0..1) and wait until settled.
|
|
@@ -383,6 +400,10 @@ class Cell:
|
|
|
383
400
|
# the cell program's operator-call endpoint (see is_complete).
|
|
384
401
|
_completion_conn: Any = field(default=None, init=False, repr=False, compare=False)
|
|
385
402
|
_completion_last_error_log: float = field(default=0.0, init=False, repr=False, compare=False)
|
|
403
|
+
# Reused connection for polling the automated completion monitor on the
|
|
404
|
+
# robot connector (see is_complete).
|
|
405
|
+
_monitor_conn: Any = field(default=None, init=False, repr=False, compare=False)
|
|
406
|
+
_monitor_last_error_log: float = field(default=0.0, init=False, repr=False, compare=False)
|
|
386
407
|
# Most-recent completion outcome seen during the current rollout, plus an
|
|
387
408
|
# optional sink (installed by Context.init_leaderboard) that records each
|
|
388
409
|
# rollout's cell-scored outcome. Kept here so rollout_end can record the
|
|
@@ -798,6 +819,10 @@ class Cell:
|
|
|
798
819
|
raise RuntimeError("robot connector is unavailable; cannot position rail")
|
|
799
820
|
for rail, raw_target in targets:
|
|
800
821
|
target = max(0.0, min(1.0, float(raw_target)))
|
|
822
|
+
# Record the commanded position before the move so the episode saved
|
|
823
|
+
# after this carries the fraction the carriage was driven to, even if
|
|
824
|
+
# the move itself raises partway through.
|
|
825
|
+
rail.last_commanded_position = target
|
|
801
826
|
request: dict[str, Any] = {
|
|
802
827
|
"op": "rail_set",
|
|
803
828
|
"pos": target,
|
|
@@ -1021,12 +1046,45 @@ class Cell:
|
|
|
1021
1046
|
raise RuntimeError(response.get("error", "local completion check failed"))
|
|
1022
1047
|
return _completion_from_response(response)
|
|
1023
1048
|
if self.robot_port and _looks_like_connector_endpoint(self.robot_port):
|
|
1024
|
-
|
|
1049
|
+
if block:
|
|
1050
|
+
response = _final_completion_request(self.robot_port, request)
|
|
1051
|
+
else:
|
|
1052
|
+
response = self._poll_completion_monitor(request)
|
|
1053
|
+
if response is None:
|
|
1054
|
+
return CompletionStatus(complete=False, success=False)
|
|
1025
1055
|
if not response.get("ok"):
|
|
1026
1056
|
raise RuntimeError(response.get("error", "cell completion check failed"))
|
|
1027
1057
|
return _completion_from_response(response)
|
|
1028
1058
|
return CompletionStatus(complete=False, success=False)
|
|
1029
1059
|
|
|
1060
|
+
def _poll_completion_monitor(self, request: dict[str, Any]) -> Optional[dict[str, Any]]:
|
|
1061
|
+
"""The monitor's current verdict, or None when it could not be read.
|
|
1062
|
+
|
|
1063
|
+
Polled every control tick, so it holds one connection open: opening one
|
|
1064
|
+
per tick looks the connector's host name up again each time, and a
|
|
1065
|
+
single failed lookup would end the episode. An unread verdict counts as
|
|
1066
|
+
"not decided yet", and the final blocking check asks again.
|
|
1067
|
+
"""
|
|
1068
|
+
|
|
1069
|
+
endpoint = self.robot_port
|
|
1070
|
+
if self._monitor_conn is None or self._monitor_conn.endpoint != endpoint:
|
|
1071
|
+
if self._monitor_conn is not None:
|
|
1072
|
+
self._monitor_conn.close()
|
|
1073
|
+
self._monitor_conn = _TeleopConnection(endpoint, timeout=_COMPLETION_READ_TIMEOUT_S)
|
|
1074
|
+
|
|
1075
|
+
try:
|
|
1076
|
+
return self._monitor_conn.request(request)
|
|
1077
|
+
except Exception as exc: # noqa: BLE001
|
|
1078
|
+
now = time.monotonic()
|
|
1079
|
+
if now - self._monitor_last_error_log >= _TELEOP_ERROR_LOG_INTERVAL_S:
|
|
1080
|
+
self._monitor_last_error_log = now
|
|
1081
|
+
logger.warning(
|
|
1082
|
+
"completion check on %s failed (treating as not complete): %r",
|
|
1083
|
+
endpoint,
|
|
1084
|
+
exc,
|
|
1085
|
+
)
|
|
1086
|
+
return None
|
|
1087
|
+
|
|
1030
1088
|
def _human_completion(self) -> Optional[bool]:
|
|
1031
1089
|
"""Return the operator's reported success/fail, or None if none pending.
|
|
1032
1090
|
|
|
@@ -1355,6 +1413,22 @@ def _connector_request(
|
|
|
1355
1413
|
return json.loads(data.decode("utf-8"))
|
|
1356
1414
|
|
|
1357
1415
|
|
|
1416
|
+
def _final_completion_request(endpoint: str, request: dict[str, Any]) -> dict[str, Any]:
|
|
1417
|
+
for attempt in range(1, _FINAL_COMPLETION_ATTEMPTS):
|
|
1418
|
+
try:
|
|
1419
|
+
return _connector_request(endpoint, request)
|
|
1420
|
+
except OSError as exc:
|
|
1421
|
+
logger.warning(
|
|
1422
|
+
"final completion check on %s failed (attempt %d of %d), retrying: %r",
|
|
1423
|
+
endpoint,
|
|
1424
|
+
attempt,
|
|
1425
|
+
_FINAL_COMPLETION_ATTEMPTS,
|
|
1426
|
+
exc,
|
|
1427
|
+
)
|
|
1428
|
+
time.sleep(_FINAL_COMPLETION_RETRY_DELAY_S)
|
|
1429
|
+
return _connector_request(endpoint, request)
|
|
1430
|
+
|
|
1431
|
+
|
|
1358
1432
|
def _connect_connector(endpoint: str) -> socket.socket:
|
|
1359
1433
|
if endpoint.startswith("tcp://"):
|
|
1360
1434
|
parsed = urlparse(endpoint)
|
|
@@ -1882,6 +1956,11 @@ def _build_runtime_rails(
|
|
|
1882
1956
|
) from exc
|
|
1883
1957
|
if cell_config.rail is not None:
|
|
1884
1958
|
rail = cell_config.rail
|
|
1959
|
+
job_position = (
|
|
1960
|
+
override
|
|
1961
|
+
if override is not None
|
|
1962
|
+
else _rail_fraction(rail.default_position_percent)
|
|
1963
|
+
)
|
|
1885
1964
|
return (
|
|
1886
1965
|
RuntimeRail(
|
|
1887
1966
|
servo_id=int(rail.servo_id),
|
|
@@ -1889,11 +1968,8 @@ def _build_runtime_rails(
|
|
|
1889
1968
|
left_dir=int(rail.left_dir),
|
|
1890
1969
|
home_end=str(getattr(rail, "home_end", "right")),
|
|
1891
1970
|
default_position=_rail_fraction(rail.default_position_percent),
|
|
1892
|
-
job_position=
|
|
1893
|
-
|
|
1894
|
-
if override is not None
|
|
1895
|
-
else _rail_fraction(rail.default_position_percent)
|
|
1896
|
-
),
|
|
1971
|
+
job_position=job_position,
|
|
1972
|
+
last_commanded_position=job_position,
|
|
1897
1973
|
),
|
|
1898
1974
|
)
|
|
1899
1975
|
rails: list[RuntimeRail] = []
|
|
@@ -1901,6 +1977,11 @@ def _build_runtime_rails(
|
|
|
1901
1977
|
arm_rail = getattr(arm, "rail", None)
|
|
1902
1978
|
if arm_rail is None:
|
|
1903
1979
|
continue
|
|
1980
|
+
job_position = (
|
|
1981
|
+
override
|
|
1982
|
+
if override is not None
|
|
1983
|
+
else _rail_fraction(arm_rail.default_position_percent)
|
|
1984
|
+
)
|
|
1904
1985
|
rails.append(
|
|
1905
1986
|
RuntimeRail(
|
|
1906
1987
|
servo_id=int(arm_rail.servo_id),
|
|
@@ -1909,11 +1990,8 @@ def _build_runtime_rails(
|
|
|
1909
1990
|
home_end=str(getattr(arm_rail, "home_end", "right")),
|
|
1910
1991
|
arm=arm_name,
|
|
1911
1992
|
default_position=_rail_fraction(arm_rail.default_position_percent),
|
|
1912
|
-
job_position=
|
|
1913
|
-
|
|
1914
|
-
if override is not None
|
|
1915
|
-
else _rail_fraction(arm_rail.default_position_percent)
|
|
1916
|
-
),
|
|
1993
|
+
job_position=job_position,
|
|
1994
|
+
last_commanded_position=job_position,
|
|
1917
1995
|
)
|
|
1918
1996
|
)
|
|
1919
1997
|
return tuple(rails)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""CompletionStatus return shape for ctx.cell.is_complete()."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import socket
|
|
6
|
+
from typing import Any, ClassVar
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from armnet_runtime import CompletionStatus
|
|
10
|
+
from armnet_runtime import context as context_module
|
|
11
|
+
from armnet_runtime.context import Cell, _completion_from_response
|
|
12
|
+
|
|
13
|
+
_NAME_LOOKUP_FAILED = socket.gaierror(-3, "Temporary failure in name resolution")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_completion_status_unpacks_into_complete_and_success():
|
|
17
|
+
complete, success, scored_by = CompletionStatus(True, False, "operator")
|
|
18
|
+
assert complete is True
|
|
19
|
+
assert success is False
|
|
20
|
+
assert scored_by == "operator"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_completion_status_truthy_iff_complete():
|
|
24
|
+
# `if ctx.cell.is_complete():` keys off `complete` only.
|
|
25
|
+
assert bool(CompletionStatus(True, False)) is True
|
|
26
|
+
assert bool(CompletionStatus(False, True)) is False
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_the_completion_monitor_treats_a_finished_task_as_a_success():
|
|
30
|
+
# The monitor watches for the task being done and has no separate opinion
|
|
31
|
+
# on whether it went well, so success follows completion.
|
|
32
|
+
assert _completion_from_response({"complete": True}) == CompletionStatus(True, True, "monitor")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_an_unfinished_episode_names_no_judge():
|
|
36
|
+
# Nothing decided it, so there is nobody to credit.
|
|
37
|
+
assert _completion_from_response({"complete": False}) == CompletionStatus(False, False, None)
|
|
38
|
+
assert _completion_from_response({}) == CompletionStatus(False, False, None)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_an_explicit_failure_survives_the_success_default():
|
|
42
|
+
assert _completion_from_response({"complete": True, "success": False}) == CompletionStatus(
|
|
43
|
+
True, False, "monitor"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class _MonitorConnection:
|
|
48
|
+
"""Stands in for the connector socket; ``replies`` are returned or raised in turn."""
|
|
49
|
+
|
|
50
|
+
opened: ClassVar[list[_MonitorConnection]] = []
|
|
51
|
+
replies: ClassVar[list[Any]] = []
|
|
52
|
+
|
|
53
|
+
def __init__(self, endpoint: str, *, timeout: float) -> None:
|
|
54
|
+
self.endpoint = endpoint
|
|
55
|
+
self.timeout = timeout
|
|
56
|
+
self.requests: list[dict[str, Any]] = []
|
|
57
|
+
_MonitorConnection.opened.append(self)
|
|
58
|
+
|
|
59
|
+
def request(self, payload: dict[str, Any]) -> dict[str, Any]:
|
|
60
|
+
self.requests.append(payload)
|
|
61
|
+
reply = _MonitorConnection.replies.pop(0)
|
|
62
|
+
if isinstance(reply, Exception):
|
|
63
|
+
raise reply
|
|
64
|
+
return reply
|
|
65
|
+
|
|
66
|
+
def close(self) -> None:
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@pytest.fixture
|
|
71
|
+
def monitor(monkeypatch: pytest.MonkeyPatch) -> type[_MonitorConnection]:
|
|
72
|
+
_MonitorConnection.opened = []
|
|
73
|
+
_MonitorConnection.replies = []
|
|
74
|
+
monkeypatch.setattr(context_module, "_TeleopConnection", _MonitorConnection)
|
|
75
|
+
return _MonitorConnection
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_polling_the_monitor_reuses_one_connection(monitor):
|
|
79
|
+
# A connection per tick looks the connector's host name up on every tick.
|
|
80
|
+
monitor.replies = [{"ok": True, "complete": False}] * 2 + [{"ok": True, "complete": True}]
|
|
81
|
+
cell = Cell(robot_port="tcp://raspberrypi-04:9876")
|
|
82
|
+
|
|
83
|
+
assert not cell.is_complete()
|
|
84
|
+
assert not cell.is_complete()
|
|
85
|
+
assert cell.is_complete() == CompletionStatus(True, True, "monitor")
|
|
86
|
+
|
|
87
|
+
(connection,) = monitor.opened
|
|
88
|
+
assert connection.endpoint == "tcp://raspberrypi-04:9876"
|
|
89
|
+
assert connection.requests == [{"op": "is_complete", "block": False}] * 3
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_a_failed_poll_counts_as_not_decided_rather_than_ending_the_episode(monitor):
|
|
93
|
+
monitor.replies = [_NAME_LOOKUP_FAILED, {"ok": True, "complete": True}]
|
|
94
|
+
cell = Cell(robot_port="tcp://raspberrypi-04:9876")
|
|
95
|
+
|
|
96
|
+
assert cell.is_complete() == CompletionStatus(False, False)
|
|
97
|
+
assert cell.is_complete() == CompletionStatus(True, True, "monitor")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_the_final_check_retries_a_failed_name_lookup(monkeypatch: pytest.MonkeyPatch):
|
|
101
|
+
replies: list[Any] = [_NAME_LOOKUP_FAILED, {"ok": True, "complete": True, "success": False}]
|
|
102
|
+
sent: list[dict[str, Any]] = []
|
|
103
|
+
|
|
104
|
+
def connector_request(endpoint: str, payload: dict[str, Any], **_: Any) -> dict[str, Any]:
|
|
105
|
+
sent.append(payload)
|
|
106
|
+
reply = replies.pop(0)
|
|
107
|
+
if isinstance(reply, Exception):
|
|
108
|
+
raise reply
|
|
109
|
+
return reply
|
|
110
|
+
|
|
111
|
+
monkeypatch.setattr(context_module, "_connector_request", connector_request)
|
|
112
|
+
monkeypatch.setattr(context_module.time, "sleep", lambda _seconds: None)
|
|
113
|
+
|
|
114
|
+
status = Cell(robot_port="tcp://raspberrypi-04:9876").is_complete(block=True)
|
|
115
|
+
|
|
116
|
+
assert status == CompletionStatus(True, False, "monitor")
|
|
117
|
+
assert sent == [{"op": "is_complete", "block": True}] * 2
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_the_final_check_gives_up_when_the_connector_stays_unreachable(
|
|
121
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
122
|
+
):
|
|
123
|
+
attempts: list[str] = []
|
|
124
|
+
|
|
125
|
+
def connector_request(endpoint: str, payload: dict[str, Any], **_: Any) -> dict[str, Any]:
|
|
126
|
+
attempts.append(endpoint)
|
|
127
|
+
raise _NAME_LOOKUP_FAILED
|
|
128
|
+
|
|
129
|
+
monkeypatch.setattr(context_module, "_connector_request", connector_request)
|
|
130
|
+
monkeypatch.setattr(context_module.time, "sleep", lambda _seconds: None)
|
|
131
|
+
|
|
132
|
+
with pytest.raises(socket.gaierror):
|
|
133
|
+
Cell(robot_port="tcp://raspberrypi-04:9876").is_complete(block=True)
|
|
134
|
+
assert len(attempts) == 3
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"""CompletionStatus return shape for ctx.cell.is_complete()."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from armnet_runtime import CompletionStatus
|
|
6
|
-
from armnet_runtime.context import _completion_from_response
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_completion_status_unpacks_into_complete_and_success():
|
|
10
|
-
complete, success, scored_by = CompletionStatus(True, False, "operator")
|
|
11
|
-
assert complete is True
|
|
12
|
-
assert success is False
|
|
13
|
-
assert scored_by == "operator"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_completion_status_truthy_iff_complete():
|
|
17
|
-
# `if ctx.cell.is_complete():` keys off `complete` only.
|
|
18
|
-
assert bool(CompletionStatus(True, False)) is True
|
|
19
|
-
assert bool(CompletionStatus(False, True)) is False
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def test_the_completion_monitor_treats_a_finished_task_as_a_success():
|
|
23
|
-
# The monitor watches for the task being done and has no separate opinion
|
|
24
|
-
# on whether it went well, so success follows completion.
|
|
25
|
-
assert _completion_from_response({"complete": True}) == CompletionStatus(True, True, "monitor")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def test_an_unfinished_episode_names_no_judge():
|
|
29
|
-
# Nothing decided it, so there is nobody to credit.
|
|
30
|
-
assert _completion_from_response({"complete": False}) == CompletionStatus(False, False, None)
|
|
31
|
-
assert _completion_from_response({}) == CompletionStatus(False, False, None)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def test_an_explicit_failure_survives_the_success_default():
|
|
35
|
-
assert _completion_from_response({"complete": True, "success": False}) == CompletionStatus(
|
|
36
|
-
True, False, "monitor"
|
|
37
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{armnet_runtime-0.3.3 → armnet_runtime-0.3.4}/src/armnet_runtime/lerobot/_remote_protocol.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|