workflow-engine-mapper
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkflow Engine Mapper
工作流引擎映射工具
Goal
目标
Choose the smallest workflow structure that preserves reproducibility, restartability, and provenance for a materials simulation task.
为材料模拟任务选择最小化的工作流结构,同时确保可复现性、可重启性和溯源性。
Requirements
要求
- Python 3.10+
- No external dependencies
- Works on Linux, macOS, and Windows
- Python 3.10+
- 无外部依赖
- 支持Linux、macOS和Windows系统
Inputs to Gather
需要收集的输入信息
| Input | Description | Example |
|---|---|---|
| Task | Workflow purpose | |
| Code | Main simulation engine | |
| Runs | Approximate number of calculations | |
| Provenance | Whether audit trail matters | |
| Restart | Whether jobs may resume after failure | |
| HPC | Whether remote scheduler is required | |
| 输入项 | 描述 | 示例 |
|---|---|---|
| 任务 | 工作流用途 | |
| 代码 | 主模拟引擎 | |
| 运行次数 | 估算的计算次数 | |
| 溯源性 | 是否需要审计追踪 | |
| 重启功能 | 任务失败后是否需要恢复 | |
| HPC | 是否需要远程调度器 | |
Decision Guidance
决策指南
- Use one-off scripts for fewer than 5 local exploratory runs (no provenance, no HPC).
- Use jobflow/atomate2 when the workflow is Python-native and Materials Project style input sets are useful.
- Use AiiDA when provenance-critical work is also remote (HPC) or large (>= 50 runs) — i.e. long-lived, database-backed campaigns. For smaller local provenance needs, atomate2 (Materials Project codes, >= 10 runs) or jobflow stores already capture inputs, outputs, code version, and environment, so the mapper recommends those instead of the heavier AiiDA stack.
- Use pyiron when interactive atomistic workflows, notebooks, and job management are the primary user surface (ASE/LAMMPS without strict provenance).
The recommendations are emitted in a fixed precedence so the prose and the implemented thresholds agree: an explicit engine overrides everything; otherwise one-off (small local, no provenance/HPC) -> AiiDA (provenance AND remote/large) -> atomate2 (VASP/QE/CP2K/force-field, >= 10 runs) -> pyiron (ASE/LAMMPS, no provenance) -> jobflow (fallback).
--preferred- 针对少于5次的本地探索性运行(无需溯源、无需HPC),使用一次性脚本。
- 当工作流为Python原生,且Materials Project风格的输入集有用时,使用jobflow/atomate2。
- 当需要严格溯源的工作同时涉及远程(HPC)或大规模(≥50次运行)场景——即长期运行、基于数据库的计算任务时,使用AiiDA。对于规模较小的本地溯源需求,atomate2(Materials Project支持的代码、≥10次运行)或jobflow的存储已能捕获输入、输出、代码版本和环境信息,因此映射工具会推荐这些方案,而非更重型的AiiDA栈。
- 当以交互式原子工作流、笔记本和任务管理为主要使用场景(无需严格溯源的ASE/LAMMPS任务)时,使用pyiron。
推荐结果遵循固定优先级,以确保文字说明与实现的阈值一致:显式指定的引擎会覆盖所有规则;否则优先级顺序为:一次性脚本(小规模本地任务、无需溯源/HPC)→ AiiDA(需要溯源且为远程/大规模任务)→ atomate2(代码为vasp/qe/CP2K/力场、≥10次运行)→ pyiron(ASE/LAMMPS、无需溯源)→ jobflow(兜底方案)。
--preferredScript Outputs
脚本输出
scripts/workflow_engine_mapper.pyrecommended_enginedag_patternprovenance_requirementsrestart_strategystorage_layoutmigration_triggersnotes
scripts/workflow_engine_mapper.pyrecommended_enginedag_patternprovenance_requirementsrestart_strategystorage_layoutmigration_triggersnotes
Workflow
使用流程
bash
python3 skills/simulation-workflow/workflow-engine-mapper/scripts/workflow_engine_mapper.py \
--task "relax static dos for 200 oxides" \
--code vasp \
--runs 200 \
--needs-provenance \
--needs-restart \
--hpc \
--jsonUse the output to scaffold the workflow before writing engine-specific code.
bash
python3 skills/simulation-workflow/workflow-engine-mapper/scripts/workflow_engine_mapper.py \
--task "relax static dos for 200 oxides" \
--code vasp \
--runs 200 \
--needs-provenance \
--needs-restart \
--hpc \
--json在编写引擎专属代码前,可使用输出内容搭建工作流框架。
Error Handling
错误处理
If the task has too few details, choose the conservative pattern and ask for engine, run count, and restart needs before implementation.
若任务信息不足,选择保守模式,并在实现前询问引擎类型、运行次数和重启需求。
Limitations
局限性
The skill does not replace the official APIs of atomate2, jobflow, AiiDA, or pyiron; it selects and explains the workflow shape.
本工具无法替代atomate2、jobflow、AiiDA或pyiron的官方API;它仅负责选择并解释工作流的架构。
Verification checklist
验证清单
- Recorded the full payload from
--json(includingworkflow_engine_mapper.py) and confirmed the echoedinputs,runs,code,needs_provenance, andneeds_restartmatch the task you actually intend, not a guessed default.hpc - Confirmed follows the documented precedence for these inputs:
recommended_engineoverride -> one-off (--preferred, no provenance, no HPC) -> aiida (provenance AND (runs<5orhpc)) -> atomate2 (runs>=50in vasp/qe/cp2k/forcefield ANDcode) -> pyiron (ase/lammps, no provenance) -> jobflow fallback; if the result surprises you, re-check which branch the inputs hit rather than overriding blindly.runs>=10 - Verified reflects the task keywords: branch terms (
dag_pattern/dos/band/phonon) and sweep terms (static/screen/sweep/campaign/many) compose into the map+branch pattern, andbatchis appended only whenwith restart checkpointswas passed.--needs-restart - Checked and
provenance_requirementsagainst intent:restart_strategy/store_code_version,store_environment(also auto-true atcheckpoint_jobs), andruns>=20(false for one-off) are consistent with how the campaign will actually be audited and resumed.resume_by_job_id_or_name - Read ; for a one-off recommendation, confirmed the forward-looking "migrate once results are compared/published/screened/resumed or runs reach ~5+" entry is present and planned for, rather than treating one-off as permanent.
migration_triggers - Used (
storage_layout,inputs/,runs/<job-id>/,outputs/,metadata/workflow.json) as the on-disk scaffold and confirmed it maps onto the chosen engine's native store before writing engine-specific code.reports/ - Confirmed the mapper exit code was (a
0means input validation rejected the args and no recommendation was produced) before trusting any output.2
- 记录输出的完整
workflow_engine_mapper.py负载(包括--json),并确认回显的inputs、runs、code、needs_provenance和needs_restart与实际任务需求一致,而非默认值。hpc - 确认符合文档中定义的输入优先级:
recommended_engine覆盖规则 → 一次性脚本(--preferred、无需溯源、无需HPC)→ aiida(需要溯源且(使用HPC或runs<5))→ atomate2(runs>=50属于vasp/qe/cp2k/力场且code)→ pyiron(ase/lammps、无需溯源)→ jobflow兜底;若结果不符合预期,先检查输入触发了哪个分支,而非盲目覆盖。runs>=10 - 验证反映了任务关键字:分支术语(
dag_pattern/dos/band/phonon)和扫描术语(static/screen/sweep/campaign/many)组合成映射+分支模式,且仅当传递了batch时才会追加--needs-restart。with restart checkpoints - 检查和
provenance_requirements是否与预期一致:restart_strategy/store_code_version、store_environment(当checkpoint_jobs时自动设为true)和runs>=20(一次性脚本为false)需与任务实际的审计和恢复方式一致。resume_by_job_id_or_name - 阅读;若推荐为一次性脚本,确认其中包含前瞻性的“当结果完成对比/发布/筛选/恢复或运行次数达到~5+时进行迁移”条目,并做好规划,不要将一次性脚本视为永久方案。
migration_triggers - 使用(
storage_layout、inputs/、runs/<job-id>/、outputs/、metadata/workflow.json)作为磁盘架构,并确认其与所选引擎的原生存储结构匹配后,再编写引擎专属代码。reports/ - 确认映射工具的退出码为(退出码
0表示输入验证未通过,未生成推荐结果),再信任输出内容。2
Common pitfalls & rationalizations
常见误区与合理化建议
| Tempting shortcut | Why it's wrong / what to do |
|---|---|
| "It's only a few runs now, so a one-off script is fine forever." | The mapper emits a |
| "I need provenance, so the answer must be AiiDA." | AiiDA is gated on provenance AND (HPC or |
| "The engine ran and printed a recommendation, so the inputs were right." | The script validates bounds, not intent. A forgotten |
| "It's a screening campaign, so the DAG is just a map over structures." | If the task also names a property (dos/band/phonon/static), the correct pattern composes both: |
| "Restart isn't critical, so I can skip checkpointing." | |
"The recommended engine doesn't match what I'd have picked, so I'll just use | |
| 诱人的捷径 | 错误原因及正确做法 |
|---|---|
| "现在只是几次运行,所以一次性脚本可以一直用下去。" | 映射工具输出 |
| "我需要溯源功能,所以必须选AiiDA。" | AiiDA的使用条件是需要溯源且(使用HPC或 |
| "工具运行并给出了推荐,所以输入肯定是对的。" | 脚本仅验证输入的合法性,而非合理性。遗漏的 |
| "这是一个筛选任务,所以DAG只是对结构的映射。" | 如果任务还指定了属性(dos/band/phonon/static),正确的模式应同时包含两者: |
| "重启不重要,所以我可以跳过 checkpointing。" | 当 |
"推荐的引擎不符合我的预期,所以我直接用 | |
Security
安全性
Input Validation
输入验证
- The script accepts only scalar CLI inputs and boolean flags (,
--needs-provenance,--needs-restart,--hpcvia--json).store_true - must be a positive integer (rejects booleans, non-integers, and values
runs) and is capped at<= 0;MAX_RUNS = 1,000,000also rejects non-finite values viamain().math.isfinite - Free-text fields are length-bounded: <= 2000 characters (
task) and must be non-empty after stripping;MAX_TASK_LENandcode<= 100 characters each (preferred).MAX_FIELD_LEN - must be one of the allowed engine names:
preferred,auto,one-off,jobflow,atomate2,aiida.pyiron - The and
taskstrings are not otherwise restricted by an allowlist; only their length and (forcode) emptiness are validated.task - All invalid input raises , which is printed to stderr and exits with code 2 before any recommendation is computed.
ValueError
- 脚本仅接受标量CLI输入和布尔标志(、
--needs-provenance、--needs-restart、--hpc通过--json实现)。store_true - 必须为正整数(拒绝布尔值、非整数和
runs的值),且上限为<=0;MAX_RUNS = 1,000,000还会通过main()拒绝非有限值。math.isfinite - 自由文本字段有长度限制:长度不超过2000字符(
task),且去除空白后不能为空;MAX_TASK_LEN和code长度不超过100字符(preferred)。MAX_FIELD_LEN - 必须为允许的引擎名称之一:
preferred、auto、one-off、jobflow、atomate2、aiida。pyiron - 和
task字符串不通过白名单限制;仅验证其长度(以及code是否为空)。task - 所有无效输入都会触发,错误信息会打印到stderr,并以退出码2终止,不会生成任何推荐结果。
ValueError
File Access
文件访问
- The script reads and writes no files; all I/O is CLI args in -> stdout (JSON or two summary lines) out.
- It accepts no path arguments, so there is no path-sandboxing concern; there are no on-disk size limits because nothing is read from disk.
- 脚本不读取或写入任何文件;所有I/O均为CLI输入→stdout输出(JSON或两行摘要)。
- 不接受路径参数,因此不存在路径沙箱问题;由于不读取磁盘内容,也没有磁盘大小限制。
Tool Restrictions
工具限制
- The frontmatter declares .
allowed-tools: Read, Bash, Write, Grep, Glob - is used only to run the bundled
Bash.scripts/workflow_engine_mapper.py - /
Read/Grepare used to inspect the skill's own files and references (e.g.Glob) and the user's task context;references/workflow_engines.mdis available to scaffold workflow files from the recommended structure.Write
- 前置声明。
allowed-tools: Read, Bash, Write, Grep, Glob - 仅用于运行内置的
Bash。scripts/workflow_engine_mapper.py - /
Read/Grep用于检查工具自身的文件和参考资料(如Glob)以及用户的任务上下文;references/workflow_engines.md用于根据推荐的结构搭建工作流文件。Write
Safety Measures
安全措施
- No /
eval, noexec, and no shell invocation inside the script.subprocess - No network access: it does not connect to remote services, submit jobs, or deserialize untrusted data.
- Output is emitted as structured JSON via (with
json.dumps) or plain text summary lines.--json - DoS caps bound resource use: the ceiling (1,000,000) and the
runs/task/codelength caps prevent unbounded input.preferred
- 不使用/
eval、exec,脚本内部也不调用shell。subprocess - 无网络访问:不连接远程服务、不提交任务、不反序列化不可信数据。
- 输出通过以结构化JSON格式(使用
json.dumps时)或纯文本摘要行形式输出。--json - DoS限制约束资源使用:上限(1,000,000)和
runs/task/code的长度限制可防止无限制输入。preferred
References
参考资料
- See for engine selection heuristics.
references/workflow_engines.md
- 引擎选择启发式规则详见。
references/workflow_engines.md
Version History
版本历史
- 1.2.2: Add a Verification checklist (evidence tied to the mapper's JSON outputs, precedence, DAG composition, and exit code) and a Common pitfalls & rationalizations table covering one-off permanence, AiiDA over-selection, unread input flags, and forced checkpointing.
- 1.2.0: Strengthen evals with deterministic that pin the mapper's exact output (recommended_engine, dag_pattern, provenance_requirements, restart_strategy, migration_triggers) so each case discriminates the skill from a from-memory baseline.
script_checks - 1.1.0: Compose branch+sweep DAG patterns instead of overwriting; emit a forward-looking migration trigger for one-off runs; document AiiDA gating/precedence; add input-validation safeguards (bounds, length caps) matching the Security section.
- 1.0.0: Initial workflow engine mapping skill.
- 1.2.2:添加验证清单(与映射工具的JSON输出、优先级、DAG组合和退出码相关的验证项)和常见误区与合理化建议表,涵盖一次性脚本的永久性、过度选择AiiDA、未阅读输入标志和强制checkpointing等问题。
- 1.2.0:通过确定性的增强评估,固定映射工具的精确输出(recommended_engine、dag_pattern、provenance_requirements、restart_strategy、migration_triggers),使每个案例都能区分本工具与基于记忆的基线方案。
script_checks - 1.1.0:组合分支+扫描DAG模式而非覆盖;为一次性运行输出前瞻性的迁移触发条件;记录AiiDA的准入规则/优先级;添加与安全章节匹配的输入验证防护(边界、长度限制)。
- 1.0.0:初始版本的工作流引擎映射工具。