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

Reduce warnings in pytest output #10168

Merged
merged 12 commits into from
Feb 4, 2022

Conversation

bdice
Copy link
Contributor

@bdice bdice commented Jan 31, 2022

This PR reduces some warnings in pytest output.

The pyarrow warning that I silenced was occurring thousands of times during our tests but should be fixed by #9686, so I marked it with a TODO.

I just tackled a few files for now, aiming for around 100 LOC changed for ideal review size.

@bdice bdice self-assigned this Jan 31, 2022
@github-actions github-actions bot added the Python Affects Python cuDF API. label Jan 31, 2022
@bdice bdice added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change tech debt labels Jan 31, 2022
@codecov
Copy link

codecov bot commented Jan 31, 2022

Codecov Report

Merging #10168 (a2fbb64) into branch-22.04 (a7d88cd) will increase coverage by 0.05%.
The diff coverage is 0.00%.

Impacted file tree graph

@@               Coverage Diff                @@
##           branch-22.04   #10168      +/-   ##
================================================
+ Coverage         10.42%   10.47%   +0.05%     
================================================
  Files               119      122       +3     
  Lines             20603    20487     -116     
================================================
- Hits               2148     2147       -1     
+ Misses            18455    18340     -115     
Impacted Files Coverage Δ
python/cudf/cudf/_fuzz_testing/fuzzer.py 0.00% <0.00%> (ø)
python/cudf/cudf/_fuzz_testing/io.py 0.00% <0.00%> (ø)
python/cudf/cudf/_fuzz_testing/main.py 0.00% <0.00%> (ø)
python/cudf/cudf/_version.py 0.00% <0.00%> (ø)
python/cudf/cudf/comm/gpuarrow.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/_base_index.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/categorical.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/column.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/datetime.py 0.00% <ø> (ø)
python/cudf/cudf/core/column/numerical.py 0.00% <0.00%> (ø)
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e8cb4f...a2fbb64. Read the comment docs.

@bdice bdice marked this pull request as ready for review January 31, 2022 23:42
@bdice bdice requested a review from a team as a code owner January 31, 2022 23:42
@@ -29,8 +29,37 @@

@pytest.fixture(params=dtypes, ids=dtypes)
def pandas_input(request):
Copy link
Contributor Author

@bdice bdice Jan 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixture was throwing a lot of warnings about unsafe casting -- in particular, things like creating a Series with dtype int8 from data that could exceed 127 (the max random value was 1000). Instead, I implemented a function that creates random values based on the type.

@bdice bdice requested a review from vyasr February 3, 2022 05:38
@bdice
Copy link
Contributor Author

bdice commented Feb 3, 2022

pytest output on branch-22.04, gpuCI running commit b2b9232 on Python 3.9:

88729 passed, 2399 skipped, 985 xfailed, 1978 xpassed, 19524 warnings in 2314.01s (0:38:34)

Warnings on this branch (as of 99006ce, results from a local build):

88693 passed, 2401 skipped, 985 xfailed, 1978 xpassed, 3041 warnings in 618.52s (0:10:18)

Looks like this PR cuts the warning count from 19524 warnings to 3041. That's a good start!

Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some suggestions for improvement, otherwise LGTM.

python/cudf/cudf/tests/test_column.py Show resolved Hide resolved
python/cudf/cudf/tests/test_column.py Outdated Show resolved Hide resolved
python/cudf/cudf/tests/test_column.py Outdated Show resolved Hide resolved
python/cudf/cudf/tests/test_column.py Outdated Show resolved Hide resolved
python/cudf/cudf/tests/test_column.py Outdated Show resolved Hide resolved
python/cudf/cudf/tests/test_column.py Outdated Show resolved Hide resolved
Comment on lines +36 to +61
def random_ints(dtype, size):
dtype_min = np.iinfo(dtype).min
dtype_max = np.iinfo(dtype).max
return rng.integers(dtype_min, dtype_max, size=size, dtype=dtype)

try:
dtype = np.dtype(dtype)
except TypeError:
if dtype == "category":
data = random_ints(np.int64, size)
else:
raise
else:
if dtype.kind == "b":
data = rng.choice([False, True], size=size)
elif dtype.kind in ("m", "M"):
# datetime or timedelta
data = random_ints(np.int64, size)
elif dtype.kind == "U":
# Unicode strings of integers like "12345"
data = random_ints(np.int64, size).astype(dtype.str)
elif dtype.kind == "f":
# floats in [0.0, 1.0)
data = rng.random(size=size, dtype=dtype)
else:
data = random_ints(dtype, size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this could be more generally useful. Which also makes me wonder... does something like this already exist in cudf, and can we re-use that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely a good question. I plan to investigate that further and strive for de-duplication as I work through some more warnings. Lots of the warnings are affected by dtypes!

@bdice
Copy link
Contributor Author

bdice commented Feb 4, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit f654c4a into rapidsai:branch-22.04 Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants