From e6aeb21a08e4404c6d220ca8246238b654fbf40b Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 26 Aug 2022 17:49:50 +0200 Subject: [PATCH 1/3] Always call strip() on data_column column values Not just when they start with `c`. Should fix running workflows that were created by manually writing columns in the text area field and then hitting enter. --- lib/galaxy/tools/parameters/basic.py | 10 +++++++-- lib/galaxy_test/api/test_workflows.py | 30 ++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index 1b3e147f74c..26d10f37d7f 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -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): diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index 6f26a060ca4..76aaf2ef8a9 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -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_workflow( + """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 From a01c8c5a88debc7f9e0c7e2865a33acb9633acab Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 3 Nov 2022 10:37:49 +0100 Subject: [PATCH 2/3] Use _run_jobs instead of _run_workflows --- lib/galaxy_test/api/test_workflows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index 76aaf2ef8a9..4e719cb6bc9 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -1325,7 +1325,7 @@ steps: # 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_workflow( + job_summary = self._run_jobs( """class: GalaxyWorkflow steps: empty_output: From 494bae8dddbb9de3bc99a808ce45be01bebe9f2f Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sat, 5 Nov 2022 18:14:12 +0100 Subject: [PATCH 3/3] Revert "Use _run_jobs instead of _run_workflows" This reverts commit a01c8c5a88debc7f9e0c7e2865a33acb9633acab. _run_workflow has the right type annotations, but 21.09 didn't have this. --- lib/galaxy_test/api/test_workflows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index f5babd3e333..af60f7f644c 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -1279,7 +1279,7 @@ steps: # 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( + job_summary = self._run_workflow( """class: GalaxyWorkflow steps: empty_output: