Skip to content

Commit 0c8e2ee

Browse files
authored
Merge pull request #708 from common-workflow-language/name-missing-warnings
Suppress spurious "invalid fields `name`" warnings
2 parents d668116 + 9ef26af commit 0c8e2ee

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cwltool/validate_js.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ def is_expression(tool, schema):
2525
# type: (Union[CommentedMap, Any], avro.schema.Schema) -> bool
2626
return isinstance(schema, avro.schema.EnumSchema) and schema.name == "Expression" and isinstance(tool, (str, Text))
2727

28+
class SuppressLog(logging.Filter):
29+
def __init__(self, name): # type: (Text) -> None
30+
name = str(name)
31+
super(SuppressLog, self).__init__(name)
32+
33+
def filter(self, record):
34+
return False
35+
36+
_logger_validation_warnings = logging.getLogger("cwltool.validation_warnings")
37+
_logger_validation_warnings.addFilter(SuppressLog("cwltool.validation_warnings"))
38+
2839
def get_expressions(tool, schema, source_line=None):
2940
# type: (Union[CommentedMap, Any], avro.schema.Schema, SourceLine) -> List[Tuple[Text, SourceLine]]
3041
if is_expression(tool, schema):
@@ -35,7 +46,7 @@ def get_expressions(tool, schema, source_line=None):
3546
for possible_schema in schema.schemas:
3647
if is_expression(tool, possible_schema):
3748
return [(tool, source_line)]
38-
elif validate_ex(possible_schema, tool, raise_ex=False):
49+
elif validate_ex(possible_schema, tool, raise_ex=False, logger=_logger_validation_warnings):
3950
valid_schema = possible_schema
4051

4152
return get_expressions(tool, valid_schema, source_line)

0 commit comments

Comments
 (0)