def test_all(g: Graph) -> None: tasks = [f"windows10/opt-{chr(i)}" for i in range(len(g.vs))] try: test_scheduling.close_failing_together_db("label") except AssertionError: pass test_scheduling.remove_failing_together_db("label") # TODO: Also add some couples that are *not* failing together. ft: Dict[str, Dict[str, Tuple[float, float]]] = {} for edge in g.es: task1 = tasks[edge.tuple[0]] task2 = tasks[edge.tuple[1]] assert task1 < task2 if task1 not in ft: ft[task1] = {} ft[task1][task2] = (0.1, 1.0) failing_together = test_scheduling.get_failing_together_db("label", False) for t, ts in ft.items(): failing_together[t.encode("ascii")] = pickle.dumps(ts) test_scheduling.close_failing_together_db("label") model = TestLabelSelectModel() result = model.reduce(tasks, 1.0) hypothesis.note(f"Result: {sorted(result)}") assert len(result) == len(g.components())
def test_reduce3(failing_together: LMDBDict) -> None: test_scheduling.remove_failing_together_db("label") failing_together = test_scheduling.get_failing_together_db("label") failing_together[b"windows10/opt-a"] = pickle.dumps({ "windows10/opt-b": (0.1, 1.0), "windows10/opt-c": (0.1, 0.3), "windows10/opt-d": (0.1, 1.0), }) failing_together[b"windows10/opt-b"] = pickle.dumps({ "windows10/opt-c": (0.1, 1.0), "windows10/opt-d": (0.1, 0.3), }) failing_together[b"windows10/opt-c"] = pickle.dumps({ "windows10/opt-d": (0.1, 1.0), }) model = TestLabelSelectModel() result = model.reduce( { "windows10/opt-a", "windows10/opt-b", "windows10/opt-c", "windows10/opt-d" }, 1.0, ) assert (result == { "windows10/opt-a", "windows10/opt-c", } or result == { "windows10/opt-d", "windows10/opt-c", } or result == { "windows10/opt-b", "windows10/opt-c", } or result == { "windows10/opt-b", "windows10/opt-d", })