Skip to content

Commit ba16b65

Browse files
authored
Merge pull request #1193 from common-workflow-language/cwlprov_conf_fixes
--provenance: conformance tests fixes
2 parents c6fb488 + 286501f commit ba16b65

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

cwltool/main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,21 @@ def my_represent_none(self, data): # pylint: disable=unused-argument
836836
if runtimeContext.research_obj is not None:
837837
runtimeContext.research_obj.create_job(
838838
out, None, True)
839+
def remove_at_id(doc): # type: (MutableMapping[Text, Any]) -> None
840+
for key in list(doc.keys()):
841+
if key == '@id':
842+
del doc[key]
843+
else:
844+
value = doc[key]
845+
if isinstance(value, MutableMapping):
846+
remove_at_id(value)
847+
elif isinstance(value, MutableSequence):
848+
for entry in value:
849+
if isinstance(entry, MutableMapping):
850+
remove_at_id(entry)
851+
remove_at_id(out)
852+
visit_class(out, ("File",), functools.partial(
853+
add_sizes, runtimeContext.make_fs_access('')))
839854

840855
def loc_to_path(obj): # type: (Dict[Text, Any]) -> None
841856
for field in ("path", "nameext", "nameroot", "dirname"):

cwltool/provenance.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,12 @@ def declare_file(self, value):
545545
# Check for secondaries
546546
for sec in value.get("secondaryFiles", ()):
547547
# TODO: Record these in a specializationOf entity with UUID?
548-
(sec_entity, _, _) = self.declare_file(sec)
548+
if sec['class'] == "File":
549+
(sec_entity, _, _) = self.declare_file(sec)
550+
elif sec['class'] == "Directory":
551+
sec_entity = self.declare_directory(sec)
552+
else:
553+
raise ValueError("Got unexpected secondaryFiles value: {}".format(sec))
549554
# We don't know how/when/where the secondary file was generated,
550555
# but CWL convention is a kind of summary/index derived
551556
# from the original file. As its generally in a different format
@@ -796,10 +801,13 @@ def used_artefacts(self,
796801
base += "/" + name
797802
for key, value in job_order.items():
798803
prov_role = self.wf_ns["%s/%s" % (base, key)]
799-
entity = self.declare_artefact(value)
800-
self.document.used(
801-
process_run_id, entity, datetime.datetime.now(), None,
802-
{"prov:role": prov_role})
804+
try:
805+
entity = self.declare_artefact(value)
806+
self.document.used(
807+
process_run_id, entity, datetime.datetime.now(), None,
808+
{"prov:role": prov_role})
809+
except OSError:
810+
pass
803811

804812
def generate_output_prov(self,
805813
final_output, # type: Union[Dict[Text, Any], List[Dict[Text, Any]]]
@@ -1572,7 +1580,10 @@ def _relativise_files(self, structure):
15721580
del structure["location"]
15731581

15741582
for val in structure.values():
1575-
self._relativise_files(val)
1583+
try:
1584+
self._relativise_files(val)
1585+
except OSError:
1586+
pass
15761587
return
15771588

15781589
if isinstance(structure, (str, Text)):

0 commit comments

Comments
 (0)