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

Fix warnings in remaining modules #12406

Merged
merged 27 commits into from
Dec 21, 2022

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Dec 17, 2022

Description

Contributes to #9999 and #10363.

When I merge these changes with #12369 I no longer see any warnings on my machine. I suspect that there will be slightly different results on different machines, so we'll see have to see how CI looks after both PRs are merged before we close #10363.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@vyasr vyasr added 3 - Ready for Review Ready for review by team tests Unit testing for project code quality Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function labels Dec 17, 2022
@vyasr vyasr added the non-breaking Non-breaking change label Dec 17, 2022
@vyasr vyasr self-assigned this Dec 17, 2022
@vyasr vyasr requested a review from a team as a code owner December 17, 2022 01:22
@vyasr vyasr added this to PR-WIP in v23.02 Release via automation Dec 17, 2022
@codecov
Copy link

codecov bot commented Dec 17, 2022

Codecov Report

Base: 86.58% // Head: 85.71% // Decreases project coverage by -0.86% ⚠️

Coverage data is based on head (567032a) compared to base (b6dccb3).
Patch has no changes to coverable lines.

Additional details and impacted files
@@               Coverage Diff                @@
##           branch-23.02   #12406      +/-   ##
================================================
- Coverage         86.58%   85.71%   -0.87%     
================================================
  Files               155      155              
  Lines             24368    24798     +430     
================================================
+ Hits              21098    21255     +157     
- Misses             3270     3543     +273     
Impacted Files Coverage Δ
python/cudf/cudf/_version.py 1.41% <0.00%> (-98.59%) ⬇️
python/cudf/cudf/core/buffer/spill_manager.py 72.50% <0.00%> (-7.50%) ⬇️
python/cudf/cudf/core/buffer/spillable_buffer.py 90.04% <0.00%> (-2.81%) ⬇️
python/cudf/cudf/utils/dtypes.py 77.77% <0.00%> (-1.69%) ⬇️
python/cudf/cudf/options.py 86.11% <0.00%> (-1.59%) ⬇️
python/cudf/cudf/core/single_column_frame.py 94.30% <0.00%> (-1.27%) ⬇️
...ython/custreamz/custreamz/tests/test_dataframes.py 98.38% <0.00%> (-1.01%) ⬇️
python/dask_cudf/dask_cudf/io/parquet.py 91.81% <0.00%> (-0.59%) ⬇️
python/cudf/cudf/core/multiindex.py 91.66% <0.00%> (-0.51%) ⬇️
python/cudf/cudf/core/algorithms.py 90.00% <0.00%> (-0.48%) ⬇️
... and 36 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

pandas compat changes LGTM

v23.02 Release automation moved this from PR-WIP to PR-Reviewer approved Dec 19, 2022
@@ -1010,9 +1010,13 @@ def __init__(
) -> None:
if isinstance(path, str) and path.startswith("s3://"):
self.fs_meta = {"is_s3": True, "actual_path": path}
self.path = tempfile.TemporaryDirectory().name
self.dir_: Optional[
Copy link
Contributor

Choose a reason for hiding this comment

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

How do type declarations work here? Is the type only declared in one branch of the if, or is it assumed that a type definition in one branch of the if also applies to the other else clause? Is it possible/better to forward-declare the type of self.dir_ before entering the if/else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, types in both branches must be the same. That is how mypy always works. Here's an example (I'm using sys.argv rather than a trivial if True because mypy is smart enough to ignore unreachable branches).

# test.py
import sys
if len(sys.argv) > 2:
    x = 1
else:
    x = "hello"

results in

(main) dt08% mypy test.py
test.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]

Note that in this example I didn't even bother annotating the type, mypy just inferred the types and noticed the incompatibility.

It is possible to forward-declare the type, but it's not something I've seen done much and not anywhere in cudf except for class members. I would be open to discussing that change, but it's out of scope for this PR since only doing it here would be inconsistent with typing everywhere else in cudf (which is already fairly inconsistent at the moment).

@@ -10,6 +10,8 @@

import cudf

pytestmark = pytest.mark.filterwarnings("ignore::FutureWarning")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this only ignore FutureWarnings from a particular package (or small set of packages), like cudf or pandas? You can specify the module name as part of this ignore syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could do that, but I didn't see much value in it. Currently IIRC the list would be cudf, pandas, and numpy (pandas uses a deprecated numpy API somewhere in one example), but in principle it could also come from any other deprecated API that pandas calls and doesn't intercept the warning for, for instance. Given how much of our examples are copied straight from pandas, and since in examples we don't have the flexibility to insert things like warnings.simplefilter where needed, I don't think it's worthwhile to overthink how we suppress the warnings. Dealing with those when they break seems good enough to me.

@vyasr
Copy link
Contributor Author

vyasr commented Dec 21, 2022

@bdice given your approval I'm going to merge to keep things moving along, but happy to continue either of the above discussions in follow-ups if you think there's a worthwhile change to be made.

@vyasr
Copy link
Contributor Author

vyasr commented Dec 21, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 1d81fbb into rapidsai:branch-23.02 Dec 21, 2022
v23.02 Release automation moved this from PR-Reviewer approved to Done Dec 21, 2022
@vyasr vyasr deleted the fix/warnings_next branch December 21, 2022 14:37
rapids-bot bot pushed a commit that referenced this pull request Jan 5, 2023
This PR fixes a final few warnings introduced in PRs merged after #12406 or with changes that weren't merged into #12406. More importantly, this PR updates the testing suite to always raise uncaught warnings as errors. This is a substantial change to the testing suite that will allow us to proactively react to deprecations in our dependencies, identify areas where pandas/pyarrow/some other dependency handles input data in different ways than us, etc. I've opted for the strictest possible setting, but am open to reviewer requests to be a little more lax with certain classes of warnings.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Matthew Roeschke (https://github.com/mroeschke)

URL: #12468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API. tests Unit testing for project
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[FEA] Remove FutureWarnings from Python tests
3 participants