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

Make gpuCI and pre-commit style configurations consistent #8215

Merged
merged 27 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2a7498a
Fix black, flake8 checks, attempt to fix isort
charlesbluca May 11, 2021
1b1a7e3
Fix clang-format checks
charlesbluca May 11, 2021
8eab7ab
Add new isort checks to gpuCI script
charlesbluca May 11, 2021
42ecf31
Add new isort return values to array
charlesbluca May 13, 2021
f2ad3b2
Exclude __init__.py files for isort-cudf
charlesbluca Jun 4, 2021
4cb923b
Bump isort to 5.6.0, include cython/pyi in checks
charlesbluca Jun 4, 2021
00ecc51
Bump isort to 5.6.4
charlesbluca Jun 14, 2021
220a722
Run updated hooks across codebase
charlesbluca Jun 21, 2021
bdb23db
Revert "Run updated hooks across codebase"
charlesbluca Jun 21, 2021
4bc7b69
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jun 21, 2021
c301e3f
Run hooks again
charlesbluca Jun 21, 2021
6cead3b
Temporary fix for style failures
charlesbluca Jun 22, 2021
a9f555e
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jun 24, 2021
d34eeb9
Run pre-commit hooks again
charlesbluca Jun 24, 2021
994e770
Retain old import style with isort skip
charlesbluca Jun 24, 2021
88eca4e
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jun 24, 2021
44399d3
Bump copyright on affected files
charlesbluca Jun 24, 2021
1dc0d9b
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jun 28, 2021
ab166a0
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jun 30, 2021
ef6691c
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jun 30, 2021
bb622a9
Run hooks again
charlesbluca Jun 30, 2021
323d3a5
Fix test failures
charlesbluca Jul 2, 2021
02ab8e6
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jul 2, 2021
1655435
Fix merge conflicts
charlesbluca Jul 8, 2021
31a1a23
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jul 8, 2021
3e799bd
Fix merge conflicts
charlesbluca Jul 13, 2021
367e1cd
Merge remote-tracking branch 'upstream/branch-21.08' into consistent-…
charlesbluca Jul 13, 2021
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
34 changes: 28 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.0.7
- repo: https://github.com/pycqa/isort
rev: 5.6.4
hooks:
- id: isort
alias: isort-cudf
name: isort-cudf
args: ["--settings-path=python/cudf/setup.cfg"]
charlesbluca marked this conversation as resolved.
Show resolved Hide resolved
files: python/cudf/.*
exclude: __init__.py$
types: [text]
types_or: [python, cython, pyi]
- id: isort
alias: isort-cudf-kafka
name: isort-cudf-kafka
args: ["--settings-path=python/cudf_kafka/setup.cfg"]
files: python/cudf_kafka/.*
types: [text]
types_or: [python, cython]
- id: isort
alias: isort-custreamz
name: isort-custreamz
args: ["--settings-path=python/custreamz/setup.cfg"]
files: python/custreamz/.*
- id: isort
alias: isort-dask-cudf
name: isort-dask-cudf
args: ["--settings-path=python/dask_cudf/setup.cfg"]
files: python/dask_cudf/.*
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
files: python/.*
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
alias: flake8
name: flake8
args: ["--config=python/.flake8"]
types: [python]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
files: python/.*\.py$
- id: flake8
alias: flake8-cython
name: flake8-cython
Expand Down
68 changes: 54 additions & 14 deletions ci/checks/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,77 @@ LANG=C.UTF-8
# Activate common conda env
source activate gdf

# Run isort and get results/return code
ISORT=`isort --check-only python/**/*.py`
ISORT_RETVAL=$?
# Run isort-cudf and get results/return code
ISORT_CUDF=`isort python/cudf --check-only --skip-glob *.pyx --settings-path=python/cudf/setup.cfg 2>&1`
ISORT_CUDF_RETVAL=$?

# Run isort-cudf-kafka and get results/return code
ISORT_CUDF_KAFKA=`isort python/cudf_kafka --check-only --settings-path=python/cudf_kafka/setup.cfg 2>&1`
ISORT_CUDF_KAFKA_RETVAL=$?

# Run isort-custreamz and get results/return code
ISORT_CUSTREAMZ=`isort python/custreamz --check-only --settings-path=python/custreamz/setup.cfg 2>&1`
ISORT_CUSTREAMZ_RETVAL=$?

# Run isort-dask-cudf and get results/return code
ISORT_DASK_CUDF=`isort python/dask_cudf --check-only --settings-path=python/dask_cudf/setup.cfg 2>&1`
ISORT_DASK_CUDF_RETVAL=$?

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

# Run flake8 and get results/return code
FLAKE=`flake8 --config=python/.flake8 python`
FLAKE=`flake8 --config=python/.flake8 python 2>&1`
FLAKE_RETVAL=$?

# Run flake8-cython and get results/return code
FLAKE_CYTHON=`flake8 --config=python/.flake8.cython`
FLAKE_CYTHON=`flake8 --config=python/.flake8.cython 2>&1`
FLAKE_CYTHON_RETVAL=$?

# Run mypy and get results/return code
MYPY_CUDF=`mypy --config=python/cudf/setup.cfg python/cudf/cudf`
MYPY_CUDF=`mypy --config=python/cudf/setup.cfg python/cudf/cudf 2>&1`
MYPY_CUDF_RETVAL=$?

# Run pydocstyle and get results/return code
PYDOCSTYLE=`pydocstyle --config=python/.flake8 python`
PYDOCSTYLE=`pydocstyle --config=python/.flake8 python 2>&1`
PYDOCSTYLE_RETVAL=$?

# Run clang-format and check for a consistent code format
CLANG_FORMAT=`python cpp/scripts/run-clang-format.py 2>&1`
CLANG_FORMAT_RETVAL=$?

# Output results if failure otherwise show pass
if [ "$ISORT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: isort style check; begin output\n\n"
echo -e "$ISORT"
echo -e "\n\n>>>> FAILED: isort style check; end output\n\n"
if [ "$ISORT_CUDF_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: isort-cudf style check; begin output\n\n"
echo -e "$ISORT_CUDF"
echo -e "\n\n>>>> FAILED: isort-cudf style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: isort-cudf style check\n\n"
fi

if [ "$ISORT_CUDF_KAFKA_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: isort-cudf-kafka style check; begin output\n\n"
echo -e "$ISORT_CUDF_KAFKA"
echo -e "\n\n>>>> FAILED: isort-cudf-kafka style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: isort-cudf-kafka style check\n\n"
fi

if [ "$ISORT_CUSTREAMZ_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: isort-custreamz style check; begin output\n\n"
echo -e "$ISORT_CUSTREAMZ"
echo -e "\n\n>>>> FAILED: isort-custreamz style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: isort-custreamz style check\n\n"
fi

if [ "$ISORT_DASK_CUDF_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: isort-dask-cudf style check; begin output\n\n"
echo -e "$ISORT_DASK_CUDF"
echo -e "\n\n>>>> FAILED: isort-dask-cudf style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: isort style check\n\n"
echo -e "\n\n>>>> PASSED: isort-dask-cudf style check\n\n"
fi

if [ "$BLACK_RETVAL" != "0" ]; then
Expand Down Expand Up @@ -103,7 +139,11 @@ HEADER_META=`ci/checks/headers_test.sh`
HEADER_META_RETVAL=$?
echo -e "$HEADER_META"

RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $PYDOCSTYLE_RETVAL $CLANG_FORMAT_RETVAL $HEADER_META_RETVAL $MYPY_CUDF_RETVAL)
RETVALS=(
$ISORT_CUDF_RETVAL $ISORT_CUDF_KAFKA_RETVAL $ISORT_CUSTREAMZ_RETVAL $ISORT_DASK_CUDF_RETVAL
$BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $PYDOCSTYLE_RETVAL $CLANG_FORMAT_RETVAL
$HEADER_META_RETVAL $MYPY_CUDF_RETVAL
)
IFS=$'\n'
RETVAL=`echo "${RETVALS[*]}" | sort -nr | head -n1`

Expand Down
2 changes: 1 addition & 1 deletion cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <string>
#include "cudf_kafka/kafka_consumer.hpp"

#include <cudf/io/datasource.hpp>
#include <cudf/io/csv.hpp>
#include <cudf/io/datasource.hpp>
charlesbluca marked this conversation as resolved.
Show resolved Hide resolved

namespace kafka = cudf::io::external::kafka;

Expand Down
4 changes: 2 additions & 2 deletions cpp/scripts/run-clang-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
DEFAULT_DIRS = [
charlesbluca marked this conversation as resolved.
Show resolved Hide resolved
"cpp/benchmarks",
"cpp/include",
"cpp/include/cudf",
hyperbolic2346 marked this conversation as resolved.
Show resolved Hide resolved
"cpp/include/nvtext",
"cpp/libcudf_kafka",
"cpp/src",
"cpp/tests",
"java/src/main/native",
]


Expand Down
25 changes: 8 additions & 17 deletions java/src/main/native/include/jni_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,13 @@ template <typename N_TYPE, typename J_ARRAY_TYPE, typename ACCESSOR> class nativ
return data_ptr;
}

const N_TYPE *const begin() const {
return data();
}
const N_TYPE *const begin() const { return data(); }

N_TYPE *begin() {
return data();
}
N_TYPE *begin() { return data(); }

const N_TYPE *const end() const {
return data() + size();
}
const N_TYPE *const end() const { return data() + size(); }

N_TYPE *end() {
return data() + size();
}
N_TYPE *end() { return data() + size(); }

const J_ARRAY_TYPE get_jArray() const { return orig; }

Expand Down Expand Up @@ -315,7 +307,7 @@ template <typename T> class native_jpointerArray {

int size() const noexcept { return wrapped.size(); }

T *operator[](int index) const {
T *operator[](int index) const {
if (data() == NULL) {
throw_java_exception(env, NPE_CLASS, "pointer is NULL");
}
Expand Down Expand Up @@ -754,14 +746,13 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) {
if (cudaErrorMemoryAllocation == cudaPeekAtLastError()) { \
cudaGetLastError(); \
} \
auto what = std::string("Could not allocate native memory: ") + \
(e.what() == nullptr ? "" : e.what()); \
auto what = \
std::string("Could not allocate native memory: ") + (e.what() == nullptr ? "" : e.what()); \
JNI_CHECK_THROW_NEW(env, cudf::jni::OOM_CLASS, what.c_str(), ret_val); \
} \
catch (const std::exception &e) { \
/* If jni_exception caught then a Java exception is pending and this will not overwrite it. */ \
JNI_CHECK_THROW_NEW(env, class_name, e.what(), ret_val); \
}

#define CATCH_STD(env, ret_val) \
CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val)
#define CATCH_STD(env, ret_val) CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val)
34 changes: 13 additions & 21 deletions java/src/main/native/src/AggregationJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

extern "C" {

JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env,
jclass class_object,
JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, jclass class_object,
jlong ptr) {
try {
cudf::jni::auto_set_device(env);
Expand Down Expand Up @@ -51,7 +50,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv
case 3: // MAX
ret = cudf::make_max_aggregation();
break;
//case 4 COUNT
// case 4 COUNT
case 5: // ANY
ret = cudf::make_any_aggregation();
break;
Expand Down Expand Up @@ -84,9 +83,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv
// case 18: COLLECT_LIST
// case 19: COLLECT_SET
// case 20: MERGE_LISTS
case 20:
ret = cudf::make_merge_lists_aggregation();
break;
case 20: ret = cudf::make_merge_lists_aggregation(); break;
// case 21: MERGE_SETS
// case 22: LEAD
// case 23: LAG
Expand All @@ -107,18 +104,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env
try {
cudf::jni::auto_set_device(env);

std::unique_ptr<cudf::aggregation> ret =
cudf::make_nth_element_aggregation(offset,
include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE);
std::unique_ptr<cudf::aggregation> ret = cudf::make_nth_element_aggregation(
offset, include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE);
return reinterpret_cast<jlong>(ret.release());
}
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createDdofAgg(JNIEnv *env,
jclass class_object,
jint kind,
jint ddof) {
jint kind, jint ddof) {
try {
cudf::jni::auto_set_device(env);

Expand Down Expand Up @@ -184,8 +179,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createQuantAgg(JNIEnv *e

JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv *env,
jclass class_object,
jint kind,
jint offset) {
jint kind, jint offset) {
try {
cudf::jni::auto_set_device(env);

Expand All @@ -205,9 +199,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg(JNIEnv *env,
jclass class_object,
jboolean include_nulls) {
JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg(
JNIEnv *env, jclass class_object, jboolean include_nulls) {
try {
cudf::jni::auto_set_device(env);
cudf::null_policy policy =
Expand All @@ -231,9 +224,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectSetAgg(JNIE
nulls_equal ? cudf::null_equality::EQUAL : cudf::null_equality::UNEQUAL;
cudf::nan_equality nan_equality =
nans_equal ? cudf::nan_equality::ALL_EQUAL : cudf::nan_equality::UNEQUAL;
std::unique_ptr<cudf::aggregation> ret = cudf::make_collect_set_aggregation(null_policy,
null_equality,
nan_equality);
std::unique_ptr<cudf::aggregation> ret =
cudf::make_collect_set_aggregation(null_policy, null_equality, nan_equality);
return reinterpret_cast<jlong>(ret.release());
}
CATCH_STD(env, 0);
Expand All @@ -249,8 +241,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createMergeSetsAgg(JNIEn
nulls_equal ? cudf::null_equality::EQUAL : cudf::null_equality::UNEQUAL;
cudf::nan_equality nan_equality =
nans_equal ? cudf::nan_equality::ALL_EQUAL : cudf::nan_equality::UNEQUAL;
std::unique_ptr<cudf::aggregation> ret = cudf::make_merge_sets_aggregation(null_equality,
nan_equality);
std::unique_ptr<cudf::aggregation> ret =
cudf::make_merge_sets_aggregation(null_equality, nan_equality);
return reinterpret_cast<jlong>(ret.release());
}
CATCH_STD(env, 0);
Expand Down
Loading