From 25f8d7ec1d86dba2c16e0ade2f185fa9730090aa 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 61cb868854d6..dbe1b065a243 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2675,7 +2675,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(trans, as_dict_value): +def raw_to_galaxy(trans, as_dict_value, commit=True): app = trans.app history = trans.history @@ -2725,7 +2725,8 @@ def raw_to_galaxy(trans, as_dict_value): trans.sa_session.add(primary_data) history.stage_addition(primary_data) history.add_pending_items() - trans.sa_session.flush() + if commit: + app.model.session.commit() return primary_data else: name = as_dict_value.get("name") @@ -2745,7 +2746,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(trans, element_dict) + # Don't commit for inner elements + hda = raw_to_galaxy(trans, element_dict, commit=False) collection_builder.add_dataset(identifier, hda) else: subcollection_builder = collection_builder.get_level(identifier) @@ -2756,7 +2758,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