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

Who has has what html reprs v2 #4865

Merged
merged 8 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
)
from .diagnostics.plugin import UploadFile, WorkerPlugin, _get_worker_plugin_name
from .metrics import time
from .objects import HasWhat, WhoHas
from .protocol import to_serialize
from .protocol.pickle import dumps, loads
from .publish import Datasets
Expand Down Expand Up @@ -3205,7 +3206,11 @@ def who_has(self, futures=None, **kwargs):
keys = list(map(stringify, {f.key for f in futures}))
else:
keys = None
return self.sync(self.scheduler.who_has, keys=keys, **kwargs)

async def _():
return WhoHas(await self.scheduler.who_has(keys=keys, **kwargs))

return self.sync(_)

def has_what(self, workers=None, **kwargs):
"""Which keys are held by which workers
Expand Down Expand Up @@ -3239,7 +3244,11 @@ def has_what(self, workers=None, **kwargs):
workers = list(workers)
if workers is not None and not isinstance(workers, (tuple, list, set)):
workers = [workers]
return self.sync(self.scheduler.has_what, workers=workers, **kwargs)

async def _():
return HasWhat(await self.scheduler.has_what(workers=workers, **kwargs))

return self.sync(_)

def processing(self, workers=None):
"""The tasks currently running on each worker
Expand Down
5 changes: 3 additions & 2 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3656,13 +3656,14 @@ async def test_async_whowhat(c, s, a, b):

who_has = await c.who_has()
has_what = await c.has_what()
assert type(who_has) is WhoHas
assert type(has_what) is HasWhat

assert who_has == {x.key: (a.address,)}
assert has_what == {a.address: (x.key,), b.address: ()}


@pytest.mark.xfail(reason="Want to fix to use `WhoHas` + `WhatHas`")
def test_client_repr(c):
def test_client_repr_html(c):
x = c.submit(inc, 1)

who_has = c.who_has()
Expand Down