Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved test for balancing expensive tasks #7272

Merged
merged 2 commits into from Nov 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions distributed/tests/test_steal.py
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