Skip to content

Commit aa0cde0

Browse files
committed
Remove sortedcontainers entirely
`Computation.code` was the only other place it was used. Doesn't seem worth the dependency for that.
1 parent f8e0ec5 commit aa0cde0

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

distributed/scheduler.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from typing import TYPE_CHECKING, Any, ClassVar, Literal, cast, overload
3535

3636
import psutil
37-
from sortedcontainers import SortedSet
3837
from tlz import (
3938
first,
4039
groupby,
@@ -854,15 +853,15 @@ class Computation:
854853

855854
start: float
856855
groups: set[TaskGroup]
857-
code: SortedSet
856+
code: dict[str, None] # a sorted set
858857
id: uuid.UUID
859858

860859
__slots__ = tuple(__annotations__)
861860

862861
def __init__(self):
863862
self.start = time()
864863
self.groups = set()
865-
self.code = SortedSet()
864+
self.code = {}
866865
self.id = uuid.uuid4()
867866

868867
@property
@@ -4268,8 +4267,8 @@ def update_graph(
42684267
computation = Computation()
42694268
self.computations.append(computation)
42704269

4271-
if code and code not in computation.code: # add new code blocks
4272-
computation.code.add(code)
4270+
if code: # add new code blocks
4271+
computation.code.setdefault(code, None)
42734272

42744273
n = 0
42754274
while len(tasks) != n: # walk through new tasks, cancel any bad deps

distributed/tests/test_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6985,7 +6985,7 @@ def fetch_comp_code(dask_scheduler):
69856985
assert len(computations) == 1
69866986
comp = computations[0]
69876987
assert len(comp.code) == 1
6988-
return comp.code[0]
6988+
return first(comp.code)
69896989

69906990
code = client.run_on_scheduler(fetch_comp_code)
69916991

@@ -7005,7 +7005,7 @@ def fetch_comp_code(dask_scheduler):
70057005
assert len(computations) == 1
70067006
comp = computations[0]
70077007
assert len(comp.code) == 1
7008-
return comp.code[0]
7008+
return first(comp.code)
70097009

70107010
code = client.run_on_scheduler(fetch_comp_code)
70117011
assert code == "<Code not available>"
@@ -7026,7 +7026,7 @@ async def test_computation_object_code_dask_persist(c, s, a, b):
70267026
comp = computations[0]
70277027
assert len(comp.code) == 1
70287028

7029-
assert comp.code[0] == test_function_code
7029+
assert first(comp.code) == test_function_code
70307030

70317031

70327032
@gen_cluster(client=True)
@@ -7047,7 +7047,7 @@ def func(x):
70477047

70487048
assert len(comp.code) == 1
70497049

7050-
assert comp.code[0] == test_function_code
7050+
assert first(comp.code) == test_function_code
70517051

70527052

70537053
@gen_cluster(client=True)
@@ -7069,7 +7069,7 @@ def func(x):
70697069
# Code is deduplicated
70707070
assert len(comp.code) == 1
70717071

7072-
assert comp.code[0] == test_function_code
7072+
assert first(comp.code) == test_function_code
70737073

70747074

70757075
@gen_cluster(client=True)
@@ -7091,7 +7091,7 @@ def func(x):
70917091
# Code is deduplicated
70927092
assert len(comp.code) == 1
70937093

7094-
assert comp.code[0] == test_function_code
7094+
assert first(comp.code) == test_function_code
70957095

70967096

70977097
@gen_cluster(client=True)
@@ -7109,7 +7109,7 @@ async def test_computation_object_code_client_map(c, s, a, b):
71097109
comp = computations[0]
71107110
assert len(comp.code) == 1
71117111

7112-
assert comp.code[0] == test_function_code
7112+
assert first(comp.code) == test_function_code
71137113

71147114

71157115
@gen_cluster(client=True)
@@ -7127,7 +7127,7 @@ async def test_computation_object_code_client_compute(c, s, a, b):
71277127
comp = computations[0]
71287128
assert len(comp.code) == 1
71297129

7130-
assert comp.code[0] == test_function_code
7130+
assert first(comp.code) == test_function_code
71317131

71327132

71337133
@gen_cluster(client=True, Worker=Nanny)

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ locket >= 1.0.0
66
msgpack >= 0.6.0
77
packaging >= 20.0
88
psutil >= 5.0
9-
sortedcontainers !=2.0.0, !=2.0.1
109
tblib >= 1.6.0
1110
toolz >= 0.8.2
1211
tornado >= 6.0.3, <6.2

0 commit comments

Comments
 (0)