feat: enable remote SDK and resilient device orchestration
This commit is contained in:
1 parent
3cc711df51
commit
ddfa420945
110 files changed
+14450
-12954
No files matched your search
@@ -146,6 +146,7 @@ async def run_task(
|
||||
target_serial = device_serial
|
||||
|
||||
try:
|
||||
from artemis.config import settings
|
||||
from artemis.sdk import Agent
|
||||
from artemis.sdk.builders import Builders
|
||||
from artemis.sdk.types import AgentProfile
|
||||
|
||||
@@ -92,6 +92,13 @@ def _reconcile_task_state(
|
||||
pid = status_data.get("pid")
|
||||
dirty = False
|
||||
|
||||
# "success" is a legacy alias for the canonical "completed" terminal
|
||||
# status; consumers of this reconcile must only ever see "completed".
|
||||
if current_status == "success":
|
||||
current_status = "completed"
|
||||
status_data["status"] = "completed"
|
||||
dirty = True
|
||||
|
||||
db_status: str | None = None
|
||||
db_pid: int | None = None
|
||||
db_path = _find_data_engine_db()
|
||||
|
||||
@@ -137,28 +137,14 @@ def _validate_device_serial(device_serial: str) -> dict[str, Any] | None:
|
||||
"""
|
||||
try:
|
||||
from artemis.runtime import device_pool
|
||||
from artemis.runtime.device_lock import DeviceExecutionLock
|
||||
|
||||
norm = DeviceExecutionLock._normalize_device_id
|
||||
attached = {norm(d.serial): d.state for d in device_pool.list_devices()}
|
||||
# The shared validator fails open on an indeterminate/empty enumeration:
|
||||
# the task proceeds and fails downstream with a clear no-device error.
|
||||
detail = device_pool.validate_explicit_serial(device_serial)
|
||||
except Exception:
|
||||
return None
|
||||
if not attached:
|
||||
# Enumeration unavailable (no adb / transient failure): let the task
|
||||
# proceed and fail downstream with a clear no-device error instead.
|
||||
if detail is None:
|
||||
return None
|
||||
|
||||
dev_state = attached.get(norm(device_serial))
|
||||
if dev_state == "device":
|
||||
return None
|
||||
|
||||
if dev_state is None:
|
||||
detail = (
|
||||
f"Device '{device_serial}' is not connected. "
|
||||
f"Attached devices: {sorted(attached) if attached else 'none'}."
|
||||
)
|
||||
else:
|
||||
detail = f"Device '{device_serial}' is attached but not ready (state: '{dev_state}')."
|
||||
return {
|
||||
"status": "failed",
|
||||
"error": detail,
|
||||
|
||||
@@ -113,6 +113,11 @@ def update_trace_status(
|
||||
if not data:
|
||||
return None
|
||||
|
||||
# "success" is a legacy alias for the canonical "completed" terminal
|
||||
# status and must never be persisted into status.json.
|
||||
if status == "success":
|
||||
status = "completed"
|
||||
|
||||
data["status"] = status
|
||||
if status in ("completed", "failed", "cancelled"):
|
||||
data["end_time"] = time.time()
|
||||
|
||||
Reference in new issue
Block a user