Skip to content

abc_runner.groups

WARNING

This documentation is almost entirely "vibe coded"; while a helpful resource for humans and agents to understand this codebase, it should not be considered a source of ground truth in the way documentation normally is, and the user is responsible for verifying that all instructions given here are safe.

abc_runner.groups

Task-group discovery and resolution for ABC Runner.

A task group is the discrete, installable unit of benchmarks. It is a directory (or a squashfs image of one) that contains a group.yaml, an optional group_prompt.md, a Dockerfile.jinja2 describing the group's runtime container layer, and one subdirectory per task.

Groups are discovered from a prioritized set of search roots. A search root is a directory that contains task groups (<root>/<group>/ or <root>/<group>.sqfs), analogous to a directory on the shell PATH containing executables. Priority, highest first:

  1. an explicit --task-dir supplied on the command line,
  2. the colon-separated TASK_PATH environment variable (left-to-right), and
  3. the installed root ~/.abc-runner/tasks (populated by abc-runner install).

The first root that provides a given group id wins; lower-priority roots that also define it are shadowed (with a warning). Squashfs groups are materialized to a temporary directory on first resolution and reused within the process.

GroupResolver

GroupResolver(task_dir: Path | None = None, task_path: str | None = None, installed_root: Path | None = None, warn: bool = True)

Resolve task-group ids to concrete group directories.

Parameters:

Name Type Description Default
task_dir Path

Highest-priority search root from the CLI --task-dir flag.

None
task_path str

Colon-separated search roots. Defaults to the TASK_PATH environment variable.

None
installed_root Path

Lowest-priority search root. Defaults to ~/.abc-runner/tasks.

None
warn bool

Emit a warning when a group id is shadowed by a higher-priority root.

True
Source code in abc_runner/groups.py
def __init__(
    self,
    task_dir: Path | None = None,
    task_path: str | None = None,
    installed_root: Path | None = None,
    warn: bool = True,
):
    if task_path is None:
        task_path = os.environ.get(TASK_PATH_ENV)
    if installed_root is None:
        installed_root = installed_tasks_root()

    roots: list[Path] = []
    if task_dir is not None:
        roots.append(Path(task_dir).expanduser())
    roots.extend(_split_task_path(task_path))
    roots.append(Path(installed_root).expanduser())

    # De-duplicate while preserving priority order.
    seen: set[Path] = set()
    self.search_roots: list[Path] = []
    for root in roots:
        resolved = root.resolve() if root.exists() else root
        if resolved in seen:
            continue
        seen.add(resolved)
        self.search_roots.append(root)

    self.warn = warn
    # Cache of resolved (materialized) group directories by group id.
    self._resolved: dict[str, Path] = {}

list_group_ids

list_group_ids() -> list[str]

Return all discoverable group ids across search roots (deduped).

Source code in abc_runner/groups.py
def list_group_ids(self) -> list[str]:
    """Return all discoverable group ids across search roots (deduped)."""
    group_ids: list[str] = []
    seen: set[str] = set()
    for root in self.search_roots:
        for group_id in self._group_entries_in(root):
            if group_id not in seen:
                seen.add(group_id)
                group_ids.append(group_id)
    return sorted(group_ids)

resolve_group_dir

resolve_group_dir(group_id: str) -> Path

Resolve a group id to a concrete, directory-backed group path.

Squashfs images are materialized to a temporary directory (cached for the lifetime of the process).

Raises:

Type Description
FileNotFoundError

If no search root provides the group.

Source code in abc_runner/groups.py
def resolve_group_dir(self, group_id: str) -> Path:
    """Resolve a group id to a concrete, directory-backed group path.

    Squashfs images are materialized to a temporary directory (cached for
    the lifetime of the process).

    Raises
    ------
    FileNotFoundError
        If no search root provides the group.
    """
    if group_id in self._resolved:
        return self._resolved[group_id]

    source = self._source_for(group_id)
    if source is None:
        roots = ", ".join(str(root) for root in self.search_roots) or "<none>"
        raise FileNotFoundError(
            f"task group {group_id!r} not found in any search root ({roots})"
        )

    if squashfs.is_squashfs_artifact(source):
        group_dir = squashfs.materialize_group(source)
    else:
        group_dir = source.resolve()

    self._resolved[group_id] = group_dir
    return group_dir

has_group

has_group(group_id: str) -> bool

Return True if any search root provides the group.

Source code in abc_runner/groups.py
def has_group(self, group_id: str) -> bool:
    """Return True if any search root provides the group."""
    return self._source_for(group_id) is not None

installed_tasks_root

installed_tasks_root() -> Path

Return the resolved installed task-group root.

Source code in abc_runner/groups.py
def installed_tasks_root() -> Path:
    """Return the resolved installed task-group root."""
    return INSTALLED_TASKS_ROOT.expanduser()