MCPcopy
hub / github.com/EleutherAI/lm-evaluation-harness / TaskManager

Class TaskManager

lm_eval/tasks/manager.py:37–367  ·  view source on GitHub ↗

Central entry point for discovering and loading evaluation tasks. On construction, scans one or more directories for YAML task configs and builds an in-memory index of every known task, group, and tag. Callers then use :meth:`load` to instantiate tasks by name, glob pattern, file p

Source from the content-addressed store, hash-verified

35
36
37class TaskManager:
38 """Central entry point for discovering and loading evaluation tasks.
39
40 On construction, scans one or more directories for YAML task configs and
41 builds an in-memory index of every known task, group, and tag. Callers
42 then use :meth:`load` to instantiate tasks by name, glob pattern, file
43 path, or inline config dict.
44
45 Example::
46
47 tm = TaskManager(include_path="my_tasks/")
48 result = tm.load(["mmlu", "hellaswag"])
49 result["tasks"] # {name: Task, ...}
50 result["groups"] # {name: Group, ...}
51 """
52
53 def __init__(
54 self,
55 verbosity: str | None = None,
56 include_path: str | Path | list[str | Path] | None = None,
57 include_defaults: bool = True,
58 metadata: dict[str, dict[str, Any] | str] | None = None,
59 ) -> None:
60 """
61 Args:
62 verbosity: Logging level (e.g., "INFO", "DEBUG") (deprecated, use standard logging configuration instead)
63 include_path: Custom paths to scan for task configs (takes precedence)
64 include_defaults: Whether to include built-in tasks from lm_eval/tasks/
65 metadata: Extra metadata to attach to all loaded tasks
66 """
67 if verbosity:
68 warnings.warn(
69 "The `verbosity` argument is deprecated. Use logging configuration instead.",
70 DeprecationWarning,
71 stacklevel=2,
72 )
73
74 self.include_path = include_path
75 self.metadata = metadata
76
77 index = TaskIndex()
78 self._factory: TaskFactory = TaskFactory(meta=metadata)
79
80 all_paths: list[Path] = []
81 # Process defaults FIRST, then include_path (later paths can override earlier)
82 if include_defaults:
83 all_paths.append(Path(__file__).parent)
84 if include_path:
85 all_paths += [
86 Path(p)
87 for p in (
88 include_path
89 if isinstance(include_path, (list, tuple))
90 else [include_path]
91 )
92 ]
93
94 self._index = index.build(all_paths)

Callers 15

mainFunction · 0.90
shared_task_managerFunction · 0.90
test_include_pathMethod · 0.90
test_group_loadingMethod · 0.90
test_include_groupMethod · 0.90

Calls

no outgoing calls