Skip to content

Commit 7ddcbe2

Browse files
author
Alan Christie
committed
fix: Validation now takes vraiables (not workflow variables)
1 parent e4b99b4 commit 7ddcbe2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

tests/test_workflow_engine_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def start_workflow(
7676
# 2.
7777
vr_result: ValidationResult = WorkflowValidator.validate(
7878
workflow_definition=wf_definition,
79-
workflow_inputs=variables,
79+
variables=variables,
8080
level=ValidationLevel.RUN,
8181
)
8282
assert vr_result.error_num == 0

workflow/workflow_validator.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,37 @@ def validate(
3939
*,
4040
level: ValidationLevel,
4141
workflow_definition: dict[str, Any],
42-
workflow_inputs: dict[str, Any] | None = None,
42+
variables: dict[str, Any] | None = None,
4343
) -> ValidationResult:
4444
"""Validates the workflow definition (and inputs)
4545
based on the provided 'level'."""
4646
assert level in ValidationLevel
4747
assert isinstance(workflow_definition, dict)
48-
if workflow_inputs:
49-
assert isinstance(workflow_inputs, dict)
48+
if variables:
49+
assert isinstance(variables, dict)
5050

51-
# ALl levels require a schema validation
51+
# ALl levels need to pass schema validation
5252
if error := validate_schema(workflow_definition):
5353
return ValidationResult(error_num=1, error_msg=[error])
5454

55+
# Now level-specific validation...
5556
if level == ValidationLevel.RUN:
5657
run_level_result: ValidationResult = WorkflowValidator._validate_run_level(
5758
workflow_definition=workflow_definition,
58-
workflow_inputs=workflow_inputs,
59+
variables=variables,
5960
)
6061
if run_level_result.error_num:
6162
return run_level_result
6263

64+
# OK if we get here
6365
return _VALIDATION_SUCCESS
6466

6567
@classmethod
6668
def _validate_run_level(
6769
cls,
6870
*,
6971
workflow_definition: dict[str, Any],
70-
workflow_inputs: dict[str, Any] | None = None,
72+
variables: dict[str, Any] | None = None,
7173
) -> ValidationResult:
7274
assert workflow_definition
7375

@@ -107,7 +109,7 @@ def _validate_run_level(
107109
wf_variables: list[str] = get_variable_names(workflow_definition)
108110
missing_values: list[str] = []
109111
for wf_variable in wf_variables:
110-
if not workflow_inputs or wf_variable not in workflow_inputs:
112+
if not variables or wf_variable not in variables:
111113
missing_values.append(wf_variable)
112114
if missing_values:
113115
return ValidationResult(

0 commit comments

Comments
 (0)