Skip to content

Commit

Permalink
Handle sum of memory percentage when memory_limit is 0 (#3984)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsignell authored Jul 28, 2020
1 parent 907452b commit 7cdba1d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
17 changes: 14 additions & 3 deletions distributed/dashboard/components/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1942,9 +1942,20 @@ def update(self):
if len(self.scheduler.workers) == 0:
total_data = None
elif name == "memory_percent":
total_data = sum(
ws.metrics["memory"] for ws in self.scheduler.workers.values()
) / sum(ws.memory_limit for ws in self.scheduler.workers.values())
total_mem = sum(
ws.memory_limit for ws in self.scheduler.workers.values()
)
total_data = (
(
sum(
ws.metrics["memory"]
for ws in self.scheduler.workers.values()
)
/ total_mem
)
if total_mem
else ""
)
elif name == "cpu":
total_data = (
sum(ws.metrics["cpu"] for ws in self.scheduler.workers.values())
Expand Down
11 changes: 11 additions & 0 deletions distributed/dashboard/tests/test_scheduler_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,17 @@ def metric(worker):
assert s.workers[a.address].metrics["metric"] == -999


@gen_cluster(client=True, worker_kwargs={"memory_limit": 0})
async def test_WorkerTable_with_memory_limit_as_0(c, s, a, b):

wt = WorkerTable(s)
wt.update()
assert all(wt.source.data.values())
assert wt.source.data["name"][0] == "Total (2)"
assert wt.source.data["memory_limit"][0] == 0
assert wt.source.data["memory_percent"][0] == ""


@gen_cluster(client=True)
async def test_TaskGraph(c, s, a, b):
gp = TaskGraph(s)
Expand Down

0 comments on commit 7cdba1d

Please sign in to comment.