Download¶
cxg.download
¶
FileType
¶
DownloadFailure
dataclass
¶
DownloadPlan
dataclass
¶
select_asset(dataset, filetype)
¶
Find the asset dict matching the requested file type, or None.
Source code in src/cxg/download.py
build_plan(dataset, filetype)
¶
Build a DownloadPlan from a dataset and file type.
Returns:
| Type | Description |
|---|---|
DownloadPlan | None
|
A DownloadPlan if a matching asset exists, or None. |
Source code in src/cxg/download.py
ensure_disk_space(output_dir, required_bytes)
¶
Raise OSError if the output directory lacks sufficient disk space.
Source code in src/cxg/download.py
download_file(client, plan, output_dir, *, overwrite=False, retries=3, progress=None, task_id=None, cancel_event=None)
¶
Download a file with a progress bar and retry logic.
Uses a .part temp file with atomic rename on completion. Skips the
download if the destination already exists and overwrite is False.
If progress and task_id are provided, advances that external task;
otherwise creates a transient single-file progress bar. Both must be
provided together or both omitted.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If all retry attempts fail. |
ValueError
|
If only one of |
Source code in src/cxg/download.py
download_many(client, plans, output_dir, *, overwrite=False, parallel=3, retries=3)
¶
Download multiple datasets concurrently with stacked progress bars.
Returns a list of DownloadFailure for any plans that failed. On
KeyboardInterrupt, signals all in-flight workers to stop, cleans up
.part files, and re-raises.