nemo_gym.rollout_correlation

View as Markdown

Module Contents

Classes

NameDescription
RolloutContextMiddlewareStrip a rollout prefix and expose it to downstream Gym calls for this request.

Functions

NameDescription
current_rollout_id-
maybe_rollout_id_from_run_bodyBuild the capture key for a run request.
rollout_context-

Data

ROLLOUT_ID_PATTERN

_ROLLOUT_ID

API

class nemo_gym.rollout_correlation.RolloutContextMiddleware(
app: typing.Any
)

Strip a rollout prefix and expose it to downstream Gym calls for this request.

_PREFIX
nemo_gym.rollout_correlation.RolloutContextMiddleware.__call__(
scope: dict[str, typing.Any],
receive: typing.Any,
send: typing.Any
) -> None
async
nemo_gym.rollout_correlation.current_rollout_id() -> typing.Optional[str]
nemo_gym.rollout_correlation.maybe_rollout_id_from_run_body(
body: pydantic.BaseModel | collections.abc.Mapping[str, typing.Any] | None
) -> typing.Optional[str]

Build the capture key for a run request.

An explicit _ng_rollout_id takes precedence. Otherwise derive "{task}-{rollout}" from the task and rollout indices. Re-dispatch attempts append -a{n}. Writers and consumers must use this same identity. Reused task and rollout indices produce a repeated capture key. Use an explicit id when numbering restarts across dispatches.

nemo_gym.rollout_correlation.rollout_context(
rollout_id: typing.Optional[str]
) -> collections.abc.Iterator[None]
nemo_gym.rollout_correlation.ROLLOUT_ID_PATTERN = re.compile('^[A-Za-z0-9][A-Za-z0-9._-]*$')
nemo_gym.rollout_correlation._ROLLOUT_ID: ContextVar[Optional[str]] = ContextVar('nemo_gym_rollout_id', default=None)