Skip to content

Commit 3fc5d93

Browse files
committed
add docs
1 parent 65fc387 commit 3fc5d93

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

lm_eval/tasks/manager.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,27 @@
1616

1717

1818
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+
1926
def __init__(
2027
self,
2128
verbosity: str | None = None,
2229
include_path: str | Path | list[str | Path] | None = None,
2330
include_defaults: bool = True,
2431
metadata: dict[str, dict[str, Any]] | None = None,
2532
) -> 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+
"""
2640
if verbosity:
2741
setup_logging(verbosity)
2842

@@ -62,22 +76,27 @@ def __init__(
6276
# ---------------------------------------------------------------- properties
6377
@property
6478
def all_tasks(self) -> list[str]:
79+
"""All registered names (tasks, groups, tags)."""
6580
return self._all_tasks
6681

6782
@property
6883
def all_groups(self) -> list[str]:
84+
"""All group names (e.g., "mmlu", "arc")."""
6985
return self._all_groups
7086

7187
@property
7288
def all_subtasks(self) -> list[str]:
89+
"""All individual task names (YAML and Python tasks)."""
7390
return self._all_subtasks
7491

7592
@property
7693
def all_tags(self) -> list[str]:
94+
"""All tag names (e.g., "ai2_arc", "mmlu_humanities_tasks")."""
7795
return self._all_tags
7896

7997
@property
8098
def task_index(self) -> dict[str, Entry]:
99+
"""Raw index mapping names to Entry objects."""
81100
return self._index
82101

83102
# ---------------------------------------------------------------- name checks
@@ -169,9 +188,13 @@ def _entry(self, name: str) -> Entry:
169188
return self._index[name]
170189

171190
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)
175198
"""
176199
if isinstance(spec, str):
177200
entry = self._entry(spec)
@@ -209,6 +232,7 @@ def get_task_dict(
209232
task_name_list: str | list[str | dict | Task],
210233
task_manager: TaskManager | None = None,
211234
):
235+
"""Helper to load multiple tasks into a dict. Creates TaskManager if not provided."""
212236
if not task_manager:
213237
task_manager = TaskManager()
214238
else:

0 commit comments

Comments
 (0)