inspect_evals_utils.readmes.generate¶
Generate and maintain auto-generated sections in per-eval README files.
Scans eval directories under src/, extracts metadata from eval.yaml and task parameters from @task functions, and writes Usage, Options, Parameters, and Contributors sections into README files between HTML comment tags.
Usage
inspect-evals-readmes generate inspect-evals-readmes generate --eval my_eval inspect-evals-readmes generate --create-missing inspect-evals-readmes generate --check
Adapted from: https://github.com/UKGovernmentBEIS/inspect_evals/blob/main/tools/generate_readmes.py
TaskInfo
dataclass
¶
EvalInfo
dataclass
¶
package_name
property
¶
package_name: str
The Python package name (e.g. 'my_eval' or 'examples.gpqa').
Contents
¶
TaskImportError
¶
Bases: ImportError
A task named in eval.yaml could not be imported from its package.
discover_evals
¶
discover_evals(
src_dir: Path, include_examples: bool = False
) -> list[EvalInfo]
Discover all evaluations by scanning src/*/eval.yaml.
rewrite_readme
¶
rewrite_readme(
file: Path,
key: str,
contents: list[str],
*,
check: bool = False,
) -> bool
Replace the section between the key's tags. Returns whether the file changes.
With check, nothing is written.
rewrite_task_readme
¶
rewrite_task_readme(
eval_info: EvalInfo,
key: str,
contents: list[str],
*,
check: bool = False,
) -> bool
extract_task_parameters
¶
extract_task_parameters(
task_name: str, package_name: str
) -> list[dict[str, Any]]
Extract parameter information from a @task decorated function.
Tries to import the task function from the package init (which should export @task functions).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
Name of the task function |
required |
package_name
|
str
|
Python package name (e.g. "my_eval" or "examples.gpqa") |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of parameter dictionaries with name, type_str, default, and description |
build_parameters_section
¶
build_parameters_section(eval_info: EvalInfo) -> list[str]
Build the Parameters section for a task README.
generate_basic_readme
¶
generate_basic_readme(eval_info: EvalInfo) -> list[str]
Generate basic README content for a new eval.
missing_tasks
¶
missing_tasks(eval_info: EvalInfo) -> list[str]
Return the package.task names in eval.yaml that cannot be imported.
generate_readmes
¶
generate_readmes(
src_dir: Path,
*,
eval_name: str | None = None,
create_missing: bool = False,
include_examples: bool = False,
check: bool = False,
) -> list[Path]
Generate or update the README sections of every eval under src_dir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_dir
|
Path
|
Directory holding |
required |
eval_name
|
str | None
|
If set, only process this eval (package name, e.g. "my_eval" or "examples.gpqa"). |
None
|
create_missing
|
bool
|
Create README files for evals that don't have them. |
False
|
include_examples
|
bool
|
Also process example evaluations under |
False
|
check
|
bool
|
Report what would change without writing anything. |
False
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
The README paths that changed, or would change under |
Raises:
| Type | Description |
|---|---|
LookupError
|
|
TaskImportError
|
a task in some eval.yaml could not be imported; that eval's README is left untouched. |