跳到主要内容

运行任务

Task 提交支持本地两文件目录或 SDK 文件内容映射。SDK 读取文件并发送内容;远程机器不需要访问客户端目录。具名 Runner / Dataset 使用 APIServer catalog;执行时由平台下载题目。

Submit and inspect​

先按 Quickstart 准备 ./my-task 和连接配置:

el task submit ./my-task --wait
el task status TRIAL_ID
el task snapshot TRIAL_ID
el task result TRIAL_ID
el task stop TRIAL_ID

将 TRIAL_ID 替换为提交返回的 ID。HTTP 提交默认立即返回,--wait 显式等待;本地 CLI 提交等待执行结束。result 本身不等待。CLI 没有 task logs、task cancel 或 task wait 子命令。

Harbor Runner​

在 APIServer catalog 中注册对应 Runner 和 Dataset 并配置连接后,单独运行 fix-git:

el task submit \
--runner envhub/harbor@0.23.0 \
--dataset envloop/terminal-bench-2-1-lite@1.0.1 \
--task-id terminal-bench/fix-git \
--queue-id default \
--priority 10 \
--wait

示例固定 Dataset 版本 1.0.1;所选名称与版本须已存在于你的 catalog 中。该示例不代表生产目录可用或 benchmark 得分已验收。

无需 --command:runner.toml 声明 main.sh,平台执行 bash main.sh。Python Runner 的 main.py 同样自动选择 python main.py。--command 用于自定义启动;Harbor Runner 需要执行节点支持并启用 Docker-in-Docker(DinD)。

Inline files with Python​

from envloop import Client

files = {
"runner.toml": '''schema_version = "envhub.runner/v1"
[runner]
name = "examples/inline"
version = "1"
[execution]
entrypoint = "main.py"
timeout_sec = 10
''',
"main.py": 'print("inline hello")\n',
}
with Client.remote() as client:
trial = client.tasks.submit(files, request_id="inline-hello-001")
final = client.tasks.wait(trial["trial_id"], timeout=60)
print(final["status"])
print(client.tasks.result(trial["trial_id"])["stdout"])

首次运行预期 succeeded、stdout 为 inline hello 加换行。重复使用相同 request_id 会复用原 Trial;有意重跑请换新值。

Results and artifacts​

结果字典包含 stdout、stderr、outputs。每个 output 包含 name、content、size、sha256。只有任务声明的产物才作为 outputs 返回,详见 Task format。SHA-256 针对原始字节;content 是文本解码结果,不适合重新编码后校验任意二进制文件。

本地日志保留在启动时当前目录的 logs/trials/<trial_id>/,包括 stdout.log、stderr.log 和 manifest.json,与 work_dir 独立。远程执行日志不写入客户端此目录。

Timeout and cancellation​

tasks.wait(timeout=...) 限制客户端等待时间,抛 TimeoutError 不取消执行。execution.timeout_sec 限制任务执行期限。需要停止时显式调用 tasks.stop();后端可能拒绝取消,例如当前 E2B 返回 CANCELLATION_UNSUPPORTED,不能据此宣称云资源已回收。

错误处理见 Troubleshooting。