Skip to navigation

nemo_gym.sandbox.compose_config

View as Markdown

Turn a published Harbor Compose overlay into a document the sandbox Compose adapter can start.

Harbor publishes environment/docker-compose.yaml as an overlay on its own base file: the main service is the task image, sidecars are prebuilt images. Starting it without Docker needs each image’s recorded OCI configuration (entrypoint, command, user, exposed ports, healthcheck), which image_configs supplies, keyed by image reference.

Adapted from Gym’s Terminal Bench 4 server (resources_servers/terminal_bench_4/compose_config.py).

Module Contents

Functions

NameDescription
_compose_literals-
_peer_urlWhether value is exactly one URL whose host is a Compose service, the shape resolve_environment rewrites.
adapt_non_root_sidecarsKeep a sidecar on its image’s default non-root user without host-file injection.
opensandbox_shm_labelsOpenSandbox takes a service’s shared-memory size as a label. Mutates and returns document.
resolve_composeApply Harbor’s prebuilt-image base and normalize the published task overlay.

API

nemo_gym.sandbox.compose_config._compose_literals(
value: typing.Any
) -> typing.Any
nemo_gym.sandbox.compose_config._peer_url(
value: typing.Any,
services: dict
) -> bool

Whether value is exactly one URL whose host is a Compose service, the shape resolve_environment rewrites.

A compound value (Kafka’s comma-separated KAFKA_ADVERTISED_LISTENERS) parses to a hostname too, but its port text is not a number and the adapter would fail reading it; it is left as written.

nemo_gym.sandbox.compose_config.adapt_non_root_sidecars(
document: dict,
image_configs: dict
) -> dict

Keep a sidecar on its image’s default non-root user without host-file injection.

A non-root process cannot edit /etc/hosts, so peer names are resolved into the environment variables that carry http://<service> URLs instead, and the explicit user copied from image metadata is dropped so the provider does not try to su to the user it already runs as. Mutates and returns document.

nemo_gym.sandbox.compose_config.opensandbox_shm_labels(
document: dict,
label: str = 'nemo.nvidia.com/shm'
) -> dict

OpenSandbox takes a service’s shared-memory size as a label. Mutates and returns document.

nemo_gym.sandbox.compose_config.resolve_compose(
document: dict,
main_image: str,
image_configs: dict
) -> dict

Apply Harbor’s prebuilt-image base and normalize the published task overlay.