From 8807db4ca61509b6bfc67188f4f5ee4fa0d8bb0d Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 26 Feb 2024 13:40:17 +0000 Subject: [PATCH] Mark outputs skipped if necessary --- lib/galaxy/model/__init__.py | 12 ++++++++++++ lib/galaxy/tools/actions/__init__.py | 9 +-------- lib/galaxy/tools/actions/model_operations.py | 7 +++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 7e6bbc9a40dc..f426fb72e6e6 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -152,6 +152,7 @@ ) from galaxy.model.orm.now import now from galaxy.model.orm.util import add_object_to_object_session +from galaxy.objectstore import ObjectStorePopulator from galaxy.schema.invocation import ( InvocationCancellationUserRequest, InvocationState, @@ -4581,6 +4582,17 @@ def get_quota_source_label(self): quota_source_label = property(get_quota_source_label) + def set_skipped(self, object_store_populator: ObjectStorePopulator): + assert self.dataset + object_store_populator.set_object_store_id(self) + self.extension = "expression.json" + self.state = self.states.OK + self.blurb = "skipped" + self.visible = False + with open(self.dataset.get_file_name(), "w") as out: + out.write(json.dumps(None)) + self.set_total_size() + def get_file_name(self, sync_cache=True) -> str: if self.dataset.purged: return "" diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 8403e0137bbe..2c8f0fb354b9 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -675,14 +675,7 @@ def handle_output(name, output, hidden=None): hdca.visible = False object_store_populator = ObjectStorePopulator(trans.app, trans.user) for data in out_data.values(): - object_store_populator.set_object_store_id(data) - data.extension = "expression.json" - data.state = "ok" - data.blurb = "skipped" - data.visible = False - with open(data.dataset.get_file_name(), "w") as out: - out.write(json.dumps(None)) - data.set_total_size() + data.set_skipped(object_store_populator) job.preferred_object_store_id = preferred_object_store_id self._record_inputs(trans, tool, job, incoming, inp_data, inp_dataset_collections) self._record_outputs(job, out_data, output_collections) diff --git a/lib/galaxy/tools/actions/model_operations.py b/lib/galaxy/tools/actions/model_operations.py index a1e7230b9eeb..bedba42d4aa3 100644 --- a/lib/galaxy/tools/actions/model_operations.py +++ b/lib/galaxy/tools/actions/model_operations.py @@ -1,6 +1,7 @@ import logging from typing import TYPE_CHECKING +from galaxy.objectstore import ObjectStorePopulator from galaxy.tools.actions import ( DefaultToolAction, OutputCollections, @@ -137,8 +138,10 @@ def _produce_outputs( if skip: for output_collection in output_collections.out_collections.values(): output_collection.mark_as_populated() + object_store_populator = ObjectStorePopulator(trans.app, trans.user) for hdca in output_collections.out_collection_instances.values(): hdca.visible = False - # Would we also need to replace the datasets with skipped datasets? - + # Would we also need to replace the datasets with skipped datasets? + for data in hdca.dataset_instances: + data.set_skipped(object_store_populator) trans.sa_session.add_all(out_data.values())