Unverified Commit bec9d4b4 authored by mvdbeek's avatar mvdbeek
Browse files

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.
parent 44644a01
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -675,11 +675,12 @@ 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:
            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
+1 −0
Original line number Diff line number Diff line
@@ -967,6 +967,7 @@ steps:
          cond_param_inner: true
          input1:
            $link: 0/out_file1
    thedata: null
  cat:
    tool_id: cat1
    in:
+1 −0
Original line number Diff line number Diff line
@@ -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" />