Skip to content

Commit 2b5ea22

Browse files
committed
Use job cache also for implicit conversions
1 parent 8c3dbe4 commit 2b5ea22

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

lib/galaxy/datatypes/data.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ def convert_dataset(
849849
deps: Optional[Dict] = None,
850850
target_context: Optional[Dict] = None,
851851
history=None,
852+
use_cached_job: bool = False,
852853
):
853854
"""This function adds a job to the queue to convert a dataset to another type. Returns a message about success/failure."""
854855
converter = trans.app.datatypes_registry.get_converter_by_target_type(original_dataset.ext, target_type)
@@ -864,8 +865,16 @@ def convert_dataset(
864865
# Make the target datatype available to the converter
865866
params["__target_datatype__"] = target_type
866867
# Run converter, job is dispatched through Queue
868+
# Always use cached job if it exists
869+
completed_jobs = converter.completed_jobs(trans, all_params=[params], use_cached_job=use_cached_job)
870+
completed_job = completed_jobs[0] if completed_jobs else None
867871
job, converted_datasets, *_ = converter.execute(
868-
trans, incoming=params, set_output_hid=visible, history=history, flush_job=False
872+
trans,
873+
incoming=params,
874+
set_output_hid=visible,
875+
history=history,
876+
flush_job=False,
877+
completed_job=completed_job,
869878
)
870879
# We should only have a single converted output, but let's be defensive here
871880
n_converted_datasets = len(converted_datasets)

lib/galaxy/model/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5165,7 +5165,7 @@ def get_converted_files_by_type(self, file_type, include_errored=False):
51655165
return item
51665166
return None
51675167

5168-
def get_converted_dataset_deps(self, trans, target_ext):
5168+
def get_converted_dataset_deps(self, trans, target_ext, use_cached_job=False):
51695169
"""
51705170
Returns dict of { "dependency" => HDA }
51715171
"""
@@ -5174,9 +5174,11 @@ def get_converted_dataset_deps(self, trans, target_ext):
51745174
depends_list = trans.app.datatypes_registry.converter_deps[self.extension][target_ext]
51755175
except KeyError:
51765176
depends_list = []
5177-
return {dep: self.get_converted_dataset(trans, dep) for dep in depends_list}
5177+
return {dep: self.get_converted_dataset(trans, dep, use_cached_job=use_cached_job) for dep in depends_list}
51785178

5179-
def get_converted_dataset(self, trans, target_ext, target_context=None, history=None, include_errored=False):
5179+
def get_converted_dataset(
5180+
self, trans, target_ext, target_context=None, history=None, include_errored=False, use_cached_job=False
5181+
):
51805182
"""
51815183
Return converted dataset(s) if they exist, along with a dict of dependencies.
51825184
If not converted yet, do so and return None (the first time). If unconvertible, raise exception.
@@ -5226,6 +5228,7 @@ def get_converted_dataset(self, trans, target_ext, target_context=None, history=
52265228
deps=deps,
52275229
target_context=target_context,
52285230
history=history,
5231+
use_cached_job=use_cached_job,
52295232
).values()
52305233
)
52315234
)

lib/galaxy/tools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,7 @@ def execute(
24022402
history: Optional[model.History] = None,
24032403
set_output_hid: bool = DEFAULT_SET_OUTPUT_HID,
24042404
flush_job: bool = True,
2405+
completed_job: Optional[Job] = None,
24052406
):
24062407
"""
24072408
Execute the tool using parameter values in `incoming`. This just
@@ -2419,6 +2420,7 @@ def execute(
24192420
history=history,
24202421
set_output_hid=set_output_hid,
24212422
flush_job=flush_job,
2423+
completed_job=completed_job,
24222424
)
24232425

24242426
def _execute(

lib/galaxy/tools/actions/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ def process_dataset(data, formats=None):
173173
if converted_dataset:
174174
data = converted_dataset
175175
else:
176-
data = data.get_converted_dataset(trans, target_ext, target_context=parent, history=history)
176+
data = data.get_converted_dataset(
177+
trans,
178+
target_ext,
179+
target_context=parent,
180+
history=history,
181+
use_cached_job=param_values.get("__use_cached_job__", False),
182+
)
177183

178184
input_name = prefixed_name
179185
# Checked security of whole collection all at once if mapping over this input, else

0 commit comments

Comments
 (0)