Skip to content

Commit

Permalink
Also set extension and metadata on copies of job outputs when finishi…
Browse files Browse the repository at this point in the history
…ng job
  • Loading branch information
mvdbeek committed Mar 19, 2024
1 parent be2201f commit 8f23c62
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
11 changes: 8 additions & 3 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
Task,
)
from galaxy.model.base import transaction
from galaxy.model.store import copy_dataset_instance_metadata_attributes
from galaxy.model.store.discover import MaxDiscoveredFilesExceededError
from galaxy.objectstore import ObjectStorePopulator
from galaxy.structured_app import MinimalManagerApp
Expand Down Expand Up @@ -1949,9 +1950,7 @@ def fail(message=job.info, exception=None):
]

for dataset_assoc in output_dataset_associations:
if getattr(dataset_assoc.dataset, "discovered", False):
# skip outputs that have been discovered
continue
is_discovered_dataset = getattr(dataset_assoc.dataset, "discovered", False)
context = self.get_dataset_finish_context(job_context, dataset_assoc)
# should this also be checking library associations? - can a library item be added from a history before the job has ended? -
# lets not allow this to occur
Expand All @@ -1960,6 +1959,12 @@ def fail(message=job.info, exception=None):
dataset_assoc.dataset.dataset.history_associations
+ dataset_assoc.dataset.dataset.library_associations
):
if is_discovered_dataset:
if dataset is dataset_assoc.dataset:
continue
elif dataset.extension == dataset_assoc.dataset.extension or dataset.extension == "auto":
copy_dataset_instance_metadata_attributes(dataset_assoc.dataset, dataset)
continue
output_name = dataset_assoc.name

# Handles retry internally on error for instance...
Expand Down
18 changes: 13 additions & 5 deletions lib/galaxy/model/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,11 @@ def handle_dataset_object_edit(dataset_instance, dataset_attrs):
if (
dataset_association is not dataset_instance
and dataset_association.extension == dataset_instance.extension
or dataset_association.extension == "auto"
):
dataset_association.metadata = dataset_instance.metadata
dataset_association.blurb = dataset_instance.blurb
dataset_association.peek = dataset_instance.peek
dataset_association.info = dataset_instance.info
dataset_association.tool_version = dataset_instance.tool_version
copy_dataset_instance_metadata_attributes(
source=dataset_instance, target=dataset_association
)
if job:
dataset_instance.dataset.job_id = job.id

Expand Down Expand Up @@ -3085,3 +3084,12 @@ def payload_to_source_uri(payload) -> str:
dump(store_dict, f)
source_uri = f"file://{import_json}"
return source_uri


def copy_dataset_instance_metadata_attributes(source: model.DatasetInstance, target: model.DatasetInstance) -> None:
target.metadata = source.metadata
target.blurb = source.blurb
target.peek = source.peek
target.info = source.info
target.tool_version = source.tool_version
target.extension = source.extension
2 changes: 1 addition & 1 deletion lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,7 @@ def exec_after_process(self, app, inp_data, out_data, param_dict, job=None, **kw
break
if copy_object is None:
raise exceptions.MessageException("Failed to find dataset output.")
out_data[key].copy_from(copy_object)
out_data[key].copy_from(copy_object, include_metadata=True)

def parse_environment_variables(self, tool_source):
"""Setup environment variable for inputs file."""
Expand Down

0 comments on commit 8f23c62

Please sign in to comment.