Skip to content

Commit b57e5ce

Browse files
authored
Merge pull request #21142 from mvdbeek/new_datasets_when_creating_skipped_expression_tool_outputs
[25.0] Create new datasets when creating skipped database operation tool outputs
2 parents 5566adf + 82a6bdc commit b57e5ce

File tree

4 files changed

+57
-4
lines changed

4 files changed

+57
-4
lines changed

lib/galaxy/model/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4948,9 +4948,15 @@ def get_quota_source_label(self):
49484948

49494949
quota_source_label = property(get_quota_source_label)
49504950

4951-
def set_skipped(self, object_store_populator: "ObjectStorePopulator") -> None:
4951+
def set_skipped(self, object_store_populator: "ObjectStorePopulator", replace_dataset: bool) -> None:
49524952
assert self.dataset
49534953
object_store_populator.set_object_store_id(self)
4954+
if replace_dataset:
4955+
replacement = Dataset(state=Dataset.states.NEW)
4956+
replacement.object_store_id = self.dataset.object_store_id
4957+
self.dataset = replacement
4958+
self.dataset_id = None
4959+
self.dataset.object_store.create(self.dataset)
49544960
self.extension = "expression.json"
49554961
self.state = self.states.OK
49564962
self.blurb = "skipped"

lib/galaxy/tools/actions/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def handle_output(name, output, hidden=None):
737737
hdca.collection.mark_as_populated()
738738
object_store_populator = ObjectStorePopulator(trans.app, trans.user)
739739
for data in out_data.values():
740-
data.set_skipped(object_store_populator)
740+
data.set_skipped(object_store_populator, replace_dataset=False)
741741
job.preferred_object_store_id = preferred_object_store_id
742742
self._record_inputs(trans, tool, job, incoming, inp_data, inp_dataset_collections)
743743
self._record_outputs(job, out_data, output_collections)

lib/galaxy/tools/actions/model_operations.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def _produce_outputs(
178178
object_store_populator = ObjectStorePopulator(trans.app, trans.user)
179179
for hdca in output_collections.out_collection_instances.values():
180180
hdca.visible = False
181-
# Would we also need to replace the datasets with skipped datasets?
182181
for data in hdca.dataset_instances:
183-
data.set_skipped(object_store_populator)
182+
data.set_skipped(object_store_populator, replace_dataset=True)
184183
trans.sa_session.add_all(out_data.values())

lib/galaxy_test/api/test_workflows.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5639,6 +5639,54 @@ def test_run_with_default_file_in_step_inline(self):
56395639
content = self.dataset_populator.get_history_dataset_content(history_id)
56405640
assert "chr1" in content
56415641

5642+
def test_conditional_skip_on_database_operation_collection_output(self):
5643+
with self.dataset_populator.test_history() as history_id:
5644+
summary = self._run_workflow(
5645+
"""
5646+
class: GalaxyWorkflow
5647+
inputs:
5648+
input_collection: collection
5649+
steps:
5650+
filter:
5651+
tool_id: __FILTER_FAILED_DATASETS__
5652+
in:
5653+
input: input_collection
5654+
when: $(false)
5655+
""",
5656+
test_data="""
5657+
input_collection:
5658+
collection_type: list
5659+
elements:
5660+
- identifier: el1
5661+
content: "test content 1"
5662+
""",
5663+
history_id=history_id,
5664+
wait=True,
5665+
assert_ok=True,
5666+
)
5667+
invocation = self.workflow_populator.get_invocation(summary.invocation_id, step_details=True)
5668+
5669+
input_hdca_details = self.dataset_populator.get_history_collection_details(
5670+
history_id, content_id=invocation["inputs"]["0"]["id"]
5671+
)
5672+
input_hda = input_hdca_details["elements"][0]["object"]
5673+
filter_content = self.dataset_populator.get_history_dataset_content(
5674+
history_id=history_id, content_id=input_hda["id"]
5675+
)
5676+
assert "test content 1" in filter_content, f"Expected 'test content 1' in input, got: {filter_content}"
5677+
5678+
# Get the filter step output
5679+
filter_step = [s for s in invocation["steps"] if s["workflow_step_label"] == "filter"][0]
5680+
filter_output_id = filter_step["output_collections"]["output"]["id"]
5681+
hdca = self.dataset_populator.get_history_collection_details(history_id, content_id=filter_output_id)
5682+
hda = hdca["elements"][0]["object"]
5683+
5684+
# Assert that the filter output dataset contains the string 'null'
5685+
filter_content = self.dataset_populator.get_history_dataset_content(
5686+
history_id=history_id, content_id=hda["id"]
5687+
)
5688+
assert "null" in filter_content, f"Expected 'null' in filter output, got: {filter_content}"
5689+
56425690
def test_conditional_flat_crossproduct_subworkflow(self):
56435691
parent = yaml.safe_load(
56445692
"""

0 commit comments

Comments
 (0)