报告与证据
Environment evidence、run manifest、scorecard、紧凑 summary 与可读报告的构建 API。
本页内容
Reporting 把执行状态转成持久证据。Builder 返回普通 dictionary,便于组合与测试;writer 则补充规范文件名并写入磁盘。Environment 或 config 进入 manifest 前,疑似 secret 的值会先被脱敏。
本页 symbol 均从 worldfoundry.evaluation.reporting 导入。
build_env_requirements
这个 builder 记录所需环境变量名和本地路径是否存在,但不会记录 secret 值。可选依赖组则通过 required_extras 保持显式。
def build_env_requirements(required_env: Sequence[str | Mapping[str, Any]] = (),required_paths: Sequence[str | Path | Mapping[str, Any]] = (),required_extras: Sequence[str] = (),environ: Mapping[str, str] | None = None) -> dict[str, Any]worldfoundry.evaluation.reporting.build_env_requirementsfrom worldfoundry.evaluation.reporting import build_env_requirements简介
为 run manifest 收集环境需求声明(软件包、CUDA、资产等)。
参数
required_envSequence[str | Mapping[str, Any]]- Required environment variable names or mappings.默认值:
() required_pathsSequence[str | Path | Mapping[str, Any]]- Required local paths checked for existence only.默认值:
() required_extrasSequence[str]- Required optional dependency groups or runtime bundles.默认值:
() environMapping[str, str] | None- Environment mapping used for deterministic tests; defaults to `
os.environ`.默认值:None
返回值: dict[str, Any]
build_environment
Environment payload 记录 Python、已安装 package 版本、git metadata 与相关 cache 路径。完整环境清单过大时,可以用 package_names 限定收集范围。
def build_environment(repo_root: str | Path | None = None,cache_paths: Mapping[str, Any] | None = None,package_names: Sequence[str] | None = None) -> dict[str, Any]worldfoundry.evaluation.reporting.build_environmentfrom worldfoundry.evaluation.reporting import build_environment简介
快照当前执行环境,写入 run manifest 作为可复现证据。
参数
repo_rootstr | Path | None- Repository root used for git metadata.默认值:
None cache_pathsMapping[str, Any] | None- Cache directories or files relevant to the run.默认值:
None package_namesSequence[str] | None- Optional distribution names to record; all installed distributions are recorded when omitted.默认值:
None
返回值: dict[str, Any]
build_run_manifest
这个函数会在 runner 的 base manifest 上补充脱敏配置、环境证据、revision、cache path、复现字段与稳定 manifest hash。
def build_run_manifest(base_manifest: Mapping[str, Any],config: Mapping[str, Any] | None = None,environment: Mapping[str, Any] | None = None,env_requirements: Mapping[str, Any] | None = None,seed: int | str | None = None,cache_paths: Mapping[str, Any] | None = None,environment_path: str | Path | None = None,env_requirements_path: str | Path | None = None) -> dict[str, Any]worldfoundry.evaluation.reporting.build_run_manifestfrom worldfoundry.evaluation.reporting import build_run_manifest简介
构建记录请求、环境与产物索引的 run manifest 文档。
参数
base_manifestMapping[str, Any]- Existing runner manifest fields to preserve.
configMapping[str, Any] | None- Redacted run configuration snapshot.默认值:
None environmentMapping[str, Any] | None- Environment payload from `
build_environment`.默认值:None env_requirementsMapping[str, Any] | None- Requirement payload from `
build_env_requirements`.默认值:None seedint | str | None- Run seed when the caller has one.默认值:
None cache_pathsMapping[str, Any] | None- Cache path mapping relevant to model, dataset, or runner behavior.默认值:
None environment_pathstr | Path | None- Optional path to the separately written `
environment.json`.默认值:None env_requirements_pathstr | Path | None- Optional path to the separately written `
env_requirements.json`.默认值:None
返回值: dict[str, Any]
write_run_manifest_artifacts
自定义 runner 需要一次性写出标准 manifest 三件套时,使用这个 writer。
from worldfoundry.evaluation.reporting import write_run_manifest_artifacts
paths = write_run_manifest_artifacts(
output_dir="tmp/custom_run",
base_manifest={
"run": {"run_id": "custom-0001", "status": "succeeded"},
"model": {"model_id": "my-model", "revision": "abc123"},
"dataset": {"dataset_id": "my-samples", "split": "validation"},
},
config={"seed": 42, "device": "cuda:0"},
required_env=("HF_TOKEN",),
required_paths=("/data/my-samples",),
required_extras=("video",),
seed=42,
)
print(paths["run_manifest"])如果 HF_TOKEN 或 dataset 路径缺失,输出会把它们记录为缺失证据;函数不会暴露 token,也不会虚构路径存在。
def write_run_manifest_artifacts(output_dir: str | Path,base_manifest: Mapping[str, Any],config: Mapping[str, Any] | None = None,required_env: Sequence[str | Mapping[str, Any]] = (),required_paths: Sequence[str | Path | Mapping[str, Any]] = (),required_extras: Sequence[str] = (),seed: int | str | None = None,cache_paths: Mapping[str, Any] | None = None,repo_root: str | Path | None = None,package_names: Sequence[str] | None = None,environ: Mapping[str, str] | None = None,manifest_path: str | Path | None = None,environment_path: str | Path | None = None,env_requirements_path: str | Path | None = None) -> dict[str, Path]worldfoundry.evaluation.reporting.write_run_manifest_artifactsfrom worldfoundry.evaluation.reporting import write_run_manifest_artifacts简介
把 run manifest JSON(及附属文件)写入运行输出目录。
参数
output_dirstr | Path- Run output directory.
base_manifestMapping[str, Any]- Existing runner manifest fields to enrich.
configMapping[str, Any] | None- Run configuration snapshot with secret-like values redacted.默认值:
None required_envSequence[str | Mapping[str, Any]]- Required environment variable names or mappings.默认值:
() required_pathsSequence[str | Path | Mapping[str, Any]]- Required local paths verified before execution.默认值:
() required_extrasSequence[str]- Required optional dependency groups or runtime bundles.默认值:
() seedint | str | None- Run seed when available.默认值:
None cache_pathsMapping[str, Any] | None- Cache path mapping relevant to reproducibility.默认值:
None repo_rootstr | Path | None- Repository root used for git metadata.默认值:
None package_namesSequence[str] | None- Optional distribution names to record.默认值:
None environMapping[str, str] | None- Environment mapping used for deterministic tests.默认值:
None manifest_pathstr | Path | None- Optional destination for `
run_manifest.json`.默认值:None environment_pathstr | Path | None- Optional destination for `
environment.json`.默认值:None env_requirements_pathstr | Path | None- Optional destination for `
env_requirements.json`.默认值:None
返回值: dict[str, Path]
build_scorecard
Scorecard 汇总 run identity、模型、benchmark、dataset、生成、metric、artifact、provenance 与被跳过工作。它的 leaderboard gate 是保守的:metric 成功计算本身不能证明完整 official evidence。
def build_scorecard(run: Mapping[str, Any],benchmark: Mapping[str, Any],model: Mapping[str, Any],dataset: Mapping[str, Any],generation: Mapping[str, Any],metrics_summary: Mapping[str, Any],artifacts: Mapping[str, Any],skipped: Mapping[str, Any] | None = None,leaderboard_evidence: Mapping[str, Any] | None = None,provenance: Mapping[str, Any] | None = None,evaluation_kind: str = 'existing_results',comparison_identity: Mapping[str, Any] | None = None) -> dict[str, Any]worldfoundry.evaluation.reporting.build_scorecardfrom worldfoundry.evaluation.reporting import build_scorecard简介
从指标聚合与协议结果组装 scorecard 摘要。
参数
runMapping[str, Any]benchmarkMapping[str, Any]modelMapping[str, Any]datasetMapping[str, Any]generationMapping[str, Any]metrics_summaryMapping[str, Any]artifactsMapping[str, Any]skippedMapping[str, Any] | None- 默认值:
None leaderboard_evidenceMapping[str, Any] | None- 默认值:
None provenanceMapping[str, Any] | None- 默认值:
None evaluation_kindstr- 默认值:
'existing_results' comparison_identityMapping[str, Any] | None- 默认值:
None
返回值: dict[str, Any]
write_scorecard
这个 convenience function 使用相同 keyword arguments 构建 scorecard,再写成 JSON,同时把自身绝对路径记录到 artifacts.scorecard。
def write_scorecard(path: str | Path, **kwargs: Any) -> Pathworldfoundry.evaluation.reporting.write_scorecardfrom worldfoundry.evaluation.reporting import write_scorecard简介
将 scorecard 产物落盘,供榜单与人工审阅使用。
参数
pathstr | Path- Destination file path for the scorecard JSON.
kwargsAny- Forwarded to :func:
build_scorecard.
返回值: Path — The resolved path of the written scorecard file.
build_run_summary
Summary 保留 scorecard 中适合比较的子集:identity、fidelity、sample 数、leaderboard 值、eligibility 与 artifact 路径。它适合 run index 和跨 run 比较。
def build_run_summary(scorecard: Mapping[str, Any]) -> dict[str, Any]worldfoundry.evaluation.reporting.build_run_summaryfrom worldfoundry.evaluation.reporting import build_run_summary简介
构建供报告与 UI 使用的精简运行摘要结构。
参数
scorecardMapping[str, Any]
返回值: dict[str, Any]
build_markdown_report
这个 renderer 把紧凑 summary 转成供人阅读的 report.md,不会重新计算分数,也不会改变 eligibility。
def build_markdown_report(summary: Mapping[str, Any]) -> strworldfoundry.evaluation.reporting.build_markdown_reportfrom worldfoundry.evaluation.reporting import build_markdown_report简介
根据运行摘要与 scorecard 渲染人类可读的 Markdown 报告。
参数
summaryMapping[str, Any]
返回值: str
write_run_report_artifacts
输入内存 scorecard 或 scorecard.json 路径后,这个 writer 会同时生成 summary.json 与 report.md。
def write_run_report_artifacts(output_dir: str | Path,scorecard_path: str | Path | None = None,summary_path: str | Path | None = None,report_path: str | Path | None = None,scorecard: Mapping[str, Any] | None = None) -> dict[str, Path]worldfoundry.evaluation.reporting.write_run_report_artifactsfrom worldfoundry.evaluation.reporting import write_run_report_artifacts简介
把 Markdown/HTML 等报告文件与其他运行证据一并写出。
参数
output_dirstr | Path- Run output directory used for default file paths.
scorecard_pathstr | Path | None- Explicit path to the scorecard JSON file.默认值:
None summary_pathstr | Path | None- Explicit destination for the summary JSON file.默认值:
None report_pathstr | Path | None- Explicit destination for the Markdown report file.默认值:
None scorecardMapping[str, Any] | None- In-memory scorecard payload; overrides *scorecard_path*.默认值:
None
返回值: dict[str, Path] — A dict mapping `"summary" and "report" to resolved Path` objects.
正常 CLI 和 run_worldfoundry 流程会自动调用这些 writer。只有外部 runtime 或自定义编排层需要输出相同证据 layout 时,才需要直接使用它们。