Skip to content

Commit

Permalink
CI: cleanup style check(#477)
Browse files Browse the repository at this point in the history
This PR clean up the style check output by capturing both stdout and stderr. 
Also `isort` line-length is now 88, which is what `black` and `flake8` use.

Authors:
  - Mads R. B. Kristensen <[email protected]>

Approvers:
  - AJ Schmidt
  - Benjamin Zaitlen

URL: #477
  • Loading branch information
madsbk authored Dec 16, 2020
1 parent 6e6d868 commit b170b29
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
rev: 5.0.7
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: stable
rev: 19.10b0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
rev: 3.8.3
hooks:
- id: flake8
default_language_version:
Expand Down
19 changes: 14 additions & 5 deletions ci/checks/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ PATH=/opt/conda/bin:$PATH
. /opt/conda/etc/profile.d/conda.sh
conda activate rapids

# Print versions
echo -e "\nVersions:"
black --version
echo "isort, `isort --vn`"
echo "flake8, `flake8 --version`"

# Run isort and get results/return code
ISORT=`isort --recursive --check-only .`
ISORT=`isort --check-only dask_cuda 2>&1`
ISORT_RETVAL=$?

# Run black and get results/return code
BLACK=`black --check .`
BLACK=`black --check dask_cuda 2>&1`
BLACK_RETVAL=$?

# Run flake8 and get results/return code
FLAKE=`flake8 dask_cuda`
RETVAL=$?
FLAKE=`flake8 dask_cuda 2>&1`
FLAKE_RETVAL=$?

# Output results if failure otherwise show pass
if [ "$ISORT_RETVAL" != "0" ]; then
Expand All @@ -41,12 +47,15 @@ else
echo -e "\n\n>>>> PASSED: black style check\n\n"
fi

if [ "$FLAKE" != "0" ]; then
if [ "$FLAKE_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: flake8 style check; begin output\n\n"
echo -e "$FLAKE"
echo -e "\n\n>>>> FAILED: flake8 style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: flake8 style check\n\n"
fi

RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL)
IFS=$'\n'
RETVAL=`echo "${RETVALS[*]}" | sort -nr | head -n1`
exit $RETVAL
2 changes: 1 addition & 1 deletion dask_cuda/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ._version import get_versions
from .local_cuda_cluster import LocalCUDACluster
from .cuda_worker import CUDAWorker
from .local_cuda_cluster import LocalCUDACluster

__version__ = get_versions()["version"]
del get_versions
2 changes: 1 addition & 1 deletion dask_cuda/cuda_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

import dask
from distributed import Nanny
from distributed.deploy.cluster import Cluster
from distributed.proctitle import (
enable_proctitle_on_children,
enable_proctitle_on_current,
)
from distributed.deploy.cluster import Cluster
from distributed.utils import parse_bytes
from distributed.worker import parse_memory_limit

Expand Down
6 changes: 1 addition & 5 deletions dask_cuda/explicit_comms/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

import distributed.comm
from distributed import default_client, get_worker
from distributed.comm.addressing import (
parse_address,
parse_host_port,
unparse_address,
)
from distributed.comm.addressing import parse_address, parse_host_port, unparse_address

from . import utils

Expand Down
5 changes: 1 addition & 4 deletions dask_cuda/proxy_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,7 @@ def obj_pxy_dask_deserialize(header, frames):
subclass = ProxyObject
else:
subclass = pickle.loads(meta["subclass"])
return subclass(
obj=(header["proxied-header"], frames),
**header["obj-pxy-meta"],
)
return subclass(obj=(header["proxied-header"], frames), **header["obj-pxy-meta"],)


@dask.dataframe.utils.hash_object_dispatch.register(ProxyObject)
Expand Down
6 changes: 1 addition & 5 deletions dask_cuda/tests/test_device_host_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
)
from distributed.protocol.pickle import HIGHEST_PROTOCOL

from dask_cuda.device_host_file import (
DeviceHostFile,
device_to_host,
host_to_device,
)
from dask_cuda.device_host_file import DeviceHostFile, device_to_host, host_to_device

cupy = pytest.importorskip("cupy")

Expand Down
6 changes: 1 addition & 5 deletions dask_cuda/tests/test_explicit_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
from distributed import Client
from distributed.deploy.local import LocalCluster

from dask_cuda.explicit_comms import (
CommsContext,
dataframe_merge,
dataframe_shuffle,
)
from dask_cuda.explicit_comms import CommsContext, dataframe_merge, dataframe_shuffle

mp = mp.get_context("spawn")
ucp = pytest.importorskip("ucp")
Expand Down
2 changes: 1 addition & 1 deletion dask_cuda/tests/test_local_cuda_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from distributed.system import MEMORY_LIMIT
from distributed.utils_test import gen_test

from dask_cuda import LocalCUDACluster, CUDAWorker, utils
from dask_cuda import CUDAWorker, LocalCUDACluster, utils
from dask_cuda.initialize import initialize


Expand Down
7 changes: 6 additions & 1 deletion dask_cuda/tests/test_proxy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pickle
import operator
import pickle

import pandas
import pytest
from pandas.testing import assert_frame_equal

Expand Down Expand Up @@ -222,6 +223,10 @@ def task(x):
ddf = dask_cudf.from_cudf(df, npartitions=1)
ddf = ddf.map_partitions(task, meta=df.head())
got = ddf.compute()
if isinstance(got, pandas.Series):
pytest.xfail(
"BUG fixed by <https://github.com/rapidsai/dask-cuda/pull/451>"
)
assert_frame_equal(got.to_pandas(), df.to_pandas())


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ignore =
E231

[isort]
line_length=79
line_length=88
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
Expand Down

0 comments on commit b170b29

Please sign in to comment.