Skip to content

Commit 468fb7c

Browse files
committed
Fix dataset export inclusion logic in invocation exports
Extracts the common logic for determining whether a dataset should be included in an export into a dedicated helper method. Applies this consistent inclusion check across different export paths, particularly for datasets and collections linked to workflow invocations. This ensures that the 'include_hidden' and 'include_deleted' flags are uniformly respected throughout the export process.
1 parent c166087 commit 468fb7c

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

lib/galaxy/model/store/__init__.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,9 @@ def export_history(
22632263
for dataset in datasets:
22642264
# Add a new "annotation" attribute so that the user annotation for the dataset can be serialized without needing the user
22652265
dataset.annotation = get_item_annotation_str(sa_session, history.user, dataset) # type: ignore[attr-defined]
2266-
should_include_file = (dataset.visible or include_hidden) and (not dataset.deleted or include_deleted)
2266+
should_include_file = self._should_include_dataset(
2267+
dataset, include_hidden=include_hidden, include_deleted=include_deleted
2268+
)
22672269
if not dataset.deleted and dataset.id in self.collection_datasets:
22682270
should_include_file = True
22692271

@@ -2301,25 +2303,44 @@ def export_library_folder_contents(
23012303
for folder in library_folder.folders:
23022304
self.export_library_folder_contents(folder, include_hidden=include_hidden, include_deleted=include_deleted)
23032305

2306+
def _should_include_dataset(
2307+
self, dataset: model.DatasetInstance, include_hidden: bool = False, include_deleted: bool = False
2308+
) -> bool:
2309+
return (dataset.visible or include_hidden) and (not dataset.deleted or include_deleted)
2310+
23042311
def export_workflow_invocation(
23052312
self, workflow_invocation: model.WorkflowInvocation, include_hidden: bool = False, include_deleted: bool = False
23062313
) -> None:
23072314
self.included_invocations.append(workflow_invocation)
23082315
for input_dataset in workflow_invocation.input_datasets:
2309-
if input_dataset.dataset:
2316+
if input_dataset.dataset and self._should_include_dataset(
2317+
input_dataset.dataset, include_hidden, include_deleted
2318+
):
23102319
self.add_dataset(input_dataset.dataset)
23112320
for output_dataset in workflow_invocation.output_datasets:
2312-
self.add_dataset(output_dataset.dataset)
2321+
if self._should_include_dataset(output_dataset.dataset, include_hidden, include_deleted):
2322+
self.add_dataset(output_dataset.dataset)
23132323
for input_dataset_collection in workflow_invocation.input_dataset_collections:
23142324
if input_dataset_collection.dataset_collection:
2315-
self.export_collection(input_dataset_collection.dataset_collection)
2325+
self.export_collection(
2326+
input_dataset_collection.dataset_collection,
2327+
include_hidden=include_hidden,
2328+
include_deleted=include_deleted,
2329+
)
23162330
for output_dataset_collection in workflow_invocation.output_dataset_collections:
2317-
self.export_collection(output_dataset_collection.dataset_collection)
2331+
self.export_collection(
2332+
output_dataset_collection.dataset_collection,
2333+
include_hidden=include_hidden,
2334+
include_deleted=include_deleted,
2335+
)
23182336
for workflow_invocation_step in workflow_invocation.steps:
23192337
for assoc in workflow_invocation_step.output_datasets:
2320-
self.add_dataset(assoc.dataset)
2338+
if self._should_include_dataset(assoc.dataset, include_hidden, include_deleted):
2339+
self.add_dataset(assoc.dataset)
23212340
for assoc in workflow_invocation_step.output_dataset_collections:
2322-
self.export_collection(assoc.dataset_collection)
2341+
self.export_collection(
2342+
assoc.dataset_collection, include_hidden=include_hidden, include_deleted=include_deleted
2343+
)
23232344

23242345
def add_job_output_dataset_associations(
23252346
self, job_id: int, name: str, dataset_instance: model.DatasetInstance

0 commit comments

Comments
 (0)