Bind the metered owner route to worker leases and sandbox lifecycle
Some checks failed
Governed runtime contract / contract (push) Failing after 23s
Some checks failed
Governed runtime contract / contract (push) Failing after 23s
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a07ff8-19d0-7820-b4d0-1353833cb7fc
This commit is contained in:
parent
c30806b968
commit
3e4c976090
13 changed files with 502 additions and 9 deletions
|
|
@ -10,6 +10,7 @@ from __future__ import annotations
|
|||
|
||||
import math
|
||||
from collections.abc import Callable
|
||||
from contextlib import nullcontext
|
||||
from typing import Any
|
||||
|
||||
from rein_aharness.execution_cancel import ExecutionCancel, ExecutionCancelled, resolve_cancel
|
||||
|
|
@ -175,6 +176,11 @@ def execute_profiled_run(
|
|||
request = request_factory(**_request_kwargs(run, config, report_to_hub))
|
||||
kwargs = {"artifact_capture": transfer.capture} if transfer else {}
|
||||
spend = worker_spend(config)
|
||||
owner = config.messages_owner
|
||||
if config.require_request_admission and owner is None:
|
||||
raise SpendAdmissionError("required request owner is not configured")
|
||||
if owner is not None and (spend is None or guard is None):
|
||||
raise SpendAdmissionError("request owner requires spend and cancellation")
|
||||
if spend is not None:
|
||||
from glas_harness.profiles import ProfileCatalog
|
||||
catalog = ProfileCatalog()
|
||||
|
|
@ -186,7 +192,11 @@ def execute_profiled_run(
|
|||
if guard is not None:
|
||||
guard.check()
|
||||
spend.reserve(run)
|
||||
result = gateway(request, **kwargs)
|
||||
route = owner.activate(run, config, spend, profile, guard) if owner else nullcontext(None)
|
||||
with route as owner_manager:
|
||||
if owner_manager is not None:
|
||||
kwargs["manager"] = owner_manager
|
||||
result = gateway(request, **kwargs)
|
||||
raw = result.model_dump(mode="json") if hasattr(result, "model_dump") else result
|
||||
except ExecutionCancelled:
|
||||
raise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue