Download List¶
The Synapse Download List (cart) lets you queue files for bulk download via the Synapse web UI or API. Files are downloaded individually rather than packaged into a zip because download lists can exceed 100 GB. Successfully downloaded files are removed from the cart automatically, so interrupted runs are safely resumable.
API Reference¶
synapseclient.operations.download_list_files_async
async
¶
download_list_files_async(download_location: Optional[str] = None, *, parallel: bool = False, max_concurrent: int = 10, synapse_client: Optional[Synapse] = None) -> str
Download all files in the Synapse download list (cart) to a local directory.
Files are downloaded individually. The cart is not packaged into a zip because download lists can exceed 100 GB. Only successfully downloaded files are removed from the cart after the full pass completes, so interrupted runs are safely resumable.
Files that cannot be accessed or fail to download are left in the cart and recorded with an error value in the result manifest.
| PARAMETER | DESCRIPTION |
|---|---|
download_location
|
Directory to download files to. Defaults to the current working directory. |
parallel
|
If True, files are downloaded concurrently up to max_concurrent at a time using asyncio.gather. If False (default), files are downloaded sequentially.
TYPE:
|
max_concurrent
|
Maximum number of files to download concurrently when parallel=True. Defaults to 10. Has no effect when parallel=False.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor. |
| RETURNS | DESCRIPTION |
|---|---|
str
|
Path to the result manifest CSV, which contains all original manifest |
str
|
columns plus path (local file path) and error (error message or |
str
|
empty string) columns. |
| RAISES | DESCRIPTION |
|---|---|
SynapseHTTPError
|
If the manifest async job fails or the cart is empty ("No files available for download"). |
SynapseError
|
If the manifest job completes but produces no local file, or if the downloaded CSV has no headers or contains reserved column names ("path" or "error"). |
Download all files in the cart
Download all files in the user's download list to a local directory.
import asyncio
from synapseclient import Synapse
from synapseclient.operations import download_list_files_async
async def main():
syn = Synapse()
syn.login()
manifest_path = await download_list_files_async(download_location="./data")
asyncio.run(main())
Source code in synapseclient/operations/download_list_operations.py
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 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
synapseclient.operations.download_list_manifest_async
async
¶
download_list_manifest_async(*, csv_table_descriptor: Optional[CsvTableDescriptor] = None, destination: str = '.', synapse_client: Optional[Synapse] = None) -> str
Generate and download the manifest CSV for the current cart contents.
Submits an async job to Synapse to generate the manifest, then downloads the resulting CSV. The manifest contains the same columns as the zip manifest downloaded from the Synapse web UI.
| PARAMETER | DESCRIPTION |
|---|---|
csv_table_descriptor
|
Optional CsvTableDescriptor controlling the format of the generated CSV (separator, quote character, escape character, line ending, and whether the first line is a header). When omitted the Synapse defaults are used.
TYPE:
|
destination
|
Directory to download the manifest CSV to. Defaults to the current working directory.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor. |
| RAISES | DESCRIPTION |
|---|---|
SynapseError
|
If the async job completes without producing a manifest. |
| RETURNS | DESCRIPTION |
|---|---|
str
|
Path to the downloaded manifest CSV. |
Get the download list manifest
Inspect the cart contents before downloading.
import asyncio
from synapseclient import Synapse
from synapseclient.operations import download_list_manifest_async
async def main():
syn = Synapse()
syn.login()
manifest_path = await download_list_manifest_async()
asyncio.run(main())
Source code in synapseclient/operations/download_list_operations.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
synapseclient.operations.download_list_add_async
async
¶
download_list_add_async(files: list[DownloadListItem], *, synapse_client: Optional[Synapse] = None) -> int
Add files to the Synapse download list.
If a file is added with no version specified, the latest version will be downloaded.
| PARAMETER | DESCRIPTION |
|---|---|
files
|
List of DownloadListItem objects identifying the file versions to add.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor. |
| RETURNS | DESCRIPTION |
|---|---|
int
|
The number of files added. |
Add files to the download list
Add specific file versions to the cart.
import asyncio
from synapseclient import Synapse
from synapseclient.operations import download_list_add_async, DownloadListItem
async def main():
syn = Synapse()
syn.login()
count = await download_list_add_async([
DownloadListItem(file_entity_id="syn123", version_number=1),
DownloadListItem(file_entity_id="syn456", version_number=2),
])
asyncio.run(main())
Source code in synapseclient/operations/download_list_operations.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
synapseclient.operations.download_list_remove_async
async
¶
download_list_remove_async(files: list[DownloadListItem], *, synapse_client: Optional[Synapse] = None) -> int
Remove files from the Synapse download list.
If a file was added with a version specified, then that version must be specified to remove it. If a file was added with no version specified, then no version must be specified to remove it.
| PARAMETER | DESCRIPTION |
|---|---|
files
|
List of DownloadListItem objects identifying the file versions to remove.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor. |
| RETURNS | DESCRIPTION |
|---|---|
int
|
The number of files removed. |
Remove files from the download list
Remove specific file versions from the cart.
import asyncio
from synapseclient import Synapse
from synapseclient.operations import download_list_remove_async, DownloadListItem
async def main():
syn = Synapse()
syn.login()
count = await download_list_remove_async([
DownloadListItem(file_entity_id="syn123", version_number=1),
])
asyncio.run(main())
Source code in synapseclient/operations/download_list_operations.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | |
synapseclient.operations.download_list_clear_async
async
¶
Clear all files from the Synapse download list (cart).
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor. |
Clear the download list
Remove all files from the cart.
import asyncio
from synapseclient import Synapse
from synapseclient.operations import download_list_clear_async
async def main():
syn = Synapse()
syn.login()
await download_list_clear_async()
asyncio.run(main())
Source code in synapseclient/operations/download_list_operations.py
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |
DownloadListItem¶
Identifies a specific file version in the download list. Used as input to download_list_add_async and download_list_remove_async.
synapseclient.operations.DownloadListItem
dataclass
¶
A single item for a user's download list.
https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/download/DownloadListItem.html
| ATTRIBUTE | DESCRIPTION |
|---|---|
file_entity_id |
Synapse ID of the file entity (e.g. "syn123").
TYPE:
|
version_number |
Version of the file to target. |
Source code in synapseclient/operations/download_list_operations.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |