Validates dependency graph to ensure it has no missing or cyclic dependencies
(G)
| 171 | |
| 172 | |
| 173 | def _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 | |
| 202 | def _render(node, render_context): |
no test coverage detected