fair-simulation-packager
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFAIR Simulation Packager
FAIR模拟打包工具
Goal
目标
Build a minimal reproducibility manifest for materials simulation results so another person or agent can understand what was run, with which inputs, and how outputs should be interpreted.
构建材料模拟结果的极简可复现性清单,让其他人或Agent能够了解运行的内容、使用的输入以及如何解读输出。
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 |
|---|---|---|
| Project name | Human-readable bundle name | |
| Engine | Simulation code | |
| Input files | Files needed to rerun | |
| Output files | Files needed to verify results | |
| Structure ID | Database or local identifier | |
| Units | Field/unit mapping | |
| 输入项 | 描述 | 示例 |
|---|---|---|
| 项目名称 | 易读的打包文件名称 | |
| 引擎 | 模拟代码 | |
| 输入文件 | 重新运行所需的文件 | |
| 输出文件 | 验证结果所需的文件 | |
| 结构ID | 数据库或本地标识符 | |
| 单位 | 字段/单位映射 | |
Decision Guidance
决策指南
- Always include input files, output files, code version, and units.
- Include hashes for every file that exists locally.
- Include structure identifiers when using Materials Project, NOMAD, OPTIMADE, CIF, POSCAR, or internal database records.
- Record missing files as warnings instead of silently dropping them.
- 始终包含输入文件、输出文件、代码版本和单位。
- 为每个本地存在的文件添加哈希值。
- 当使用Materials Project、NOMAD、OPTIMADE、CIF、POSCAR或内部数据库记录时,包含结构标识符。
- 将缺失的文件记录为警告,而非静默丢弃。
Script Outputs
脚本输出
scripts/fair_packager.py --json- : the parsed CLI arguments echoed back (note:
inputsis the raw comma-separated string passed viainputs.inputs, not the per-file records).--inputs - : contains a single key
results.manifest
results.manifest- ,
project_name,engine,engine_version,structure_idunits - with
file_inventoryandinputs, each a list of per-file records (outputs,path, and when the file exists,existsandsize_bytes)sha256 - : paths that do not exist on disk
missing_files - (
provenance,working_directory)manifest_schema - :
fair_checks,has_inputs,has_outputs,has_units, andhas_engine_version(has_hashes_for_existing_files/true, orfalsewhen no files exist so the check is not applicable)null recommended_next_steps
Parse fields at . When is given, only the bare
object (not the / envelope) is written to .
results.manifest.<field>--out PATHmanifestinputsresultsPATHscripts/fair_packager.py --json- :回显解析后的CLI参数(注意:
inputs是通过inputs.inputs传入的原始逗号分隔字符串,而非每个文件的记录)。--inputs - :包含一个键
results。manifest
results.manifest- ,
project_name,engine,engine_version,structure_idunits - ,包含
file_inventory和inputs,各自为每个文件的记录列表(outputs、path,当文件存在时还包含exists和size_bytes)sha256 - :磁盘上不存在的路径
missing_files - (
provenance,working_directory)manifest_schema - :
fair_checks,has_inputs,has_outputs,has_units和has_engine_version(值为has_hashes_for_existing_files/true,当无文件存在时为false,表示该检查不适用)null recommended_next_steps
解析字段时使用。当指定时,仅将裸对象(而非/信封结构)写入。
results.manifest.<field>--out PATHmanifestinputsresultsPATHWorkflow
工作流
bash
python3 skills/data-management/fair-simulation-packager/scripts/fair_packager.py \
--project-name al-cu-diffusion \
--engine LAMMPS \
--inputs in.lammps,data.lmp \
--outputs log.lammps,traj.dump \
--units energy=eV,length=angstrom,time=ps \
--structure-id local:alcu-cell-001 \
--jsonUse only when the user wants a manifest file written.
--out manifest.jsonbash
python3 skills/data-management/fair-simulation-packager/scripts/fair_packager.py \
--project-name al-cu-diffusion \
--engine LAMMPS \
--inputs in.lammps,data.lmp \
--outputs log.lammps,traj.dump \
--units energy=eV,length=angstrom,time=ps \
--structure-id local:alcu-cell-001 \
--json仅在用户需要写入清单文件时使用。
--out manifest.jsonError Handling
错误处理
Missing files are reported in (exit code 0). Invalid input stops with
exit code 2: malformed unit entries, fields containing control characters, fields longer
than 4096 characters, more than 1000 input or output entries, or a file larger than
500 MB. Note that ordinary file paths — including absolute paths and paths containing
— are accepted and inventoried; the tool reads file contents only to compute
metadata and SHA-256 hashes.
missing_files..缺失的文件会在中报告(退出码为0)。无效输入会以退出码2终止:格式错误的单位条目、包含控制字符的字段、长度超过4096字符的字段、输入或输出条目超过1000个,或文件大小超过500 MB。请注意,普通文件路径——包括绝对路径和包含的路径——都会被接受并纳入清单;工具仅读取文件内容以计算元数据和SHA-256哈希值。
missing_files..Limitations
局限性
This skill creates a metadata manifest. It does not upload to NOMAD, Materials Project, or an OPTIMADE provider.
本工具仅创建元数据清单,不会上传至NOMAD、Materials Project或OPTIMADE提供商。
Verification checklist
验证清单
- Confirmed is
fair_checks.has_hashes_for_existing_files(nottrueornull); afalsemeans no listed file existed on disk, so re-run from the directory where the files actually live before trusting the manifest.null - Reviewed and confirmed it is empty, or recorded an explicit reason for each entry — every missing path means an input/output was named but not hashed, so the bundle is not reproducible as-is.
missing_files - Spot-checked at least one in
sha256against an independentresults.manifest.file_inventory/sha256sumof the same file to confirm the recorded digest matches the bytes on disk.Get-FileHash - Confirmed is a real version string and not the default
engine_version; pass"unknown"so the bundle records the exact code build.--engine-version - Verified is non-empty and every reported quantity (energy, length, time, etc.) has an entry, so downstream consumers do not have to guess the unit system.
units - Confirmed is populated when a Materials Project / NOMAD / OPTIMADE / CIF / POSCAR structure was used, so the structure identity is recoverable.
structure_id - When was used, opened
--out PATHand confirmed it holds the barePATHobject (not themanifest/inputsenvelope) and that no unintended path outside the working directory was written.results
- 确认为
fair_checks.has_hashes_for_existing_files(而非true或null);false表示列出的文件均不存在于磁盘上,因此在信任清单前,请从实际存放文件的目录重新运行工具。null - 检查并确认其为空,或为每个条目记录明确的原因——每个缺失的路径意味着某个输入/输出被命名但未被哈希,因此当前打包文件无法直接复现。
missing_files - 随机抽查中的至少一个
results.manifest.file_inventory值,与通过独立工具sha256/sha256sum计算的同一文件的摘要进行比对,确认记录的摘要与磁盘上的字节内容匹配。Get-FileHash - 确认是真实的版本字符串,而非默认值
engine_version;传入"unknown"参数,以便打包文件记录确切的代码构建版本。--engine-version - 验证非空,且每个报告的量(能量、长度、时间等)都有对应的条目,这样下游使用者无需猜测单位系统。
units - 当使用Materials Project / NOMAD / OPTIMADE / CIF / POSCAR结构时,确认已填充,以便结构身份可被恢复。
structure_id - 当使用时,打开
--out PATH并确认其包含裸PATH对象(而非manifest/inputs信封结构),且未写入工作目录外的意外路径。results
Common pitfalls & rationalizations
常见陷阱与合理化借口
| Tempting shortcut | Why it's wrong / what to do |
|---|---|
| "It exited 0, so the bundle is complete." | Exit 0 only means no validation error; missing files are reported in |
" | |
"Skip | The script defaults |
"Parsing | |
| "The manifest captures the structure, so the run is fully reproducible." | This skill only inventories files, hashes, units, and IDs. It does not record code commit, container digest, or parser versions — follow |
"Absolute paths or | Paths are not sandboxed — absolute and |
| 诱人的捷径 | 错误原因/正确做法 |
|---|---|
| "退出码为0,说明打包文件已完整。" | 退出码0仅表示无验证错误;缺失文件会在 |
" | |
"跳过 | 脚本默认 |
"从JSON中解析 | |
| "清单已捕获结构,因此运行完全可复现。" | 本工具仅记录文件清单、哈希值、单位和ID。它不会记录代码提交、容器摘要或解析器版本——请遵循 |
"绝对路径或 | 路径并未沙箱化——绝对路径和包含 |
Security
安全性
Input Validation
输入验证
- and
--project-nameare required and must be non-empty after stripping whitespace; an empty value stops with exit code 2.--engine - ,
--project-name,--engine(when given), and every file path are checked for control characters (--structure-id) and a 4096-character maximum length; either condition stops with exit code 2.ord < 32 - and
--inputsare split on commas and capped at 1000 entries each; more entries stop with exit code 2.--outputs - entries must be
--units; both the key and the value must match the allowlistkey=value. A missing^[A-Za-z0-9_.:/@+-]+$or a non-matching key/value stops with exit code 2.= - There are no numeric inputs, so no finite/positive numeric checks are performed.
- 和
--project-name为必填项,去除空白后必须非空;空值会以退出码2终止。--engine - 、
--project-name、--engine(若提供)以及每个文件路径都会被检查是否包含控制字符(--structure-id)和是否超过4096字符的最大长度;任一条件满足都会以退出码2终止。ord < 32 - 和
--inputs会按逗号拆分,且每个列表最多包含1000个条目;超过会以退出码2终止。--outputs - 条目必须为
--units格式;键和值必须匹配白名单key=value。缺少^[A-Za-z0-9_.:/@+-]+$或键/值不匹配会以退出码2终止。= - 无数值输入,因此无需进行有限/正数值检查。
File Access
文件访问
- The script reads each existing input/output file in 1 MB chunks to compute its
and SHA-256 hash; files that do not exist are recorded but not read.
size_bytes - A file larger than 500 MB stops with exit code 2 before it is hashed.
- The script writes no files unless is given, in which case it writes exactly one file (the bare manifest JSON) to that path; otherwise all output goes to stdout.
--out PATH - Paths are not sandboxed: absolute paths and paths containing are accepted for both the inventoried files and
... If--outpoints outside the working directory, the file is written there as requested.--out
- 脚本会以1 MB块的方式读取每个存在的输入/输出文件,以计算其和SHA-256哈希值;不存在的文件会被记录但不会被读取。
size_bytes - 大小超过500 MB的文件会在计算哈希前以退出码2终止。
- 除非指定,否则脚本不会写入任何文件;指定后会将裸清单JSON写入该路径;否则所有输出都会输出到标准输出。
--out PATH - 路径并未沙箱化:绝对路径和包含的路径对于纳入清单的文件和
..都是可接受的。如果--out指向工作目录之外,文件会按请求写入该位置。--out
Tool Restrictions
工具限制
- is used to run the bundled
Bash.scripts/fair_packager.py - ,
Read,Write, andGrepare declared so the skill can inspect the working directory and read or write manifest/metadata files when guiding the user; they are not invoked by the script itself, which performs all of its own file I/O directly.Glob
- 使用运行捆绑的
Bash。scripts/fair_packager.py - 声明了、
Read、Write和Grep,以便工具在引导用户时检查工作目录并读取或写入清单/元数据文件;这些操作并非由脚本本身调用,脚本自身的所有文件I/O都是直接执行的。Glob
Safety Measures
安全措施
- No ,
eval,exec, oros.systemcalls; the script does not shell out and parses arguments withsubprocess.argparse - Output is emitted as JSON via (or a short plain-text summary without
json.dumps).--json - DoS caps bound resource use: 500 MB per file, 1000 entries per input/output list, and 4096 characters per field.
- 无、
eval、exec或os.system调用;脚本不会调用shell,而是使用subprocess解析参数。argparse - 通过输出JSON(或不带
json.dumps时输出简短的纯文本摘要)。--json - DoS限制约束了资源使用:每个文件最大500 MB,每个输入/输出列表最多1000个条目,每个字段最多4096字符。
References
参考资料
- See for recommended manifest fields.
references/fair_manifest.md
- 推荐的清单字段请参阅。
references/fair_manifest.md
Version History
版本历史
- 1.2.0: Made eval cases discriminating by pinning the script's exact output (per-file
--json/sha256,size_bytes,units,structure_id,engine_version, and the tri-statemissing_files) against committedhas_hashes_for_existing_filesfixtures.evals/files/ - 1.1.0: Documented the real envelope shape; made
--jsontri-state (has_hashes_for_existing_fileswhen no files exist); added entry-count (1000) and field-length (4096) caps; corrected the Error Handling and Security wording to describe actual path behavior.null - 1.0.0: Initial FAIR simulation packaging skill.
- 1.2.0:通过将脚本的精确输出(每个文件的
--json/sha256、size_bytes、units、structure_id、engine_version以及三态的missing_files)与已提交的has_hashes_for_existing_files测试用例进行比对,使评估案例更具判别性。evals/files/ - 1.1.0:记录了真实的信封结构;将
--json改为三态(无文件存在时为has_hashes_for_existing_files);添加了条目数量(1000)和字段长度(4096)限制;修正了错误处理和安全部分的措辞,以描述实际的路径行为。null - 1.0.0:初始的FAIR模拟打包工具版本。