Skip to content

Commit

Permalink
Improved test for balancing expensive tasks (#7272)
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait authored Nov 9, 2022
1 parent 48d0c6b commit 945a847
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions distributed/tests/test_steal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,14 +1371,24 @@ def func(*args):
assert (ntasks_per_worker < ideal * 1.5).all(), (ideal, ntasks_per_worker)


def test_balance_steal_communication_heavy_tasks():
dependencies = {"a": 10, "b": 10}
@pytest.mark.parametrize(
"cost, ntasks, expect_steal",
[
pytest.param(10, 5, False, id="not enough work to steal"),
pytest.param(10, 10, True, id="enough work to steal"),
pytest.param(20, 10, False, id="not enough work for increased cost"),
],
)
def test_balance_expensive_tasks(cost, ntasks, expect_steal):
dependencies = {"a": cost, "b": cost}
dependency_placement = [["a"], ["b"]]
task_placement = [[["a", "b"]] * 10, []]
task_placement = [[["a", "b"]] * ntasks, []]

def _correct_placement(actual):
actual_task_counts = [len(placed) for placed in actual]
return sum(actual_task_counts) == 10 and actual_task_counts[1] > 0
return sum(actual_task_counts) == ntasks and (
(actual_task_counts[1] > 0) == expect_steal
)

_run_dependency_balance_test(
dependencies,
Expand Down

0 comments on commit 945a847

Please sign in to comment.