Repository navigation
Avoid casting to list or struct dtypes in dask_cudf.read_parquet - #9314
Conversation
|
|
||
| class Index(Series, dd.core.Index): | ||
| _partition_type = cudf.Index | ||
| _partition_type = cudf.Index # type: ignore |
There was a problem hiding this comment.
This change is not related to the PR, but was added to avoid local mypy failures...
python/dask_cudf/dask_cudf/groupby.py:381: error: Need type annotation for '_global_set' (hint: "_global_set: Set[<type>] = ...")
python/dask_cudf/dask_cudf/core.py:423: error: Incompatible types in assignment (expression has type "Type[Index]", base class "Series" defined the type as "Type[Series]")
Found 2 errors in 2 files (checked 122 source files)
There was a problem hiding this comment.
I have previously encountered cases where unrelated changes to the code allow mypy's engine to discover typing errors that it previously couldn't. This mypy error looks real, but I think adding this ignore is fine for now. I assume that making dd.Index inherit from dd.Series was done for convenience at some point, and refactoring the class hierarchy is the only correct way to make this go away but is out of scope for this PR.
Codecov Report
Continue to review full report at Codecov.
|
|
@gpucibot merge |
charlesbluca
left a comment
There was a problem hiding this comment.
Looks good! Just one question regarding the additional import of pyarrow:
| for col_name, col in df._data.items(): | ||
| if col_name in schema.names and isinstance( | ||
| col, cudf.core.column.StringColumn | ||
| typ = schema.field(col_name).type |
There was a problem hiding this comment.
Any particular reason we don't opt to call cudf_dtype_from_pa_type up here, and avoid having to import pyarrow?
| typ = schema.field(col_name).type | |
| typ = cudf_dtype_from_pa_type(schema.field(col_name).type) |
| typ = schema.field(col_name).type | ||
| if ( | ||
| col_name in schema.names | ||
| and not isinstance(typ, (pa.ListType, pa.StructType)) |
There was a problem hiding this comment.
Continuation of above comment:
| and not isinstance(typ, (pa.ListType, pa.StructType)) | |
| and not isinstance(typ, (cudf.ListDtype, cudf.StructDtype)) |
| df._data[col_name] = col.astype( | ||
| cudf_dtype_from_pa_type(schema.field(col_name).type) | ||
| ) | ||
| df._data[col_name] = col.astype(cudf_dtype_from_pa_type(typ)) |
There was a problem hiding this comment.
Continuation of above comment:
| df._data[col_name] = col.astype(cudf_dtype_from_pa_type(typ)) | |
| df._data[col_name] = col.astype(typ) |
| from io import BufferedWriter, BytesIO, IOBase | ||
|
|
||
| import numpy as np | ||
| import pyarrow as pa |
There was a problem hiding this comment.
Continuation of above comment:
| import pyarrow as pa |
|
@charlesbluca, would it make sense to send these changes in a new PR? |
|
Thanks for the reminder @jakirkham! Yeah I think this is PR-worthy - I'll open one up now 🙂 |
|
Thanks Charles! 😄 For reference, theses changes are in PR ( #9429 ) |
Small follow up to #9314, which implements my review comments and removes a seemingly unnecessary import of pyarrow. cc @rjzamora @jakirkham Authors: - Charles Blackmon-Luca (https://github.com/charlesbluca) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: #9429
A similar fix for this problem was recently submitted in #9159 and closed in favor of #9203. It seems that the test added in the latter PR was not actually capturing the original problem. However, after dask#8072 is merged, the new test will certainly start failing.