Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions workflow/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion workflow/workflow-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions workflow/workflow_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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