From baf7feff103511f6981ad90f1d90fb621c4592c3 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 14 May 2024 10:31:42 +0200 Subject: [PATCH] Don't flush for inner elements --- lib/galaxy/tools/parameters/basic.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index de2f5a26ea7d..6768b576a660 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2681,7 +2681,7 @@ def to_text(self, value): # Code from CWL branch to massage in order to be shared across tools and workflows, # and for CWL artifacts as well as Galaxy ones. -def raw_to_galaxy(app: "MinimalApp", history: "History", as_dict_value: Dict[str, Any]) -> "HistoryItem": +def raw_to_galaxy(app: "MinimalApp", history: "History", as_dict_value: Dict[str, Any], commit=True) -> "HistoryItem": object_class = as_dict_value["class"] if object_class == "File": # TODO: relative_to = "/" @@ -2728,7 +2728,8 @@ def raw_to_galaxy(app: "MinimalApp", history: "History", as_dict_value: Dict[str app.model.session.add(primary_data) history.stage_addition(primary_data) history.add_pending_items() - app.model.session.flush() + if commit: + app.model.session.commit() return primary_data else: name = as_dict_value.get("name") @@ -2748,7 +2749,8 @@ def write_elements_to_collection(has_elements, collection_builder): element_class = element_dict["class"] identifier = element_dict["identifier"] if element_class == "File": - hda = raw_to_galaxy(app, history, element_dict) + # Don't commit for inner elements + hda = raw_to_galaxy(app, history, element_dict, commit=False) collection_builder.add_dataset(identifier, hda) else: subcollection_builder = collection_builder.get_level(identifier) @@ -2759,7 +2761,8 @@ def write_elements_to_collection(has_elements, collection_builder): collection_builder.populate() history.stage_addition(hdca) history.add_pending_items() - app.model.session.flush() + if commit: + app.model.session.commit() return hdca