diff --git a/lib/galaxy/job_execution/actions/post.py b/lib/galaxy/job_execution/actions/post.py index 8d7de45db58..62d168ce6b5 100644 --- a/lib/galaxy/job_execution/actions/post.py +++ b/lib/galaxy/job_execution/actions/post.py @@ -55,11 +55,13 @@ class EmailAction(DefaultJobAction): try: frm = app.config.email_from history_id_encoded = app.security.encode_id(job.history_id) - invocation_id_encoded = app.security.encode_id(job.workflow_invocation_step.workflow_invocation_id) + link_invocation = None + if job.workflow_invocation_step: + invocation_id_encoded = app.security.encode_id(job.workflow_invocation_step.workflow_invocation_id) + link_invocation = ( + f"{app.config.galaxy_infrastructure_url}/workflows/invocations/report?id={invocation_id_encoded}" + ) link = f"{app.config.galaxy_infrastructure_url}/histories/view?id={history_id_encoded}" - link_invocation = ( - f"{app.config.galaxy_infrastructure_url}/workflows/invocations/report?id={invocation_id_encoded}" - ) if frm is None: if action.action_arguments and "host" in action.action_arguments: host = action.action_arguments["host"] @@ -70,7 +72,8 @@ class EmailAction(DefaultJobAction): subject = f"Galaxy job completion notification from history '{job.history.name}'" outdata = ",\n".join(ds.dataset.display_name() for ds in job.output_datasets) body = f"Your Galaxy job generating dataset(s):\n\n{outdata}\n\nis complete as of {datetime.datetime.now().strftime('%I:%M')}. Click the link below to access your data: \n{link}" - body += f"\n\nWorkflow Invocation Report:\n{link_invocation}" + if link_invocation: + body += f"\n\nWorkflow Invocation Report:\n{link_invocation}" send_mail(frm, to, subject, body, app.config) except Exception as e: log.error("EmailAction PJA Failed, exception: %s", unicodify(e)) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index ec1b4d7085b..64f7977a1c6 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -3578,7 +3578,7 @@ class SortTool(DatabaseOperationTool): sorttype = incoming["sort_type"]["sort_type"] new_elements = {} elements = hdca.collection.elements - presort_elements = [] + presort_elements = None if sorttype == "alpha": presort_elements = [(dce.element_identifier, dce) for dce in elements] elif sorttype == "numeric": @@ -3603,7 +3603,7 @@ class SortTool(DatabaseOperationTool): else: raise Exception(f"Unknown sort_type '{sorttype}'") - if presort_elements: + if presort_elements is not None: sorted_elements = [x[1] for x in sorted(presort_elements, key=lambda x: x[0])] for dce in sorted_elements: diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index 4f7f4c82100..de4535a59bd 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -6108,6 +6108,44 @@ input: put_response = self._update_workflow(workflow_id, workflow_object) assert put_response.status_code == 200 + def test_empty_collection_sort(self, history_id): + self._run_workflow( + """class: GalaxyWorkflow +inputs: + input: collection + filter_file: data +steps: + filter_collection: + tool_id: __FILTER_FROM_FILE__ + in: + input: input + how|filter_source: filter_file + sort_collection_1: + tool_id: __SORTLIST__ + in: + input: filter_collection/output_filtered + sort_collection_2: + tool_id: __SORTLIST__ + in: + input: filter_collection/output_discarded + merge_collection: + tool_id: __MERGE_COLLECTION__ + in: + inputs_0|input: sort_collection_1/output + inputs_1|input: sort_collection_2/output +test_data: + input: + collection_type: list + elements: + - identifier: i1 + content: "0" + filter_file: i1 +""", + history_id=history_id, + wait=True, + assert_ok=True, + ) + @skip_without_tool("random_lines1") def test_run_replace_params_over_default_delayed(self): with self.dataset_populator.test_history() as history_id: