Skip to content

[SYNPY-1802] Add OOP DownloadList class#1347

Draft
andrewelamb wants to merge 49 commits intodevelopfrom
SYNPY-1802
Draft

[SYNPY-1802] Add OOP DownloadList class#1347
andrewelamb wants to merge 49 commits intodevelopfrom
SYNPY-1802

Conversation

@andrewelamb
Copy link
Copy Markdown
Contributor

@andrewelamb andrewelamb commented Apr 2, 2026

Problem:

Download list functionality was part of the main client class.

Solution:

Create a DownloadList OOP class with the same functionality
Deprecate the old methods

Testing:

Unit and Integration tests for the new class methods.

@andrewelamb andrewelamb requested a review from a team as a code owner April 2, 2026 18:22
@andrewelamb andrewelamb marked this pull request as draft April 2, 2026 18:22
@andrewelamb andrewelamb changed the title add OOP DownloadList class [SYNPY-1802] Add OOP DownloadList class Apr 2, 2026
Comment thread synapseclient/models/download_list.py
@andrewelamb andrewelamb marked this pull request as ready for review April 2, 2026 22:09
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
@andrewelamb andrewelamb requested a review from linglp April 7, 2026 17:50
Copy link
Copy Markdown
Contributor

@linglp linglp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andrewelamb ! I focused on reading the tests for this round of review. I will take a look at the core functions later. Thanks for your hard work!

Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Comment thread tests/unit/synapseclient/models/async/unit_test_download_list_async.py Outdated
Copy link
Copy Markdown
Contributor

@linglp linglp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One main thing that I noticed is that some parts of the code would fail silently. For example:

num_files = DownloadList().add_files(
    files=[
        DownloadListItem(
            file_entity_id="syn24181472",
            version_number=1
        ),
        DownloadListItem(
            file_entity_id="syn24246013",
            version_number=100
        )
    ]
)

Unless users check num_files, there's no way of knowing if all the files have successfully been added to the download list or only some of them have been added.

Similarly, when you remove a file from download list, it is hard to know if all the files have successfully been removed or only some of them have been removed.

In addition, how can we download only a subset of items in the cart? My download cart has over a thousand files but I only want a subset of them to be downloaded. Currently, the only way to do this is to clear the cart, and then re-add specific files. But after clearing all the items in download cart, there's no way to restore them. It seems like there's an endpoint here that could let you query the download cart, but I didn't see it get implemented here. Please let me know if this is not part of the ticket.

Comment thread synapseclient/api/download_list_services.py Outdated
Comment thread synapseclient/api/download_list_services.py Outdated
Comment thread synapseclient/api/download_list_services.py Outdated
Comment thread synapseclient/models/download_list.py
Comment thread synapseclient/models/download_list.py
Comment thread synapseclient/models/download_list.py Outdated


@dataclass
class DownloadListManifestRequest(AsynchronousCommunicator):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is called DownloadListManifestRequest, but based on the docstring, it seems like this class is also the response class? I think the naming here is confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the name of the Endpoint: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/download/DownloadListManifestRequest.html, I'm happy to change it to something else!

Comment thread synapseclient/models/download_list.py
Comment thread synapseclient/models/download_list.py
Comment thread synapseclient/models/download_list.py Outdated
"This is unexpected — the Synapse server may have returned an empty file."
)

if _PATH_COLUMN in columns or _ERROR_COLUMN in columns:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an interesting defensive check. The manifest content is entirely determined by the Synapse server by DownloadList.get_manifest_async. Why this manifest would have naming collision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is more of a guard against those being added in the future.

@andrewelamb
Copy link
Copy Markdown
Contributor Author

One main thing that I noticed is that some parts of the code would fail silently. For example:

num_files = DownloadList().add_files(
    files=[
        DownloadListItem(
            file_entity_id="syn24181472",
            version_number=1
        ),
        DownloadListItem(
            file_entity_id="syn24246013",
            version_number=100
        )
    ]
)

Unless users check num_files, there's no way of knowing if all the files have successfully been added to the download list or only some of them have been added.

Similarly, when you remove a file from download list, it is hard to know if all the files have successfully been removed or only some of them have been removed.

In addition, how can we download only a subset of items in the cart? My download cart has over a thousand files but I only want a subset of them to be downloaded. Currently, the only way to do this is to clear the cart, and then re-add specific files. But after clearing all the items in download cart, there's no way to restore them. It seems like there's an endpoint here that could let you query the download cart, but I didn't see it get implemented here. Please let me know if this is not part of the ticket.

You are correct! This ticket was only for replicating the functionality in synapseclient/client.py that has been deprecated. I'll create a ticket to expand on this one.

Copy link
Copy Markdown
Contributor

@linglp linglp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I flag some issues with the docstring. Could you fix them? Also, I noticed a problem with get_manifest losing parameters in comparison with the old function. I am not sure if that's intentional

Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py
Comment thread synapseclient/models/protocols/download_list_protocol.py
Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py Outdated
Comment thread synapseclient/models/download_list.py Outdated
@andrewelamb andrewelamb marked this pull request as draft April 10, 2026 18:13
@andrewelamb
Copy link
Copy Markdown
Contributor Author

Reverting back to draft, I found some issues that need to be adressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants