Unverified Commit ce400589 authored by Martin Cech's avatar Martin Cech Committed by GitHub
Browse files

Merge pull request #14908 from mvdbeek/backport_data_column_fix

[21.09] Backport 14518: Always call strip() on data_column column values
parents e3d05618 a01c8c5a
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1259,6 +1259,11 @@ class ColumnListParameter(SelectToolParameter):
        self.is_dynamic = True
        self.usecolnames = input_source.get_bool("use_header_names", False)

    def to_json(self, value, app, use_security):
        if isinstance(value, str):
            return value.strip()
        return value

    def from_json(self, value, trans, other_values=None):
        """
        Label convention prepends column number with a 'c', but tool uses the integer. This
@@ -1292,8 +1297,9 @@ class ColumnListParameter(SelectToolParameter):
    @staticmethod
    def _strip_c(column):
        if isinstance(column, str):
            if column.startswith('c') and len(column) > 1 and all(c.isdigit() for c in column[1:]):
                column = column.strip().lower()[1:]
            column = column.strip()
            if column.startswith("c") and len(column) > 1 and all(c.isdigit() for c in column[1:]):
                column = column.lower()[1:]
        return column

    def get_column_list(self, trans, other_values):
+29 −1
Original line number Diff line number Diff line
@@ -1319,7 +1319,35 @@ steps:
      col_names: 'B'
""", history_id=history_id)

    @skip_without_tool('column_param')
    @skip_without_tool("column_param_list")
    def test_comma_separated_columns_with_trailing_newline(self):
        # Tests that workflows with weird tool state continue to run.
        # In this case the newline may have been added by the workflow editor
        # text field that is used for data_column parameters
        with self.dataset_populator.test_history() as history_id:
            job_summary = self._run_jobs(
                """class: GalaxyWorkflow
steps:
  empty_output:
    tool_id: empty_output
    outputs:
      out_file1:
        change_datatype: tabular
  column_param_list:
    tool_id: column_param_list
    in:
      input1: empty_output/out_file1
    state:
      col: '2,3\n'
      col_names: 'B\n'
""",
                history_id=history_id,
            )
            job = self.dataset_populator.get_job_details(job_summary.jobs[0]["id"], full=True).json()
            assert "col 2,3" in job["command_line"]
            assert 'echo "col_names B" >>' in job["command_line"]

    @skip_without_tool("column_param")
    def test_runtime_data_column_parameter(self):
        with self.dataset_populator.test_history() as history_id:
            self._run_jobs("""class: GalaxyWorkflow