Skip to content

Commit

Permalink
Don't flush for inner elements
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 14, 2024
1 parent 2950ae6 commit 25f8d7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/galaxy/tools/parameters/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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


Expand Down

0 comments on commit 25f8d7e

Please sign in to comment.