Fix resuming job when job has optional data parameters

This fixes
```
ERROR    galaxy.tools.actions:__init__.py:683 Cannot remap rerun dependencies.
Traceback (most recent call last):
  File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/actions/__init__.py", line 664, in _remap_job_on_rerun
    self.__remap_parameters(job_to_remap, jtid, jtod, out_data)
  File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/actions/__init__.py", line 694, in __remap_parameters
    input_values = {p.name: json.loads(p.value) for p in job_to_remap.parameters}
  File "/Users/mvandenb/src/galaxy/lib/galaxy/tools/actions/__init__.py", line 694, in <dictcomp>
    input_values = {p.name: json.loads(p.value) for p in job_to_remap.parameters}
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not
NoneType
```

Optional data inputs or optional selects are stored as `None` (super
inconsistent, since most other parameters are stored as JOSN. We should
create "basic_2.py" using pydantic at one point not too far into the
future ...). This means we can't call `json.loads` on these. Fortunately
this is the only place we do it, and we don't need to consider optional
parameters here anyway.
This commit is contained in:
mvdbeek
2022-02-08 15:45:01 +01:00
parent 44644a0175
commit bec9d4b49f
3 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -675,12 +675,13 @@ class DefaultToolAction:
return remapped_hdas
def __remap_parameters(self, job_to_remap, jtid, jtod, out_data):
input_values = {p.name: json.loads(p.value) for p in job_to_remap.parameters}
input_values = {p.name: json.loads(p.value) for p in job_to_remap.parameters if p.value is not None}
old_dataset_id = jtod.dataset_id
new_dataset_id = out_data[jtod.name].id
input_values = update_dataset_ids(input_values, {old_dataset_id: new_dataset_id}, src='hda')
for p in job_to_remap.parameters:
p.value = json.dumps(input_values[p.name])
if p.name in input_values:
p.value = json.dumps(input_values[p.name])
jtid.dataset = out_data[jtod.name]
jtid.dataset.hid = jtod.dataset.hid
log.info(f'Job {job_to_remap.id} input HDA {jtod.dataset.id} remapped to new HDA {jtid.dataset.id}')
+1
View File
@@ -967,6 +967,7 @@ steps:
cond_param_inner: true
input1:
$link: 0/out_file1
thedata: null
cat:
tool_id: cat1
in:
@@ -16,6 +16,7 @@
</conditional>
</when>
</conditional>
<param name="thedata" type="data" optional="true" label="Optional dummy data"/>
</inputs>
<outputs>
<data name="output1" format="tabular" from_work_dir="output1" />