任务格式参考
当前用户侧 Task 目录必须恰好包含 UTF-8 runner.toml 和其声明的 main.py 或 main.sh。入口不能是符号链接;额外输入文件和越界路径会被拒绝。产物声明不是输入文件上传。
Runner 是执行包;Dataset 中的 Task 是评测题目。目录默认读取 runner.toml;旧 task.toml / envhub.task/v1 两文件执行包继续兼容,同时存在两种配置会被拒绝。Dataset 原生 Harbor task.toml 保留原格式。
Minimal Python task
runner.toml:
schema_version = "envhub.runner/v1"
[runner]
name = "examples/hello"
version = "1"
[execution]
entrypoint = "main.py"
timeout_sec = 10
outputs = ["result.txt"]
main.py:
from pathlib import Path
Path("result.txt").write_text("hello\n", encoding="utf-8")
print("hello")
| 字段 | 示例 | 含义 |
|---|---|---|
schema_version | envhub.runner/v1 | Runner schema |
runner.name / runner.version | examples/hello / 1 | Runner 定义名称与版本,不是 trial_id |
execution.entrypoint | main.py / main.sh | 目录中匹配的入口 |
execution.command | bash main.sh | 可选 shell 脚本;默认按入口使用 bash main.sh 或 python main.py |
execution.timeout_sec | 10 | 执行期限,秒;与 SDK wait timeout 不同 |
execution.outputs | ["result.txt"] | 执行后收集的相对产物路径 |
本页展示当前最小可运行格式;具体字段校验由平台负责。CLI --timeout-sec / SDK execution={"timeout_sec": ...} 可作为执行覆盖传入。
Shell task
将 entrypoint 改为 main.sh,目录中不再放 main.py:
#!/usr/bin/env bash
set -eu
printf 'hello\n' > result.txt
printf 'hello\n'
本地 Python / Bash 解释器由执行环境提供;客户端安装不会自动创建云端运行环境。
Command override
常规提交省略 command / --command,平台按 runner.toml 推导执行命令:main.sh 对应 bash main.sh,main.py 对应 python main.py。已声明 execution.command 时使用该脚本;显式提交 command 再覆盖它。客户端不补默认字符串,因此不同 Runner 可沿用各自入口。
el task submit ./my-task --wait
Task / Job 提交的 command(CLI --command)覆盖 Runner 默认脚本,在 Runner 工作目录由 bash -c 执行。文本保留多行、引号和 shell 变量,须为非空 UTF-8 字符串、无 NUL,最多 65536 字节;空白脚本也会被拒绝。
el task submit ./my-task --command 'printf "custom startup\n"; python main.py' --wait
Python 使用 client.tasks.submit(files, command="printf custom; python main.py") 或 client.jobs.submit(dataset, runner="envhub/harbor@0.23.0", command="printf custom; bash main.sh")。Job 覆盖应用于全部成员。API 兼容 Command 拼写;同一请求包含两种拼写会被拒绝。冻结和幂等以规范化后的 command 为准,重试改脚本会返回冲突。
Profile input
任务从 ENVLOOP_TASK_PROFILE 读取提交冻结的 Profile JSON,省略时为 {}。具体参数由入口自行验证和解释;Profile 不含平台凭据。
Returned result
tasks.result(trial_id) 返回字典,包括 stdout、stderr 和 outputs。outputs 中包含文件名称、文本 content、字节 size、原始字节 SHA-256。对于任意二进制文件,文本 content 不保证可无损还原。
任务完成状态与评测 reward 分开;本示例不含 benchmark verifier,不产生已验证的 reward=1。