diff --git a/workflow/decoder.py b/workflow/decoder.py index 1b3b172..5a0fb8c 100644 --- a/workflow/decoder.py +++ b/workflow/decoder.py @@ -76,3 +76,17 @@ def get_variable_names(definition: dict[str, Any]) -> list[str]: output_variable["name"] for output_variable in variables.get("outputs", []) ) return wf_variable_names + + +def get_required_variable_names(definition: dict[str, Any]) -> list[str]: + """Given a Workflow definition this function returns all the names of the + variables that are required to be defined when it is RUN - i.e. + all those the user needs to provide.""" + required_variables: list[str] = [] + variables: dict[str, Any] | None = definition.get("variables") + if variables: + # For now, all inputs are required... + required_variables.extend( + input_variable["name"] for input_variable in variables.get("inputs", []) + ) + return required_variables diff --git a/workflow/workflow-schema.yaml b/workflow/workflow-schema.yaml index 29eb654..68a62d2 100644 --- a/workflow/workflow-schema.yaml +++ b/workflow/workflow-schema.yaml @@ -84,7 +84,7 @@ definitions: - name - type - # An workflow output parameter is essentially a file + # A workflow output parameter is essentially a file # taken from the output of a step with a default (as) value. workflow-output-parameter: type: object diff --git a/workflow/workflow_validator.py b/workflow/workflow_validator.py index 913e6f9..fc40dbd 100644 --- a/workflow/workflow_validator.py +++ b/workflow/workflow_validator.py @@ -5,7 +5,12 @@ from enum import Enum from typing import Any -from .decoder import get_steps, get_variable_names, validate_schema +from .decoder import ( + get_required_variable_names, + get_steps, + get_variable_names, + validate_schema, +) class ValidationLevel(Enum): @@ -153,8 +158,8 @@ def _validate_run_level( error_msg=[f"Specification is missing: {', '.join(missing_keys)}"], ) - # We must have values for all the inputs defined in the workflow. - wf_variables: list[str] = get_variable_names(workflow_definition) + # We must have values for all the variables defined in the workflow. + wf_variables: list[str] = get_required_variable_names(workflow_definition) missing_values: list[str] = [] missing_values.extend( wf_variable @@ -164,7 +169,9 @@ def _validate_run_level( if missing_values: return ValidationResult( error_num=3, - error_msg=[f"Missing input values for: {', '.join(missing_values)}"], + error_msg=[ + f"Missing workflow variable values for: {', '.join(missing_values)}" + ], ) return _VALIDATION_SUCCESS