From ffed1573ffb33fa54ca0263ed7cb18d8ad9d48b5 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 26 Oct 2023 09:38:17 -0400 Subject: [PATCH 1/2] When exporting a workflow, include owner's annotation if the exporting user doesn't have an overriding one. --- lib/galaxy/managers/workflows.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index 6106d0043517..8449c70f04d7 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -1337,7 +1337,12 @@ def _workflow_to_dict_export(self, trans, stored=None, workflow=None, internal=F tag_str = "" if stored is not None: if stored.id: - annotation_str = self.get_item_annotation_str(trans.sa_session, trans.user, stored) or "" + # if the active user doesn't have an annotation on the workflow, default to the owner's annotation. + annotation_str = ( + self.get_item_annotation_str(trans.sa_session, trans.user, stored) + or self.get_item_annotation_str(trans.sa_session, stored.user, stored) + or "" + ) tag_str = stored.make_tag_string_list() else: # dry run with flushed workflow objects, just use the annotation From e48e490b3a9e6659b9a5a23973a44597dd4a788c Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 26 Oct 2023 14:36:59 -0400 Subject: [PATCH 2/2] Also get owner annotations for individual steps, unless trans.user has one. It's still unclear how one would, so I'm being cautious here. --- lib/galaxy/managers/workflows.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index 8449c70f04d7..58bc7e52a2b6 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -1335,12 +1335,14 @@ def _workflow_to_dict_export(self, trans, stored=None, workflow=None, internal=F """ annotation_str = "" tag_str = "" + annotation_owner = None if stored is not None: if stored.id: # if the active user doesn't have an annotation on the workflow, default to the owner's annotation. + annotation_owner = stored.user annotation_str = ( self.get_item_annotation_str(trans.sa_session, trans.user, stored) - or self.get_item_annotation_str(trans.sa_session, stored.user, stored) + or self.get_item_annotation_str(trans.sa_session, annotation_owner, stored) or "" ) tag_str = stored.make_tag_string_list() @@ -1375,8 +1377,10 @@ def _workflow_to_dict_export(self, trans, stored=None, workflow=None, internal=F module = module_factory.from_workflow_step(trans, step) if not module: raise exceptions.MessageException(f"Unrecognized step type: {step.type}") - # Get user annotation. + # Get user annotation if it exists, otherwise get owner annotation. annotation_str = self.get_item_annotation_str(trans.sa_session, trans.user, step) or "" + if not annotation_str and annotation_owner: + annotation_str = self.get_item_annotation_str(trans.sa_session, annotation_owner, step) or "" content_id = module.get_content_id() if allow_upgrade else step.content_id # Export differences for backward compatibility tool_state = module.get_export_state()