Skip to navigation

nemo_gym.tasks.harbor

View as Markdown

Read Harbor task folders and hub references into NeMo Gym materialized tasks.

Harbor is the input format; Gym owns execution. A task is a folder holding task.toml, instruction.md, environment/ and tests/. A dataset is a folder of task folders. harbor:<dataset>[@<version>] names a dataset in the Harbor registry, which this package fetches into Gym’s shared datasets folder.

Submodules

Package Contents

Classes

NameDescription
HarborTaskA task folder read into memory.
HarborTaskConfigOne task.toml.

Functions

NameDescription
content_hashDigest the task folder at path.
discover_tasksA folder with task.toml is one task; otherwise its direct children are the tasks.
load_taskRead path as one task. Raises HarborTaskError when it is not one.

Data

DIGEST_KEY

API

class nemo_gym.tasks.harbor.HarborTask(
path: pathlib.Path,
task_id: str,
instruction: str,
digest: str,
image: str | None,
workdir: str | None,
env: dict[str, str],
user: str | None
)
Dataclass

A task folder read into memory.

task_id is the folder name: [task].name is an org/name label that is not unique across a dataset. image is the prebuilt image when the task declares one, else the base image of a base-image-only Dockerfile, else None (a build is required). Without a prebuilt image, workdir, env and user merge task.toml with what the Dockerfile recorded; task.toml wins. With a prebuilt image, the Dockerfile contributes no settings.

config
HarborTaskConfig
digest
str
env
dict[str, str]
has_solution
bool
image
str | None
instruction
str
needs_sandbox
bool

A task runs in a sandbox exactly when it declares an image or a Dockerfile.

path
Path
task_id
str
user
str | None
workdir
str | None
class nemo_gym.tasks.harbor.HarborTaskConfig()

Bases: HarborSettings

One task.toml.

agent
HarborAgent = Field(default_factory=HarborAgent)
artifacts
list[Any] = Field(default_factory=list)
deprecated_keys
frozenset[str]
environment
HarborEnvironment = Field(default_factory=HarborEnvironment)
is_shared_verifier
bool

Harbor runs the verifier in the agent’s container unless a separate one is declared.

metadata
dict[str, Any] = Field(default_factory=dict)
schema_version
str = '1.4'
solution
HarborSolution = Field(default_factory=HarborSolution)
source
str | None = None
task
dict[str, Any] = Field(default_factory=dict)
verifier
HarborVerifier = Field(default_factory=HarborVerifier)
nemo_gym.tasks.harbor.HarborTaskConfig.read_deprecated_fields(
data: typing.Any
) -> typing.Any
classmethod
nemo_gym.tasks.harbor.content_hash(
path: pathlib.Path
) -> str

Digest the task folder at path.

nemo_gym.tasks.harbor.discover_tasks(
root: pathlib.Path,
skipped: dict[str, nemo_gym.tasks.harbor.task.HarborTaskError] | None = None

A folder with task.toml is one task; otherwise its direct children are the tasks.

With skipped, a child that fails to load is recorded there under its folder name and the others still load; without it the first failure raises. A root that is itself a task always raises.

nemo_gym.tasks.harbor.load_task(
path: pathlib.Path

Read path as one task. Raises HarborTaskError when it is not one.

nemo_gym.tasks.harbor.digest.DIGEST_KEY = '_ng_digest'