Skip to content
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
31 changes: 7 additions & 24 deletions distributed/diagnostics/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import asyncio
import logging
import warnings
from collections import defaultdict
from timeit import default_timer
from typing import ClassVar

from tlz import groupby, valmap

from dask.tokenize import tokenize
from dask.typing import Key
from dask.utils import key_split

from distributed.diagnostics.plugin import SchedulerPlugin
Expand Down Expand Up @@ -147,48 +147,31 @@ class MultiProgress(Progress):

Parameters
----------

func : Callable (deprecated)
Function that splits keys. This defaults to ``key_split`` which
aligns with naming conventions chosen in the dask project (tuples,
hyphens, etc..)

group_by : Callable | Literal["spans"] | Literal["prefix"], default: "prefix"
group_by : Callable | Literal["spans", "prefix"], default: "prefix"
How to group keys to display multiple bars. Defaults to "prefix",
which uses ``key_split`` from dask project

State
-----
Attributes
----------
keys: dict
Maps group name to set of not-yet-complete keys for that group
all_keys: dict
Maps group name to set of all keys for that group

Examples
--------
>>> split = lambda s: s.split('-')[0]
>>> p = MultiProgress(['y-2'], func=split) # doctest: +SKIP
>>> p.keys # doctest: +SKIP
{'x': {'x-1', 'x-2', 'x-3'},
'y': {'y-1', 'y-2'}}
"""

keys: dict[str, set[Key]]
all_keys: dict[str, set[Key]]

def __init__(
self,
keys,
scheduler=None,
*,
func=None,
group_by="prefix",
minimum=0,
dt=0.1,
complete=False,
):
if func is not None:
warnings.warn(
"`func` is deprecated, use `group_by`", category=DeprecationWarning
)
group_by = func
self.group_by = key_split if group_by in (None, "prefix") else group_by
self.func = None
name = f"multi-progress-{tokenize(keys, group_by, minimum, dt, complete)}"
Expand Down
14 changes: 1 addition & 13 deletions distributed/diagnostics/progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def __init__(
keys,
scheduler=None,
*,
func=None,
group_by="prefix",
interval="100ms",
complete=False,
Expand All @@ -252,13 +251,7 @@ def __init__(
self.client = weakref.ref(key.client)
break

if func is not None:
warnings.warn(
"`func` is deprecated, use `group_by` instead",
category=DeprecationWarning,
)
group_by = func
elif group_by in (None, "prefix"):
if group_by in (None, "prefix"):
group_by = key_split

self.keys = {k.key if hasattr(k, "key") else k for k in keys}
Expand Down Expand Up @@ -477,11 +470,6 @@ def progress(
futures = [futures]
if notebook is None:
notebook = is_kernel() # often but not always correct assumption
if kwargs.get("func", None) is not None:
warnings.warn(
"`func` is deprecated, use `group_by` instead", category=DeprecationWarning
)
group_by = kwargs.pop("func")
if group_by not in ("spans", "prefix") and not isinstance(group_by, Callable):
raise ValueError("`group_by` should be 'spans', 'prefix', or a Callable")
if notebook:
Expand Down
6 changes: 0 additions & 6 deletions distributed/diagnostics/tests/test_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ async def test_multiprogress_with_prefix(c, s, a, b):
assert group_names == {"inc"}


def test_multiprogress_warns():
with pytest.warns(DeprecationWarning, match="func` is deprecated, use `group_by"):
p = MultiProgress([], complete=True, func="spans")
assert p.group_by == "spans"


@gen_cluster(client=True)
async def test_robust_to_bad_plugin(c, s, a, b):
class Bad(SchedulerPlugin):
Expand Down
18 changes: 0 additions & 18 deletions distributed/diagnostics/tests/test_progress_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import pytest

from dask.utils import key_split

from distributed.client import wait
from distributed.spans import span
from distributed.utils_test import dec, gen_cluster, gen_tls_cluster, inc, throws
Expand Down Expand Up @@ -188,22 +186,6 @@ def test_multibar_with_spans(client):
assert all(f">{k}<" in v for k, v in bar_labels.items())


def test_multibar_func_warns(client):
"""Deprecate `func`, use `group_by`"""
L = client.map(inc, range(100))
L2 = client.map(dec, L)
L3 = client.map(add, L, L2)

# ensure default value if nothing is set
p = MultiProgressWidget(L3)
assert p.group_by == key_split

with pytest.warns(
DeprecationWarning, match="`func` is deprecated, use `group_by` instead"
):
MultiProgressWidget(L3, func="foo")


@gen_cluster(client=True, client_kwargs={"serializers": ["msgpack"]})
async def test_serializers(c, s, a, b):
x = c.submit(inc, 1)
Expand Down
5 changes: 0 additions & 5 deletions distributed/diagnostics/tests/test_progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ def test_progress_function_w_kwargs(client, capsys):
check_bar_completed(capsys)


def test_progress_function_warns(client):
with pytest.warns(DeprecationWarning, match="`func` is deprecated"):
progress(None, func="prefix")


def test_progress_function_raises():
with pytest.raises(ValueError, match="`group_by` should be "):
progress(None, group_by="incorrect")
Expand Down
Loading