From d128734d65bb91120e1bfbc01cb8336811708540 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 4 Mar 2021 21:07:25 -0500 Subject: [PATCH] Bug fix - cannot set dbkeys in workflow tests. --- lib/galaxy/tool_util/client/staging.py | 18 +++++++++++++----- lib/galaxy/tool_util/cwl/util.py | 2 ++ lib/galaxy_test/api/test_tools_upload.py | 6 ++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/galaxy/tool_util/client/staging.py b/lib/galaxy/tool_util/client/staging.py index 430d3c26688..09494087eb9 100644 --- a/lib/galaxy/tool_util/client/staging.py +++ b/lib/galaxy/tool_util/client/staging.py @@ -23,6 +23,8 @@ log = logging.getLogger(__name__) UPLOAD_TOOL_ID = "upload1" LOAD_TOOLS_FROM_PATH = True DEFAULT_USE_FETCH_API = True +DEFAULT_FILE_TYPE = "auto" +DEFAULT_DBKEY = "?" class StagingInterace(metaclass=abc.ABCMeta): @@ -74,9 +76,12 @@ class StagingInterace(metaclass=abc.ABCMeta): fetch_payload = None if isinstance(upload_target, FileUploadTarget): file_path = upload_target.path + file_type = upload_target.properties.get('filetype', None) or DEFAULT_FILE_TYPE + dbkey = upload_target.properties.get('dbkey', None) or DEFAULT_DBKEY fetch_payload = _fetch_payload( history_id, - file_type=upload_target.properties.get('filetype', None) or "auto", + file_type=file_type, + dbkey=dbkey, to_posix_lines=to_posix_lines, ) name = _file_path_to_name(file_path) @@ -141,10 +146,12 @@ class StagingInterace(metaclass=abc.ABCMeta): if isinstance(upload_target, FileUploadTarget): file_path = upload_target.path + file_type = upload_target.properties.get('filetype', None) or DEFAULT_FILE_TYPE + dbkey = upload_target.properties.get('dbkey', None) or DEFAULT_DBKEY upload_payload = _upload_payload( history_id, - file_type=upload_target.properties.get('filetype', None) or "auto", - to_posix_lines=to_posix_lines, + file_type=file_type, + to_posix_lines=dbkey, ) name = _file_path_to_name(file_path) upload_payload["inputs"]["files_0|auto_decompress"] = False @@ -269,7 +276,7 @@ def _file_path_to_name(file_path): return name -def _upload_payload(history_id, tool_id=UPLOAD_TOOL_ID, file_type="auto", dbkey="?", **kwd): +def _upload_payload(history_id, tool_id=UPLOAD_TOOL_ID, file_type=DEFAULT_FILE_TYPE, dbkey=DEFAULT_DBKEY, **kwd): """Adapted from bioblend tools client.""" payload = {} payload["history_id"] = history_id @@ -289,9 +296,10 @@ def _upload_payload(history_id, tool_id=UPLOAD_TOOL_ID, file_type="auto", dbkey= return payload -def _fetch_payload(history_id, file_type="auto", dbkey="?", **kwd): +def _fetch_payload(history_id, file_type=DEFAULT_FILE_TYPE, dbkey=DEFAULT_DBKEY, **kwd): element = { "ext": file_type, + "dbkey": dbkey, } for arg in ['to_posix_lines', 'space_to_tab']: if arg in kwd: diff --git a/lib/galaxy/tool_util/cwl/util.py b/lib/galaxy/tool_util/cwl/util.py index 928ff54c2dc..c79beb8b1d4 100644 --- a/lib/galaxy/tool_util/cwl/util.py +++ b/lib/galaxy/tool_util/cwl/util.py @@ -180,6 +180,8 @@ def galactic_job_json( kwd = {} if "tags" in value: kwd["tags"] = value.get("tags") + if "dbkey" in value: + kwd["dbkey"] = value.get("dbkey") if composite_data_raw: composite_data = [] for entry in composite_data_raw: diff --git a/lib/galaxy_test/api/test_tools_upload.py b/lib/galaxy_test/api/test_tools_upload.py index af035505f09..824b381361d 100644 --- a/lib/galaxy_test/api/test_tools_upload.py +++ b/lib/galaxy_test/api/test_tools_upload.py @@ -274,6 +274,7 @@ class ToolsUploadTestCase(ApiTestCase): "class": "File", "format": "txt", "path": "test-data/simple_line_no_newline.txt", + "dbkey": "hg19", } } inputs, datasets = stage_inputs(self.galaxy_interactor, history_id, job, use_path_paste=False, to_posix_lines=False) @@ -284,6 +285,11 @@ class ToolsUploadTestCase(ApiTestCase): ) # By default this appends the newline. self.assertEqual(content, "This is a line of text.") + details = self.dataset_populator.get_history_dataset_details( + history_id=history_id, + dataset=dataset + ) + assert details["genome_build"] == "hg19" @uses_test_history(require_new=False) def test_upload_multiple_mixed_success(self, history_id):