Data and Weight Downloads
The cofai-download command downloads or verifies files listed in a manifest. It does not extract dataset archives. The module below also exposes the programmatic manifest parsing, download, and verification APIs.
cofai.utils.download
Batch downloader for files listed in a plain-text manifest.
A manifest is a UTF-8 .txt file where each non-empty, non-comment line
describes one file to place into the repository::
# <comment lines start with '#'>
<dest_path> [<url>] [<checksum>]
dest_pathdestination path, relative to the repo root (or--root). The helper creates parent directories automatically.url(optional) anhttp(s)://direct link. If omitted, the url defaults to<base_url>/<dest_path>, wherebase_urlis :data:DEFAULT_BASE_URL(override with--base-url).checksum(optional) one ofsha256:<hex>,md5:<hex>orsize:<bytes>used to verify the downloaded file. Forsha256/md5a prefix of the digest is accepted (e.g.sha256:95253fe4), which keeps manifests short.
Fields are separated by whitespace, so paths/urls must not contain spaces.
A trailing token is treated as a checksum when it looks like
sha256:/md5:/size:; otherwise it is treated as the url. So a line
may be as short as just <dest_path> (url derived from the base) or
<dest_path> sha256:.. (base url + checksum).
Typical use::
# download everything that is missing / corrupt
poetry run cofai-download weights/weights.manifest.txt
# only check, never download
poetry run cofai-download weights/weights.manifest.txt --verify
# show what would happen
poetry run cofai-download weights/weights.manifest.txt --dry-run
The same entry points are available programmatically::
from cofai.utils.download import download_manifest, verify_manifest
Entry
dataclass
Entry(dest: str, url: str, algo: Optional[str] = None, value: Optional[str] = None)
One manifest line: where to put a file and how to verify it.
download_entry
download_entry(entry: Entry, root: Path, *, force: bool = False, dry_run: bool = False, retries: int = 3, quiet: bool = False) -> Result
Download a single entry, skipping/redownloading based on verification.
download_manifest
download_manifest(manifest_path: PathLike | str, root: PathLike | str = '.', *, base_url: str = DEFAULT_BASE_URL, force: bool = False, dry_run: bool = False, retries: int = 3, quiet: bool = False) -> Summary
Download every entry in a manifest into root.
parse_manifest
parse_manifest(manifest_path: PathLike | str, base_url: str = DEFAULT_BASE_URL) -> List[Entry]
Parse a manifest file into a list of :class:Entry objects.
base_url is used to derive the download url for any line that omits one.
verify_file
verify_file(path: Path, entry: Entry) -> Tuple[Status, str]
Check a single file on disk against its manifest entry.
verify_manifest
verify_manifest(manifest_path: PathLike | str, root: PathLike | str = '.', base_url: str = DEFAULT_BASE_URL) -> Summary
Check every entry without downloading anything.