Skip to content

Commit

Permalink
Import tlz (#3579)
Browse files Browse the repository at this point in the history
Import from `tlz` for optional `cytoolz` support
  • Loading branch information
jakirkham authored Mar 17, 2020
1 parent 806a7e9 commit f2f82c6
Show file tree
Hide file tree
Showing 47 changed files with 64 additions and 84 deletions.
2 changes: 1 addition & 1 deletion distributed/cfexecutor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import concurrent.futures as cf
import weakref

from toolz import merge
from tlz import merge

from tornado import gen

Expand Down
2 changes: 1 addition & 1 deletion distributed/cli/dask_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from distributed.utils import deserialize_for_cli, import_term

from toolz import valmap
from tlz import valmap
from tornado.ioloop import IOLoop, TimeoutError

logger = logging.getLogger("distributed.dask_worker")
Expand Down
6 changes: 2 additions & 4 deletions distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
from dask.compatibility import apply
from dask.utils import ensure_dict, format_bytes, funcname

try:
from cytoolz import first, groupby, merge, valmap, keymap
except ImportError:
from toolz import first, groupby, merge, valmap, keymap
from tlz import first, groupby, merge, valmap, keymap

try:
from dask.delayed import single_key
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion distributed/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import dask
import tblib
from toolz import merge
from tlz import merge
from tornado import gen
from tornado.ioloop import IOLoop

Expand Down
1 change: 0 additions & 1 deletion distributed/dashboard/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from bokeh.plotting import figure
import dask
from tornado import gen
import toolz

from distributed.dashboard.utils import without_property_validation, BOKEH_VERSION
from distributed import profile
Expand Down
8 changes: 2 additions & 6 deletions distributed/dashboard/components/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
from bokeh.io import curdoc
import dask
from dask.utils import format_bytes, key_split
from toolz import pipe
from tlz import pipe
from tlz.curried import map, concat, groupby
from tornado import escape

try:
Expand Down Expand Up @@ -63,11 +64,6 @@
from distributed.diagnostics.graph_layout import GraphLayout
from distributed.diagnostics.task_stream import TaskStreamPlugin

try:
from cytoolz.curried import map, concat, groupby
except ImportError:
from toolz.curried import map, concat, groupby

if dask.config.get("distributed.dashboard.export-tool"):
from distributed.dashboard.export_tool import ExportTool
else:
Expand Down
2 changes: 1 addition & 1 deletion distributed/dashboard/components/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from bokeh.plotting import figure
import dask
from tornado import gen
import toolz
import tlz as toolz

from distributed.dashboard.components import DashboardComponent
from distributed.dashboard.utils import (
Expand Down
2 changes: 1 addition & 1 deletion distributed/dashboard/components/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from bokeh.palettes import RdBu
from bokeh.themes import Theme
from dask.utils import format_bytes
from toolz import merge, partition_all
from tlz import merge, partition_all

from distributed.dashboard.components import add_periodic_callback
from distributed.dashboard.components.shared import (
Expand Down
5 changes: 1 addition & 4 deletions distributed/dashboard/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import dask
from dask.utils import format_bytes

try:
from cytoolz import merge, merge_with
except ImportError:
from toolz import merge, merge_with
from tlz import merge, merge_with

from tornado import escape
from tornado.websocket import WebSocketHandler
Expand Down
4 changes: 2 additions & 2 deletions distributed/dashboard/tests/test_scheduler_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

pytest.importorskip("bokeh")
from toolz import first
from tlz import first
from tornado import gen
from tornado.httpclient import AsyncHTTPClient, HTTPRequest

Expand Down Expand Up @@ -624,7 +624,7 @@ def test_proxy_to_workers(c, s, a, b):
},
)
async def test_lots_of_tasks(c, s, a, b):
import toolz
import tlz as toolz

ts = TaskStream(s)
ts.update()
Expand Down
2 changes: 1 addition & 1 deletion distributed/dashboard/tests/test_worker_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

pytest.importorskip("bokeh")
import sys
from toolz import first
from tlz import first
from tornado import gen
from tornado.httpclient import AsyncHTTPClient

Expand Down
8 changes: 2 additions & 6 deletions distributed/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
import bokeh
from bokeh.io import curdoc
from tornado import web
from toolz import partition
from tlz import partition
from tlz.curried import first

try:
import numpy as np
except ImportError:
np = False


try:
from cytoolz.curried import first
except ImportError:
from toolz.curried import first

BOKEH_VERSION = LooseVersion(bokeh.__version__)
dirname = os.path.dirname(__file__)

Expand Down
2 changes: 1 addition & 1 deletion distributed/dashboard/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

from bokeh.themes import Theme
from toolz import merge
from tlz import merge

from .components.worker import (
status_doc,
Expand Down
2 changes: 1 addition & 1 deletion distributed/deploy/adaptive_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import math

from tornado.ioloop import IOLoop
import toolz
import tlz as toolz

from ..metrics import time
from ..utils import parse_timedelta, PeriodicCallback
Expand Down
2 changes: 1 addition & 1 deletion distributed/deploy/old_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from threading import Thread

from toolz import merge
from tlz import merge

from tornado import gen

Expand Down
2 changes: 1 addition & 1 deletion distributed/deploy/tests/test_spec_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from distributed.metrics import time
from distributed.utils_test import loop, cleanup # noqa: F401
from distributed.utils import is_valid_xml
import toolz
import tlz as toolz
import pytest


Expand Down
2 changes: 1 addition & 1 deletion distributed/diagnostics/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from timeit import default_timer

from toolz import groupby, valmap
from tlz import groupby, valmap

from .plugin import SchedulerPlugin
from ..utils import key_split, key_split_group, log_errors, tokey
Expand Down
2 changes: 1 addition & 1 deletion distributed/diagnostics/progress_stream.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from toolz import valmap, merge
from tlz import valmap, merge

from .progress import AllProgress

Expand Down
2 changes: 1 addition & 1 deletion distributed/diagnostics/progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import weakref

from toolz import valmap
from tlz import valmap
from tornado.ioloop import IOLoop

from .progress import format_time, Progress, MultiProgress
Expand Down
2 changes: 1 addition & 1 deletion distributed/diagnostics/tests/test_task_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from time import sleep

import pytest
from toolz import frequencies
from tlz import frequencies

from distributed import get_task_stream
from distributed.utils_test import gen_cluster, div, inc, slowinc
Expand Down
2 changes: 1 addition & 1 deletion distributed/diagnostics/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def record_display(*args):
from operator import add
import re

from toolz import valmap
from tlz import valmap

from distributed.client import wait
from distributed.worker import dumps_task
Expand Down
2 changes: 1 addition & 1 deletion distributed/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import threading
from time import sleep

import toolz
import tlz as toolz

from .metrics import time
from .utils import format_time, color_of, parse_timedelta
Expand Down
3 changes: 2 additions & 1 deletion distributed/protocol/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
Includes utilities for determining whether or not to compress
"""
from functools import partial
import logging
import random

import dask
from toolz import identity, partial
from tlz import identity

try:
import blosc
Expand Down
6 changes: 1 addition & 5 deletions distributed/protocol/core.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from functools import reduce
import logging
import operator

import msgpack

try:
from cytoolz import reduce
except ImportError:
from toolz import reduce

from .compression import compressions, maybe_compress, decompress
from .serialize import serialize, deserialize, Serialize, Serialized, extract_serialize
from .utils import frame_split_size, merge_frames, msgpack_opts
Expand Down
5 changes: 1 addition & 4 deletions distributed/protocol/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import dask
from dask.base import normalize_token

try:
from cytoolz import valmap, get_in
except ImportError:
from toolz import valmap, get_in
from tlz import valmap, get_in

import msgpack

Expand Down
2 changes: 1 addition & 1 deletion distributed/protocol/tests/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import msgpack
import numpy as np
import pytest
from toolz import identity
from tlz import identity

from distributed import wait
from distributed.protocol import (
Expand Down
17 changes: 12 additions & 5 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@
import psutil
import sortedcontainers

try:
from cytoolz import frequencies, merge, pluck, merge_sorted, first, merge_with
except ImportError:
from toolz import frequencies, merge, pluck, merge_sorted, first, merge_with
from toolz import valmap, second, compose, groupby
from tlz import (
frequencies,
merge,
pluck,
merge_sorted,
first,
merge_with,
valmap,
second,
compose,
groupby,
)
from tornado.ioloop import IOLoop

import dask
Expand Down
5 changes: 1 addition & 4 deletions distributed/stealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
from .diagnostics.plugin import SchedulerPlugin
from .utils import log_errors, parse_timedelta, PeriodicCallback

try:
from cytoolz import topk
except ImportError:
from toolz import topk
from tlz import topk

LATENCY = 10e-3
log_2 = log(2)
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import random

import pytest
from toolz import assoc
from tlz import assoc

from distributed.batched import BatchedSend
from distributed.core import listen, connect, CommClosedError
Expand Down
3 changes: 2 additions & 1 deletion distributed/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from collections import deque
from functools import partial
import gc
import logging
from operator import add
Expand All @@ -18,7 +19,7 @@
import zipfile

import pytest
from toolz import identity, isdistinct, concat, pluck, valmap, partial, first, merge
from tlz import identity, isdistinct, concat, pluck, valmap, first, merge
from tornado import gen

import dask
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_client_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

import pytest
from toolz import take
from tlz import take

from distributed import Client
from distributed.utils import CancelledError
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_failed_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from time import sleep

import pytest
from toolz import partition_all, first
from tlz import partition_all, first
from tornado import gen

from dask import delayed
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_ipython.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest import mock

import pytest
from toolz import first
from tlz import first
import tornado

from distributed import Client
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_nanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np

import pytest
from toolz import valmap, first
from tlz import valmap, first
from tornado import gen
from tornado.ioloop import IOLoop

Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_profile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import sys
import time
from toolz import first
from tlz import first
import threading

from distributed.compatibility import WINDOWS
Expand Down
Loading

0 comments on commit f2f82c6

Please sign in to comment.