def topological_sort_classes(self, fixture_classes): def find_dependencies(fixture_class): return fixture_class._options.dependencies.values() dependency_graph = DependencyGraph.from_vertices( fixture_classes, find_dependencies) return list(dependency_graph.topological_sort())
def topological_sort_instances(self, fixture_instances): def find_dependencies(fixture_instance): return fixture_instance.dependencies dependency_graph = DependencyGraph.from_vertices( fixture_instances, find_dependencies) return reversed(list(dependency_graph.topological_sort()))
def create_cluster_graph(cls, version_graph): clusters = [ DependencyCluster(root, contents) for root, contents in version_graph.find_components() ] return DependencyGraph.from_vertices( clusters, lambda c: c.get_dependencies(clusters))
def explain(self): if self.version_graph: print('Rendering version graph to: versions.svg') self.version_graph.render('versions') else: print('Could not compute version graph') if self.cluster_graph: print('Rendering cluster graph to: clusters.svg') self.cluster_graph.render('clusters') else: print('Could not compute cluster graph') if self.schedules is not None: def find_schedules(schedules): all_schedules = schedules[:] for schedule in schedules: all_schedules.extend( find_schedules(schedule.nested_schedules)) return all_schedules schedule_graph = DependencyGraph.from_vertices( find_schedules(self.schedules), lambda r: r.nested_schedules) print('Rendering schedule graph to: schedules.svg') schedule_graph.render('schedules') else: print('Could not compute schedule graph')
def create_version_graph_for(cls, egg, orm_control): graph = {} versions = egg.get_versions() for version in versions: cls.discover_version_graph_for(version, graph, orm_control) return DependencyGraph(graph)