From 70a1ca23314abf0c679920767110a1150496ef1e Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 21 Sep 2023 12:05:49 +0200 Subject: [PATCH 1/4] Copy the collection contents by default when copying a collection That got left out when creating the new multi history view. Fixes https://github.com/galaxyproject/galaxy/issues/16716 and https://github.com/galaxyproject/galaxy/issues/16619. --- client/src/schema/schema.ts | 6 +++--- lib/galaxy/schema/schema.py | 2 +- lib/galaxy/webapps/galaxy/services/history_contents.py | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/schema/schema.ts b/client/src/schema/schema.ts index 891b4bd83eb0..ea4c0b7fab7b 100644 --- a/client/src/schema/schema.ts +++ b/client/src/schema/schema.ts @@ -2445,8 +2445,8 @@ export interface components { content?: string | string; /** * Copy Elements - * @description If the source is a collection, whether to copy child HDAs into the target history as well, defaults to False but this is less than ideal and may be changed in future releases. - * @default false + * @description If the source is a collection, whether to copy child HDAs into the target history as well. Prior to the galaxy release 23.1 this defaulted to false. + * @default true */ copy_elements?: boolean; /** @@ -2616,7 +2616,7 @@ export interface components { /** * Copy Elements * @description Whether to create a copy of the source HDAs for the new collection. - * @default false + * @default true */ copy_elements?: boolean; /** diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index ca0d2b03210a..3ecfb60e3043 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -1366,7 +1366,7 @@ class CreateNewCollectionPayload(Model): description="Whether to mark the original HDAs as hidden.", ) copy_elements: Optional[bool] = Field( - default=False, + default=True, title="Copy Elements", description="Whether to create a copy of the source HDAs for the new collection.", ) diff --git a/lib/galaxy/webapps/galaxy/services/history_contents.py b/lib/galaxy/webapps/galaxy/services/history_contents.py index 0254f92001f7..65313e1af02b 100644 --- a/lib/galaxy/webapps/galaxy/services/history_contents.py +++ b/lib/galaxy/webapps/galaxy/services/history_contents.py @@ -239,12 +239,11 @@ class CreateHistoryContentPayloadFromCollection(CreateHistoryContentPayloadFromC description="TODO", ) copy_elements: Optional[bool] = Field( - default=False, + default=True, title="Copy Elements", description=( "If the source is a collection, whether to copy child HDAs into the target " - "history as well, defaults to False but this is less than ideal and may " - "be changed in future releases." + "history as well. Prior to the galaxy release 23.1 this defaulted to false." ), ) From 9860ebeeea2beabdb31f80d9c320cfc1ae3283d8 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 21 Sep 2023 12:52:54 +0200 Subject: [PATCH 2/4] Also copy contents to history when send to new history is active --- lib/galaxy/workflow/run_request.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/workflow/run_request.py b/lib/galaxy/workflow/run_request.py index 37670ead736c..e6ade4609703 100644 --- a/lib/galaxy/workflow/run_request.py +++ b/lib/galaxy/workflow/run_request.py @@ -14,6 +14,7 @@ EffectiveOutput, History, HistoryDatasetAssociation, + HistoryDatasetCollectionAssociation, LibraryDataset, LibraryDatasetDatasetAssociation, WorkflowInvocation, @@ -400,7 +401,10 @@ def build_workflow_run_configs( f"Unknown workflow input source '{input_source}' specified." ) if add_to_history and content.history != history: - content = content.copy(flush=False) + if isinstance(content, HistoryDatasetCollectionAssociation): + content = content.copy(element_destination=history, flush=False) + else: + content = content.copy(flush=False) history.stage_addition(content) input_dict["content"] = content except AssertionError: From 05f6cae73b3a908adc4a51c5a5754b910a3de3fb Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 21 Sep 2023 14:52:43 +0200 Subject: [PATCH 3/4] Update API test case for new collection copy default --- lib/galaxy_test/api/test_history_contents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy_test/api/test_history_contents.py b/lib/galaxy_test/api/test_history_contents.py index d35964ebeedf..74be58604d08 100644 --- a/lib/galaxy_test/api/test_history_contents.py +++ b/lib/galaxy_test/api/test_history_contents.py @@ -553,7 +553,7 @@ def test_hdca_copy(self, history_id): assert len(contents) == 1 new_forward, _ = self.__get_paired_response_elements(history_id, contents[0]) self._assert_has_keys(new_forward, "history_id") - assert new_forward["history_id"] == history_id + assert new_forward["history_id"] == second_history_id def test_hdca_copy_with_new_dbkey(self, history_id): fetch_response = self.dataset_collection_populator.create_pair_in_history(history_id, wait=True).json() From 73be5f3b7b91579d2a3678bdf7552f4268b500bf Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 22 Sep 2023 13:03:48 +0200 Subject: [PATCH 4/4] Fix test_extract_copied_mapping_from_history ... by copying the history instead of its contents. With the change of copying hdca contents by default we'd otherwise have find the right hids, which isn't really what this test is about. --- lib/galaxy_test/api/test_workflow_extraction.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/galaxy_test/api/test_workflow_extraction.py b/lib/galaxy_test/api/test_workflow_extraction.py index c3327c0f32b3..f8f5c939852e 100644 --- a/lib/galaxy_test/api/test_workflow_extraction.py +++ b/lib/galaxy_test/api/test_workflow_extraction.py @@ -97,17 +97,14 @@ def test_extract_mapping_workflow_from_history(self, history_id): self.__assert_looks_like_randomlines_mapping_workflow(downloaded_workflow) def test_extract_copied_mapping_from_history(self, history_id): - old_history_id = self.dataset_populator.new_history() - hdca, job_id1, job_id2 = self.__run_random_lines_mapped_over_pair(old_history_id) + hdca, job_id1, job_id2 = self.__run_random_lines_mapped_over_pair(history_id) - old_contents = self._history_contents(old_history_id) - for old_content in old_contents: - self.__copy_content_to_history(history_id, old_content) + new_history_id = self.dataset_populator.copy_history(history_id).json()["id"] # API test is somewhat contrived since there is no good way # to retrieve job_id1, job_id2 like this for copied dataset # collections I don't think. downloaded_workflow = self._extract_and_download_workflow( - history_id, + new_history_id, dataset_collection_ids=[hdca["hid"]], job_ids=[job_id1, job_id2], )