MCPcopy Create free account
hub / github.com/StackStorm/st2 / _validate

Function _validate

st2common/st2common/util/param.py:173–199  ·  view source on GitHub ↗

Validates dependency graph to ensure it has no missing or cyclic dependencies

(G)

Source from the content-addressed store, hash-verified

171
172
173def _validate(G):
174 """
175 Validates dependency graph to ensure it has no missing or cyclic dependencies
176 """
177 for name in G.nodes:
178 if "value" not in G.nodes[name] and "template" not in G.nodes[name]:
179 msg = 'Dependency unsatisfied in variable "%s"' % name
180 raise ParamException(msg)
181
182 if not nx.is_directed_acyclic_graph(G):
183 graph_cycles = nx.simple_cycles(G)
184
185 variable_names = []
186 for cycle in graph_cycles:
187 try:
188 variable_name = cycle[0]
189 except IndexError:
190 continue
191
192 variable_names.append(variable_name)
193
194 variable_names = ", ".join(sorted(variable_names))
195 msg = (
196 "Cyclic dependency found in the following variables: %s. Likely the variable is "
197 "referencing itself" % (variable_names)
198 )
199 raise ParamException(msg)
200
201
202def _render(node, render_context):

Callers 2

render_live_paramsFunction · 0.85
render_final_paramsFunction · 0.85

Calls 1

ParamExceptionClass · 0.90

Tested by

no test coverage detected