Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.0] Raise exception if collection elements missing during download #18094

Merged
merged 5 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const rerunUrl = computed(() =>
const showCollectionDetailsUrl = computed(() =>
props.dsc.job_source_type == "Job" ? `/jobs/${props.dsc.job_source_id}/view` : null
);
const disableDownload = props.dsc.populated_state !== "ok";

function onDownload() {
window.location.href = downloadUrl.value;
}
Expand All @@ -28,6 +30,7 @@ function onDownload() {
<b-button-group>
<b-button
title="Download Collection"
:disabled="disableDownload"
class="rounded-0 text-decoration-none"
size="sm"
variant="link"
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/managers/hdcas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Dict

from galaxy import model
from galaxy.exceptions import RequestParameterInvalidException
from galaxy.managers import (
annotatable,
base,
Expand Down Expand Up @@ -40,6 +41,8 @@ def stream_dataset_collection(dataset_collection_instance, upstream_mod_zip=Fals


def write_dataset_collection(dataset_collection_instance, archive):
if not dataset_collection_instance.collection.populated_optimized:
raise RequestParameterInvalidException("Attempt to write dataset collection that has not been populated yet")
names, hdas = get_hda_and_element_identifiers(dataset_collection_instance)
for name, hda in zip(names, hdas):
if hda.state != hda.states.OK:
Expand Down
10 changes: 6 additions & 4 deletions lib/galaxy/webapps/galaxy/api/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,7 @@ def download_dataset_collection_history_content(
"""Download the content of a history dataset collection as a `zip` archive
while maintaining approximate collection structure.
"""
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
return StreamingResponse(archive.response(), headers=archive.get_headers())
return self._download_collection(trans, id)

@router.get(
"/api/dataset_collections/{id}/download",
Expand All @@ -644,8 +643,7 @@ def download_dataset_collection(
"""Download the content of a history dataset collection as a `zip` archive
while maintaining approximate collection structure.
"""
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
return StreamingResponse(archive.response(), headers=archive.get_headers())
return self._download_collection(trans, id)

@router.post(
"/api/histories/{history_id}/contents/dataset_collections/{id}/prepare_download",
Expand Down Expand Up @@ -1033,3 +1031,7 @@ def materialize_to_history(
)
rval = self.service.materialize(trans, materialize_request)
return rval

def _download_collection(self, trans, id):
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
return StreamingResponse(archive.response(), headers=archive.get_headers())
Loading