Skip to main content

KernelDB.root_for()

The kernel root a download belongs in (decided 2026-11-21).

Usage

Source

KernelDB.root_for(
    mission,
    mk_path=None,
)

This is the one answer to “which kernel root does this download belong in”. In order:

  1. the root that contains mk_path, since a tracked metakernel is re-fetched into its own store;
  2. the only configured root;
  3. the one root that already holds kernels of mission.

When several roots remain it raises AmbiguousKernelRoot instead of picking the first. The CLI turns that into a picker at a terminal and exit code 2 in a script. There is no configured download target.

get_metakernel and update_metakernel call it when download_dir is not given (a URL that is already tracked uses that row’s root), and scan_directory(archive=True) calls it for every file outside the roots.

Parameters

mission: str | None

The mission the download is for. Matched case-insensitively against the missions of the registered locations.

mk_path: str | Path | None = None
A tracked metakernel’s path. The root containing it wins.

Returns

Path
The kernel root.

Raises

AmbiguousKernelRoot
Several roots are configured and neither mk_path nor the mission’s existing kernels single one out.