From 8aa24fa968159d402108ae7f2754604a56ed2380 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 18 Dec 2018 10:15:23 -0500 Subject: [PATCH] Do not re-compute job input_ext/dbkey (if unneeded). Remote metadata computation needs input_ext in the job parameters (like dbkey) so no need to re-loop through the inp_data to recompute it. Additionally the loop here in discover_outputs in the job or job handler might be running on a different Python version or different Galaxy version than the tool action in the web controller - and this is a dict not a list. Therefore the loop might result in a different value for input_ext. For this reason, it is better to just compute it once and reuse it anyway for a greater guarantee of consistency. --- lib/galaxy/jobs/__init__.py | 27 +++++++++++++++++++-------- lib/galaxy/managers/jobs.py | 4 +++- lib/galaxy/tools/actions/__init__.py | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 8f1496531c7..2c5d3fa370f 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1695,14 +1695,25 @@ class JobWrapper(HasResourceParameters): self.cleanup(delete_files=delete_files) def discover_outputs(self, job, inp_data, out_data, out_collections): - input_ext = 'data' - input_dbkey = '?' - for _, data in inp_data.items(): - # For loop odd, but sort simulating behavior in galaxy.tools.actions - if not data: - continue - input_ext = data.ext - input_dbkey = data.dbkey or '?' + # Try to just recover input_ext and dbkey from job parameters (used and set in + # galaxy.tools.actions). Old jobs may have not set these in the job parameters + # before persisting them. + input_params = job.raw_param_dict() + input_ext = input_params.get("__input_ext") + input_dbkey = input_params.get("dbkey") + if input_ext is not None: + input_ext = loads(input_ext) + input_dbkey = loads(input_dbkey) + else: + # Legacy jobs without __input_ext. + input_ext = 'data' + input_dbkey = '?' + for _, data in inp_data.items(): + # For loop odd, but sort simulating behavior in galaxy.tools.actions + if not data: + continue + input_ext = data.ext + input_dbkey = data.dbkey or '?' # Create generated output children and primary datasets. tool_working_directory = self.tool_working_directory diff --git a/lib/galaxy/managers/jobs.py b/lib/galaxy/managers/jobs.py index 289ef282d05..152ad89ea1d 100644 --- a/lib/galaxy/managers/jobs.py +++ b/lib/galaxy/managers/jobs.py @@ -283,7 +283,9 @@ class JobSearch(object): # parameter as these are not passed along when expanding tool parameters # and they can differ without affecting the resulting dataset. for parameter in job.parameters: - if parameter.name in {'__workflow_invocation_uuid__', 'chromInfo', 'dbkey'} or parameter.name.endswith('|__identifier__'): + if parameter.name.startswith("__"): + continue + if parameter.name in {'chromInfo', 'dbkey'} or parameter.name.endswith('|__identifier__'): continue n_parameters += 1 if not n_parameters == len(param_dump): diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index b6b6e409d5e..e48b8e66dfa 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -334,6 +334,7 @@ class DefaultToolAction(object): # Add the dbkey to the incoming parameters incoming["dbkey"] = input_dbkey + incoming["__input_ext"] = input_ext # wrapped params are used by change_format action and by output.label; only perform this wrapping once, as needed wrapped_params = self._wrapped_params(trans, tool, incoming, inp_data)