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.
Example¶
from synapseclient import Synapse
from synapseclient.operations import download_list_files
syn = Synapse()
syn.login()
# Download all files in the cart to a local directory
manifest_path = download_list_files(download_location="./downloads")
API Reference¶
synapseclient.operations.download_list_files
¶
download_list_files(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.
from synapseclient import Synapse
from synapseclient.operations import download_list_files
syn = Synapse()
syn.login()
manifest_path = download_list_files(download_location="./data")
Source code in synapseclient/operations/download_list_operations.py
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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
synapseclient.operations.download_list_manifest
¶
download_list_manifest(*, 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.
from synapseclient import Synapse
from synapseclient.operations import download_list_manifest
syn = Synapse()
syn.login()
manifest_path = download_list_manifest()
Source code in synapseclient/operations/download_list_operations.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
synapseclient.operations.download_list_add
¶
download_list_add(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.
from synapseclient import Synapse
from synapseclient.operations import download_list_add, DownloadListItem
syn = Synapse()
syn.login()
count = download_list_add([
DownloadListItem(file_entity_id="syn123", version_number=1),
DownloadListItem(file_entity_id="syn456", version_number=2),
])
Source code in synapseclient/operations/download_list_operations.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
synapseclient.operations.download_list_remove
¶
download_list_remove(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.
from synapseclient import Synapse
from synapseclient.operations import download_list_remove, DownloadListItem
syn = Synapse()
syn.login()
count = download_list_remove([
DownloadListItem(file_entity_id="syn123", version_number=1),
])
Source code in synapseclient/operations/download_list_operations.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
synapseclient.operations.download_list_clear
¶
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.
from synapseclient import Synapse
from synapseclient.operations import download_list_clear
syn = Synapse()
syn.login()
download_list_clear()
Source code in synapseclient/operations/download_list_operations.py
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
DownloadListItem¶
Identifies a specific file version in the download list. Used as input to download_list_add and download_list_remove.
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 | |