nemo_gym.telemetry.resources_operations
nemo_gym.telemetry.resources_operations
A shared way for resources servers to report bounded work: how long it queued, how long it ran, and how it ended.
Many resources servers limit expensive work, such as a verifier subprocess or a judge call, with a semaphore.
When that limit is too small, verification waits in a queue that no request metric shows, and the server looks slow without looking busy.
Wrapping the limited work in resources_operation makes that visible:
async with resources_operation(self._semaphore, operation=“verify”, executor=“subprocess”) as op: result = await run_the_verifier() if it_timed_out: op.outcome = “timeout”
It reports, by operation and executor:
gym.resources.operation.queue_duration_ms(histogram, milliseconds): time waiting for the limit.gym.resources.operation.duration_ms(histogram, milliseconds, also byoutcome): time running inside the limit. The count of eachoutcome, such astimeoutorcrashed, comes from this histogram.gym.resources.operation.queuedandgym.resources.operation.active: how many operations wait and run right now.
operation is one of verify, tool, judge, or other, and executor is one of inline, thread, process, subprocess, or other, so the attributes stay bounded.
Everything is recorded only while metrics are exporting; otherwise the wrapper only enters the limit.
Module Contents
Classes
Functions
Data
API
One limited operation. Set outcome inside the block when the work ended other than by returning normally.
The instruments and live counts behind resources_operation, one set per meter.
Enter limit, which is any async context manager such as an asyncio.Semaphore, and report the operation.
An exception sets the outcome to error, or cancelled for a cancellation, unless the block already set one.