任务命令:job
bohr job 用于管理 Bohrium 计算任务。后续查看、下载、停止或删除任务时,请使用 bohr job list 中 BOHR_ID 列显示的 Bohr ID。
提示:提交新任务推荐使用 Batch Job,参见批处理任务,运行
bohr batchjob submit即可。旧的 Job 模块仍可使用,后续将逐步过渡到 Batch Job。
命令
| 命令 | 用法 | 说明 |
|---|---|---|
list | bohr job list [flags] | 查询和筛选任务 |
submit | bohr job submit [flags] | 提交任务 |
describe | bohr job describe [flags] | 查看任务或任务组详情 |
log | bohr job log <bohr_id>... [flags] | 下载日志文件 |
download | bohr job download <bohr_id>... [flags] | 下载结果文件 |
terminate | bohr job terminate <bohr_id>... [flags] | 优雅终止任务 |
kill | bohr job kill <bohr_id>... [flags] | 强制停止任务 |
delete | bohr job delete <bohr_id>... [flags] | 删除任务 |
还提供适合 Agent 的快捷命令:+submit、+watch 和 +cancel。
查询任务
bohr job list -n 20
bohr job list --running -o json
bohr job list -j 1022 --fail
常用筛选参数包括 -j, --job_group_id、-n, --number、--pending、-r, --running、-i, --finish、-f, --fail、-s, --scheduling、-t, --stopping 和 -d, --stopped。
使用全局输出参数选择结构化格式:
bohr job list --output yaml
提交任务
使用 JSON 配置文件:
bohr job submit -i job.json --input_directory ./input
也可以直接传入参数:
bohr job submit \
--project_id 123 \
--machine_type c2_m4_cpu \
--image_address registry.dp.tech/dptech/ubuntu:22.04 \
--command "python main.py" \
--input_directory ./input
关键参数:
| 参数 | 说明 |
|---|---|
-i, --config_file | JSON 配置文件 |
--input_directory | 本地输入目录;没有 -p 缩写 |
--project_id | Bohrium 项目 ID |
-m, --image_address | 镜像地址 |
-t, --machine_type | 机型;可用 bohr machine list -c all 查询 |
-c, --command | 任务执行命令 |
-g, --job_group_id | 由 bohr job_group create 创建的分组 |
-r, --result_path | /personal 或 /share 下的 Bohrium 远端路径,不是本地路径 |
--max_run_time | 最大运行时间,单位为分钟 |
--nnode | 计算节点数,默认 1 |
提交任务可能创建计费资源。CLI 会要求确认;可以先用 --dry-run 校验而不提交。
查看与下载
bohr job describe -i 20143720 -o json
bohr job log 20143720 --out ./logs
bohr job download 20143720 --out ./results
log 和 download 使用 --out 指定本地目录。-o 专用于全局输出格式。
停止或删除任务
bohr job terminate 20143720
bohr job kill 20143720
bohr job delete 20143720
kill 和 delete 是破坏性操作,需要确认。自动化执行前建议先使用 --dry-run。