Skip to navigation

nemo_gym.sandbox.resource_telemetry

View as Markdown

Best-effort resource records in the existing sandbox trace stream.

Module Contents

Classes

NameDescription
ComponentAllocationObserved reservations and limits for one explicitly named component.
ResourceAllocationProvider-independent allocation record; placement is optional.
ResourceDesignatorOpaque infrastructure identity interpreted by kind, within an optional scope.
ResourceProviderOptional read-only capability; values carry explicit provider/source semantics.
ResourceSamplerOne owner samples a sandbox; borrowed connections do not start duplicate samplers.

Functions

NameDescription
allocation_attributesUse identical OTEL keys for every provider’s typed allocation.
amount_attributesSerialize shared resource quantities without losing unspecified values.
record_requestGive one logical sandbox request an identity, even if provisioning never succeeds.
requested_attributesDeclared shape only. Absent values are unknown, never zero or effective allocation.
sampling_intervalReturn zero unless resource traces are enabled, including an actual exporter.

Data

Attribute

LOGGER

PREFIX

API

class nemo_gym.sandbox.resource_telemetry.ComponentAllocation(
name: str,
requests: nemo_gym.sandbox.providers.base.SandboxResourceAmounts = SandboxResourceAmounts(),
limits: nemo_gym.sandbox.providers.base.SandboxResourceAmounts = SandboxResourceAmounts()
)
Dataclass

Observed reservations and limits for one explicitly named component.

limits
SandboxResourceAmounts = field(default_factory=SandboxResourceAmounts)
name
str
requests
SandboxResourceAmounts = field(default_factory=SandboxResourceAmounts)
class nemo_gym.sandbox.resource_telemetry.ResourceAllocation(
source: str,
)
Dataclass

Provider-independent allocation record; placement is optional.

components
tuple[ComponentAllocation, ...] = ()
designator
ResourceDesignator | None = None
host
ResourceDesignator | None = None
source
str
class nemo_gym.sandbox.resource_telemetry.ResourceDesignator(
kind: str,
id: str,
scope: str | None = None
)
Dataclass

Opaque infrastructure identity interpreted by kind, within an optional scope.

This is not a network endpoint or reconnect descriptor and contains no credentials. Scope identifies the deployment/cluster/daemon in which the ID is meaningful.

id
str
kind
str
scope
str | None = None
class nemo_gym.sandbox.resource_telemetry.ResourceProvider()
Protocol

Optional read-only capability; values carry explicit provider/source semantics.

nemo_gym.sandbox.resource_telemetry.ResourceProvider.resource_allocation(
async
nemo_gym.sandbox.resource_telemetry.ResourceProvider.resource_sample(
async
class nemo_gym.sandbox.resource_telemetry.ResourceSampler(
attributes: collections.abc.Mapping[str, nemo_gym.sandbox.resource_telemetry.Attribute],
interval: float
)

One owner samples a sandbox; borrowed connections do not start duplicate samplers.

attributes
= dict(attributes)
task
Task[None] | None = None
nemo_gym.sandbox.resource_telemetry.ResourceSampler.record(
kind: str,
final: bool = False
) -> None
async
nemo_gym.sandbox.resource_telemetry.ResourceSampler.run() -> None
async
nemo_gym.sandbox.resource_telemetry.ResourceSampler.start() -> None
nemo_gym.sandbox.resource_telemetry.ResourceSampler.stop() -> None
async
nemo_gym.sandbox.resource_telemetry.allocation_attributes(

Use identical OTEL keys for every provider’s typed allocation.

nemo_gym.sandbox.resource_telemetry.amount_attributes(
prefix: str

Serialize shared resource quantities without losing unspecified values.

nemo_gym.sandbox.resource_telemetry.record_request(
attributes: collections.abc.Mapping[str, nemo_gym.sandbox.resource_telemetry.Attribute]

Give one logical sandbox request an identity, even if provisioning never succeeds.

nemo_gym.sandbox.resource_telemetry.requested_attributes(

Declared shape only. Absent values are unknown, never zero or effective allocation.

nemo_gym.sandbox.resource_telemetry.sampling_interval() -> float

Return zero unless resource traces are enabled, including an actual exporter.

nemo_gym.sandbox.resource_telemetry.Attribute = str | int | float | bool
nemo_gym.sandbox.resource_telemetry.LOGGER = logging.getLogger(__name__)
nemo_gym.sandbox.resource_telemetry.PREFIX = 'nemo.gym.sandbox.'