Allow uploading individual HDAs via fetch API.

This commit is contained in:
John Chilton
2018-03-08 10:33:41 -05:00
parent 347f1e123b
commit 3bf5990155
3 changed files with 56 additions and 3 deletions
@@ -247,6 +247,42 @@ def collect_dynamic_outputs(
filenames,
)
collection_builder.populate()
elif destination_type == "hdas":
history = job.history
datasets = []
def collect_elements_for_history(elements):
for element in elements:
if "elements" in element:
collect_elements_for_history(element["elements"])
else:
discovered_file = discovered_file_for_unnamed_output(element, job_working_directory)
fields_match = discovered_file.match
designation = fields_match.designation
ext = fields_match.ext
dbkey = fields_match.dbkey
info = element.get("info", None)
link_data = discovered_file.match.link_data
# Create new primary dataset
name = fields_match.name or designation
dataset = job_context.create_dataset(
ext=ext,
designation=designation,
visible=True,
dbkey=dbkey,
name=name,
filename=discovered_file.path,
info=info,
link_data=link_data
)
dataset.raw_set_dataset_state('ok')
datasets.append(dataset)
collect_elements_for_history(elements)
job.history.add_datasets(job_context.sa_session, datasets)
for name, has_collection in output_collections.items():
if name not in tool.output_collections:
+1 -1
View File
@@ -15,7 +15,7 @@ from galaxy.util import (
log = logging.getLogger(__name__)
VALID_DESTINATION_TYPES = ["library", "library_folder", "hdca"]
VALID_DESTINATION_TYPES = ["library", "library_folder", "hdca", "hdas"]
ELEMENTS_FROM_TYPE = ["archive", "bagit", "bagit_archive", "directory"]
# These elements_from cannot be sym linked to because they only exist during upload.
ELEMENTS_FROM_TRANSIENT_TYPES = ["archive", "bagit_archive"]
@@ -737,10 +737,10 @@ class FetchByPathTestCase(BaseUploadContentConfigurationTestCase):
def test_fetch_recursive_archive(self):
history_id, library, destination = self.library_populator.setup_fetch_to_folder("recursive_archive")
bed_test_data_path = self.test_data_resolver.get_filename("testdir1.zip")
archive_test_data_path = self.test_data_resolver.get_filename("testdir1.zip")
targets = [{
"destination": destination,
"items_from": "archive", "src": "path", "path": bed_test_data_path,
"items_from": "archive", "src": "path", "path": archive_test_data_path,
}]
payload = {
"history_id": history_id, # TODO: Shouldn't be needed :(
@@ -756,6 +756,23 @@ class FetchByPathTestCase(BaseUploadContentConfigurationTestCase):
dataset = self.library_populator.get_library_contents_with_path(library["id"], "/dir1/file3")
assert dataset["file_size"] == 11, dataset
def test_fetch_recursive_archive_history(self):
destination = {"type": "hdas"}
archive = self.test_data_resolver.get_filename("testdir1.zip")
targets = [{
"destination": destination,
"items_from": "archive", "src": "path", "path": archive,
}]
payload = {
"history_id": self.history_id, # TODO: Shouldn't be needed :(
"targets": json.dumps(targets),
}
self.dataset_populator.fetch(payload)
contents_response = self.dataset_populator._get_contents_request(self.history_id)
assert contents_response.status_code == 200
contents = contents_response.json()
assert len(contents) == 3
def test_fetch_recursive_archive_to_library(self):
bed_test_data_path = self.test_data_resolver.get_filename("testdir1.zip")
targets = [{