feat: add Polygon UI-0 run view
This commit is contained in:
@@ -78,14 +78,23 @@ class QualificationRunStore:
|
||||
exclusive filesystem semantics and fsynced before acknowledgement.
|
||||
"""
|
||||
|
||||
def __init__(self, root: Path) -> None:
|
||||
self.root = root.expanduser().resolve()
|
||||
self.root.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
_reject_symlink(self.root, "qualification repository")
|
||||
_chmod_private(self.root)
|
||||
def __init__(self, root: Path, *, read_only: bool = False) -> None:
|
||||
configured_root = root.expanduser()
|
||||
if read_only:
|
||||
if not configured_root.is_dir():
|
||||
raise QualificationRunIntegrityError("qualification repository is missing")
|
||||
_reject_symlink(configured_root, "qualification repository")
|
||||
self.root = configured_root.resolve()
|
||||
else:
|
||||
self.root = configured_root.resolve()
|
||||
self.root.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
_reject_symlink(self.root, "qualification repository")
|
||||
_chmod_private(self.root)
|
||||
self.read_only = read_only
|
||||
self._lock = threading.RLock()
|
||||
|
||||
def create(self, run: QualificationRun) -> QualificationRun:
|
||||
self._require_writable()
|
||||
if (
|
||||
run.state is not RunState.ADMITTED
|
||||
or run.revision != 0
|
||||
@@ -152,6 +161,7 @@ class QualificationRunStore:
|
||||
sim_time_ns: int | None = None,
|
||||
reason: str | None = None,
|
||||
) -> QualificationRun:
|
||||
self._require_writable()
|
||||
with self._lock:
|
||||
current = self.load(run_id)
|
||||
if current.revision != expected_revision:
|
||||
@@ -193,6 +203,7 @@ class QualificationRunStore:
|
||||
sim_time_ns: int | None = None,
|
||||
expected_revision: int | None = None,
|
||||
) -> QualificationEvent:
|
||||
self._require_writable()
|
||||
if event_type == "lifecycle.state-changed":
|
||||
raise QualificationRunTransitionError("lifecycle events must use transition()")
|
||||
with self._lock:
|
||||
@@ -215,6 +226,7 @@ class QualificationRunStore:
|
||||
)
|
||||
|
||||
def submit_command(self, command: ControlSetpoint) -> ControlSetpoint:
|
||||
self._require_writable()
|
||||
with self._lock:
|
||||
run = self.load(command.run_id)
|
||||
if run.kind not in COMMANDABLE_RUN_KINDS:
|
||||
@@ -267,6 +279,7 @@ class QualificationRunStore:
|
||||
run_id: str,
|
||||
artifact: QualificationArtifact,
|
||||
) -> QualificationArtifact:
|
||||
self._require_writable()
|
||||
with self._lock:
|
||||
run = self.load(run_id)
|
||||
if run.state.terminal:
|
||||
@@ -304,6 +317,7 @@ class QualificationRunStore:
|
||||
episode_id: str,
|
||||
created_at_utc: str,
|
||||
) -> QualificationRun:
|
||||
self._require_writable()
|
||||
previous = self.load(previous_run_id)
|
||||
if not previous.state.terminal:
|
||||
raise QualificationRunTransitionError(
|
||||
@@ -338,6 +352,7 @@ class QualificationRunStore:
|
||||
observed_at_utc: str,
|
||||
host_monotonic_ns: int,
|
||||
) -> QualificationRun:
|
||||
self._require_writable()
|
||||
run = self.load(run_id)
|
||||
if run.state not in ACTIVE_RECOVERY_STATES:
|
||||
return run
|
||||
@@ -446,6 +461,12 @@ class QualificationRunStore:
|
||||
_reject_symlink(directory, f"run {name} journal")
|
||||
return path
|
||||
|
||||
def _require_writable(self) -> None:
|
||||
if self.read_only:
|
||||
raise QualificationRunTransitionError(
|
||||
"the qualification repository is open read-only"
|
||||
)
|
||||
|
||||
|
||||
def _replay_runtime(
|
||||
manifest: QualificationRun,
|
||||
|
||||
Reference in New Issue
Block a user