Skip to content

Commit

Permalink
Merge pull request #18179 from mvdbeek/fix_extra_files_dir_only_colle…
Browse files Browse the repository at this point in the history
…ction_pulsar

[24.0] Don't fail metadata if we only have an extra output files dir
  • Loading branch information
jmchilton authored May 23, 2024
2 parents 326e291 + e80204e commit 37aeadd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
29 changes: 20 additions & 9 deletions lib/galaxy/metadata/set_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,26 @@ def set_meta(new_dataset_instance, file_dict):
external_filename = unnamed_id_to_path.get(dataset_instance_id, dataset_filename_override)
if not os.path.exists(external_filename):
matches = glob.glob(external_filename)
assert len(matches) == 1, f"{len(matches)} file(s) matched by output glob '{external_filename}'"
external_filename = matches[0]
assert safe_contains(
tool_job_working_directory, external_filename
), f"Cannot collect output '{external_filename}' from outside of working directory"
created_from_basename = os.path.relpath(
external_filename, os.path.join(tool_job_working_directory, "working")
)
dataset.dataset.created_from_basename = created_from_basename
if matches:
assert len(matches) == 1, f"{len(matches)} file(s) matched by output glob '{external_filename}'"
external_filename = matches[0]
assert safe_contains(
tool_job_working_directory, external_filename
), f"Cannot collect output '{external_filename}' from outside of working directory"
created_from_basename = os.path.relpath(
external_filename, os.path.join(tool_job_working_directory, "working")
)
dataset.dataset.created_from_basename = created_from_basename
elif os.path.exists(dataset_path_to_extra_path(external_filename)):
# Only output is extra files dir, but no primary output file, that's fine,
# but make sure we create an empty primary output file. It's a little
# weird to do this, but it does indicate that there's nothing wrong with the file,
# as opposed to perhaps a storage issue.
with open(external_filename, "wb"):
pass
else:
raise Exception(f"Output file '{external_filename}' not found")

# override filename if we're dealing with outputs to working directory and dataset is not linked to
link_data_only = metadata_params.get("link_data_only")
if not link_data_only:
Expand Down
1 change: 0 additions & 1 deletion test/functional/tools/composite_output.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<tool id="composite_output" name="composite_output" version="1.0.0">
<command><![CDATA[
touch '$output' &&
mkdir '$output.extra_files_path' &&
cp '$input.extra_files_path'/* '$output.extra_files_path' &&
cp '$input.extra_files_path'/Log '$output.extra_files_path'/second_log &&
Expand Down
1 change: 0 additions & 1 deletion test/functional/tools/composite_output_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<command>
mkdir '$output.files_path';
mkdir '$output.files_path/output';
touch '$output';
cp '$input.extra_files_path'/* '$output.files_path';
echo "1 2 3" > '$output.files_path/md5out';
echo "1" > '$output.extra_files_path/output/1';
Expand Down

0 comments on commit 37aeadd

Please sign in to comment.