|
16 | 16 |
|
17 | 17 |
|
18 | 18 | class TaskManager: |
| 19 | + """Discovers, indexes, and loads evaluation tasks from YAML configs. |
| 20 | +
|
| 21 | + Scans directories for task definitions and provides methods to load them |
| 22 | + by name, glob pattern, or inline config. Handles groups, tags, and task |
| 23 | + namespacing (e.g., "mmlu_humanities::formal_logic"). |
| 24 | + """ |
| 25 | + |
19 | 26 | def __init__( |
20 | 27 | self, |
21 | 28 | verbosity: str | None = None, |
22 | 29 | include_path: str | Path | list[str | Path] | None = None, |
23 | 30 | include_defaults: bool = True, |
24 | 31 | metadata: dict[str, dict[str, Any]] | None = None, |
25 | 32 | ) -> None: |
| 33 | + """ |
| 34 | + Args: |
| 35 | + verbosity: Logging level (e.g., "INFO", "DEBUG") |
| 36 | + include_path: Custom paths to scan for task configs (takes precedence) |
| 37 | + include_defaults: Whether to include built-in tasks from lm_eval/tasks/ |
| 38 | + metadata: Extra metadata to attach to all loaded tasks |
| 39 | + """ |
26 | 40 | if verbosity: |
27 | 41 | setup_logging(verbosity) |
28 | 42 |
|
@@ -62,22 +76,27 @@ def __init__( |
62 | 76 | # ---------------------------------------------------------------- properties |
63 | 77 | @property |
64 | 78 | def all_tasks(self) -> list[str]: |
| 79 | + """All registered names (tasks, groups, tags).""" |
65 | 80 | return self._all_tasks |
66 | 81 |
|
67 | 82 | @property |
68 | 83 | def all_groups(self) -> list[str]: |
| 84 | + """All group names (e.g., "mmlu", "arc").""" |
69 | 85 | return self._all_groups |
70 | 86 |
|
71 | 87 | @property |
72 | 88 | def all_subtasks(self) -> list[str]: |
| 89 | + """All individual task names (YAML and Python tasks).""" |
73 | 90 | return self._all_subtasks |
74 | 91 |
|
75 | 92 | @property |
76 | 93 | def all_tags(self) -> list[str]: |
| 94 | + """All tag names (e.g., "ai2_arc", "mmlu_humanities_tasks").""" |
77 | 95 | return self._all_tags |
78 | 96 |
|
79 | 97 | @property |
80 | 98 | def task_index(self) -> dict[str, Entry]: |
| 99 | + """Raw index mapping names to Entry objects.""" |
81 | 100 | return self._index |
82 | 101 |
|
83 | 102 | # ---------------------------------------------------------------- name checks |
@@ -169,9 +188,13 @@ def _entry(self, name: str) -> Entry: |
169 | 188 | return self._index[name] |
170 | 189 |
|
171 | 190 | def load_spec(self, spec: str | dict[str, Any]): |
172 | | - """Spec can be: |
173 | | - • str task / group / tag name (registered) |
174 | | - • dict inline overrides {'task': 'hellaswag', 'num_fewshot': 5} |
| 191 | + """Load a task/group/tag by name or with inline overrides. |
| 192 | +
|
| 193 | + Args: |
| 194 | + spec: Task name (str) or dict with "task" key and overrides |
| 195 | +
|
| 196 | + Returns: |
| 197 | + Dict mapping task names to task objects (nested for groups) |
175 | 198 | """ |
176 | 199 | if isinstance(spec, str): |
177 | 200 | entry = self._entry(spec) |
@@ -209,6 +232,7 @@ def get_task_dict( |
209 | 232 | task_name_list: str | list[str | dict | Task], |
210 | 233 | task_manager: TaskManager | None = None, |
211 | 234 | ): |
| 235 | + """Helper to load multiple tasks into a dict. Creates TaskManager if not provided.""" |
212 | 236 | if not task_manager: |
213 | 237 | task_manager = TaskManager() |
214 | 238 | else: |
|
0 commit comments