Skip to content

Use existing location if a secondary file has one. #1380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import copy
import logging
import math
import os
from typing import (
IO,
Any,
Callable,
Dict,
Iterable,
List,
MutableMapping,
MutableSequence,
Expand Down Expand Up @@ -423,13 +425,47 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:

if isinstance(sfname, str):
d_location = cast(str, datum["location"])
if "/" in d_location:
sf_location = (
d_location[0 : d_location.rindex("/") + 1]
+ sfname
)
else:
sf_location = d_location + sfname
sf_location = None
if (
isinstance(datum, MutableMapping)
and "secondaryFiles" in datum
):
if isinstance(datum["secondaryFiles"], Iterable):
for existing_processed_secondaryfile in datum[
"secondaryFiles"
]:
if isinstance(
existing_processed_secondaryfile,
MutableMapping,
):
existing_processed_location = existing_processed_secondaryfile.get(
"location"
)
if (
existing_processed_location
and isinstance(
existing_processed_location, str
)
):
if (
os.path.basename(
existing_processed_location
)
== sfname
):
# the secondary file has already been processed;
# use established location
sf_location = existing_processed_secondaryfile[
"location"
]
if not sf_location:
if "/" in d_location:
sf_location = (
d_location[0 : d_location.rindex("/") + 1]
+ sfname
)
else:
sf_location = f'{d_location}{sfname}'
sfbasename = sfname
elif isinstance(sfname, MutableMapping):
sf_location = sfname["location"]
Expand Down Expand Up @@ -472,7 +508,7 @@ def addsf(
sfname,
)
elif discover_secondaryFiles and self.fs_access.exists(
sf_location
cast(str, sf_location)
):
addsf(
cast(
Expand Down