Skip to content

Commit e1cbce7

Browse files
Discard undeclared fields from cwl.output.json
This commit discards all fields that are present in a `cwl.output.json` file but have not been declared in the `output` object of the related `CommandLineTool`, implementing common-workflow-language/cwl-v1.3#80.
1 parent 766d58b commit e1cbce7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cwltool/command_line_tool.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from mypy_extensions import mypyc_attr
2828
from ruamel.yaml.comments import CommentedMap, CommentedSeq
29-
from schema_salad.avro.schema import Schema
29+
from schema_salad.avro.schema import RecordSchema
3030
from schema_salad.exceptions import ValidationException
3131
from schema_salad.ref_resolver import file_uri, uri_file_path
3232
from schema_salad.sourceline import SourceLine
@@ -1257,7 +1257,17 @@ def collect_output_ports(
12571257

12581258
if compute_checksum:
12591259
adjustFileObjs(ret, partial(compute_checksums, fs_access))
1260-
expected_schema = cast(Schema, self.names.get_name("outputs_record_schema", None))
1260+
expected_schema = cast(RecordSchema, self.names.get_name("outputs_record_schema", None))
1261+
for k in list(ret.keys()):
1262+
found = False
1263+
for field in expected_schema.fields:
1264+
if k == field.name:
1265+
found = True
1266+
break
1267+
if not found:
1268+
if _logger.isEnabledFor(logging.WARNING):
1269+
_logger.warning(f"DIscarded undeclared `{k}` output from {custom_output}")
1270+
ret.pop(k)
12611271
validate_ex(
12621272
expected_schema,
12631273
ret,

0 commit comments

Comments
 (0)