Skip to navigation

nemo_gym.token_id_capture.control_routes

View as Markdown

Expose rollout capture manifests and ledger removal over HTTP.

The training framework reads one manifest for each rollout. The endpoint returns call metadata and does not read staged token data. The framework builds receipts and removes staged data after use. It then retires the rollout’s ledger, which Gym cannot otherwise know is no longer needed.

Module Contents

Classes

NameDescription
LedgerBatchRequestBody of the retire and delete routes.
RolloutControlClientFramework-side client for the manifest, retire, and delete routes.

Functions

NameDescription
install_rollout_control_routesInstall the bearer-protected manifest, retire, and delete routes.

Data

CONTROL_ROUTE_PREFIX

MAX_LEDGER_BATCH

API

class nemo_gym.token_id_capture.control_routes.LedgerBatchRequest()

Bases: BaseModel

Body of the retire and delete routes.

model_config
= ConfigDict(extra='forbid')
rollout_ids
list[str] = Field(min_length=1, max_length=MAX_LEDGER_BATCH)
class nemo_gym.token_id_capture.control_routes.RolloutControlClient(
base_url: str,
auth_token: str,
request_timeout_s: float
)

Framework-side client for the manifest, retire, and delete routes.

_base_url
= base_url.rstrip('/')
_headers
= {'Authorization': f'Bearer {auth_token}'}
nemo_gym.token_id_capture.control_routes.RolloutControlClient._remove(
action: str,
rollout_ids: collections.abc.Sequence[str]
async
nemo_gym.token_id_capture.control_routes.RolloutControlClient._request(
method: str,
path: str,
kwargs: typing.Any = {}
)
async
nemo_gym.token_id_capture.control_routes.RolloutControlClient.delete(
rollout_ids: collections.abc.Sequence[str]
async

Delete ledgers and their fences; see CaptureLedger.delete. Retrying after a failure is safe.

nemo_gym.token_id_capture.control_routes.RolloutControlClient.manifest(
rollout_id: str
async

Fetch a rollout’s manifest. A retired rollout raises RolloutRetiredError.

nemo_gym.token_id_capture.control_routes.RolloutControlClient.retire(
rollout_ids: collections.abc.Sequence[str]
async

Retire ledgers; see CaptureLedger.retire. Retrying after a failure is safe.

nemo_gym.token_id_capture.control_routes.install_rollout_control_routes(
app: typing.Any,
auth_token: str,
refuse_removal: collections.abc.Callable[[], str | None] | None = None
) -> None

Install the bearer-protected manifest, retire, and delete routes.

refuse_removal returns a reason to refuse retire and delete for now, with 409; the caller retries later.

nemo_gym.token_id_capture.control_routes.CONTROL_ROUTE_PREFIX = '/training-token-capture/control'
nemo_gym.token_id_capture.control_routes.MAX_LEDGER_BATCH = 4096