@@ -83,11 +83,11 @@ def _validate_tag_level(
83
83
) -> ValidationResult :
84
84
assert workflow_definition
85
85
86
- # TAG level requires that each step name is unique.
86
+ # TAG level requires that each step name is unique,
87
87
duplicate_names : set [str ] = set ()
88
88
step_names : set [str ] = set ()
89
89
for step in get_steps (workflow_definition ):
90
- step_name = step ["name" ]
90
+ step_name : str = step ["name" ]
91
91
if step_name not in duplicate_names and step_name in step_names :
92
92
duplicate_names .add (step_name )
93
93
step_names .add (step_name )
@@ -96,6 +96,40 @@ def _validate_tag_level(
96
96
error_num = 2 ,
97
97
error_msg = [f"Duplicate step names found: { ', ' .join (duplicate_names )} " ],
98
98
)
99
+ # Each step specification must be a valid JSON string.
100
+ # and contain properties for 'collection', 'job', and 'version'.
101
+ for step in workflow_definition ["steps" ]:
102
+ step_name = step ["name" ]
103
+ try :
104
+ specification = json .loads (step ["specification" ])
105
+ except json .decoder .JSONDecodeError as e :
106
+ return ValidationResult (
107
+ error_num = 3 ,
108
+ error_msg = [
109
+ f"Got JSONDecodeError decoding Step '{ step_name } ' specification: { e } "
110
+ ],
111
+ )
112
+ except TypeError as e :
113
+ return ValidationResult (
114
+ error_num = 4 ,
115
+ error_msg = [
116
+ f"Got ValidationResult decoding Step '{ step_name } ' specification: { e } "
117
+ ],
118
+ )
119
+ expected_keys : set [str ] = {"collection" , "job" , "version" }
120
+ missing_keys : list [str ] = []
121
+ missing_keys .extend (
122
+ expected_key
123
+ for expected_key in expected_keys
124
+ if expected_key not in specification
125
+ )
126
+ if missing_keys :
127
+ return ValidationResult (
128
+ error_num = 5 ,
129
+ error_msg = [
130
+ f"Step '{ step_name } ' specification is missing: { ', ' .join (missing_keys )} "
131
+ ],
132
+ )
99
133
# Workflow variables must be unique.
100
134
duplicate_names = set ()
101
135
variable_names : set [str ] = set ()
@@ -109,7 +143,7 @@ def _validate_tag_level(
109
143
variable_names .add (wf_variable_name )
110
144
if duplicate_names :
111
145
return ValidationResult (
112
- error_num = 3 ,
146
+ error_num = 6 ,
113
147
error_msg = [
114
148
f"Duplicate workflow variable names found: { ', ' .join (duplicate_names )} "
115
149
],
@@ -126,38 +160,6 @@ def _validate_run_level(
126
160
) -> ValidationResult :
127
161
assert workflow_definition
128
162
129
- # RUN level requires that each step specification is a valid JSON string.
130
- # and contains properties for 'collection', 'job', and 'version'.
131
- for step in workflow_definition ["steps" ]:
132
- try :
133
- specification = json .loads (step ["specification" ])
134
- except json .decoder .JSONDecodeError as e :
135
- return ValidationResult (
136
- error_num = 2 ,
137
- error_msg = [
138
- f"Error decoding specification, which is not valid JSON: { e } "
139
- ],
140
- )
141
- except TypeError as e :
142
- return ValidationResult (
143
- error_num = 3 ,
144
- error_msg = [
145
- f"Error decoding specification, which is not valid JSON: { e } "
146
- ],
147
- )
148
- expected_keys : set [str ] = {"collection" , "job" , "version" }
149
- missing_keys : list [str ] = []
150
- missing_keys .extend (
151
- expected_key
152
- for expected_key in expected_keys
153
- if expected_key not in specification
154
- )
155
- if missing_keys :
156
- return ValidationResult (
157
- error_num = 2 ,
158
- error_msg = [f"Specification is missing: { ', ' .join (missing_keys )} " ],
159
- )
160
-
161
163
# We must have values for all the variables defined in the workflow.
162
164
wf_variables : list [str ] = get_required_variable_names (workflow_definition )
163
165
missing_values : list [str ] = []
@@ -168,7 +170,7 @@ def _validate_run_level(
168
170
)
169
171
if missing_values :
170
172
return ValidationResult (
171
- error_num = 3 ,
173
+ error_num = 7 ,
172
174
error_msg = [
173
175
f"Missing workflow variable values for: { ', ' .join (missing_values )} "
174
176
],
0 commit comments