cdm_data_loaders.pipelines.ncbi_ftp_download ¶
NCBI FTP assembly download pipeline (Phase 2).
Orchestrates parallel downloading of NCBI assemblies listed in a transfer
manifest. Settings, batching, CLI entry point, and CTS integration live here;
domain-specific download logic is in :mod:cdm_data_loaders.ncbi_ftp.assembly.
DownloadSettings ¶
Bases: LoggerSettings
Configuration for the NCBI FTP assembly download pipeline.
Source code in src/cdm_data_loaders/pipelines/ncbi_ftp_download.py
download_batch ¶
download_batch(
manifest_path: Path,
output_dir: Path,
threads: int = 4,
ftp_host: str = FTP_HOST,
limit: int | None = None,
*,
on_assembly_downloaded: (
Callable[[PurePosixPath], None] | None
) = None,
progress_desc: str = "Downloading from NCBI FTP"
) -> dict[str, Any]
Download all assemblies listed in the manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest_path
|
Path
|
path to the transfer manifest file |
required |
output_dir
|
Path
|
base output directory |
required |
threads
|
int
|
number of parallel download threads |
4
|
ftp_host
|
str
|
FTP hostname |
FTP_HOST
|
limit
|
int | None
|
optional limit for testing |
None
|
on_assembly_downloaded
|
Callable[[PurePosixPath], None] | None
|
optional callback invoked with each assembly's FTP path after download succeeds |
None
|
progress_desc
|
str
|
description shown on the tqdm progress bar |
'Downloading from NCBI FTP'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
report dict with overall stats |
Source code in src/cdm_data_loaders/pipelines/ncbi_ftp_download.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
run_download ¶
Main CTS entry point for Phase 2 download.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DownloadSettings
|
validated download settings |
required |
Source code in src/cdm_data_loaders/pipelines/ncbi_ftp_download.py
download_and_stage ¶
download_and_stage(
*,
bucket: PurePosixPath,
staging_key_prefix: PurePosixPath,
manifest_s3_key: PurePosixPath | None = None,
manifest_local_path: Path | None = None,
threads: int = 4,
ftp_host: str = FTP_HOST,
limit: int | None = None,
dry_run: bool = False
) -> dict[str, Any]
Download assemblies from NCBI FTP and stage them to S3 (Phase 2).
Exactly one of manifest_s3_key or manifest_local_path must be given.
Downloads and uploads are pipelined per assembly: each worker downloads one assembly, immediately uploads its files to S3, then deletes the local copies before picking up the next assembly. At most threads assembly directories exist on disk simultaneously, preventing disk exhaustion on large batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket
|
PurePosixPath
|
destination S3 bucket name |
required |
staging_key_prefix
|
PurePosixPath
|
key prefix inside the bucket (e.g. |
required |
manifest_s3_key
|
PurePosixPath | None
|
S3 object key of the transfer manifest within bucket |
None
|
manifest_local_path
|
Path | None
|
local path to the transfer manifest file |
None
|
threads
|
int
|
number of parallel download-and-upload workers |
4
|
ftp_host
|
str
|
NCBI FTP hostname |
FTP_HOST
|
limit
|
int | None
|
optional limit for testing |
None
|
dry_run
|
bool
|
when |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
download report extended with |
Source code in src/cdm_data_loaders/pipelines/ncbi_ftp_download.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |