Skip to content

Commit

Permalink
Merge pull request #16717 from mvdbeek/copy_elements
Browse files Browse the repository at this point in the history
[23.1] Copy the collection contents by default when copying a collection
  • Loading branch information
dannon authored Sep 25, 2023
2 parents 53790d0 + 73be5f3 commit 48101bf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions client/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down Expand Up @@ -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;
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
Expand Down
5 changes: 2 additions & 3 deletions lib/galaxy/webapps/galaxy/services/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
),
)

Expand Down
6 changes: 5 additions & 1 deletion lib/galaxy/workflow/run_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
EffectiveOutput,
History,
HistoryDatasetAssociation,
HistoryDatasetCollectionAssociation,
LibraryDataset,
LibraryDatasetDatasetAssociation,
WorkflowInvocation,
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy_test/api/test_history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 3 additions & 6 deletions lib/galaxy_test/api/test_workflow_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Expand Down

0 comments on commit 48101bf

Please sign in to comment.