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

[REVIEW] Update dask make_meta changes to be compatible with dask upstream #8426

Merged
merged 4 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 10 additions & 4 deletions python/dask_cudf/dask_cudf/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@
_scalar_from_dtype,
is_arraylike,
is_scalar,
make_meta,
)

try:
from dask.dataframe.utils import make_meta_obj as make_meta_obj
except ImportError:
from dask.dataframe.utils import make_meta as make_meta_obj

try:
from dask.dataframe.dispatch import (
make_meta_dispatch as make_meta_dispatch,
)
except ImportError:
from dask.dataframe.utils import make_meta as make_meta_dispatch

import cudf
from cudf.utils.dtypes import is_string_dtype

Expand Down Expand Up @@ -121,12 +127,12 @@ def meta_nonempty_cudf(x):
return res


@make_meta.register((cudf.Series, cudf.DataFrame))
@make_meta_dispatch.register((cudf.Series, cudf.DataFrame))
def make_meta_cudf(x, index=None):
return x.head(0)


@make_meta.register(cudf.Index)
@make_meta_dispatch.register(cudf.Index)
def make_meta_cudf_index(x, index=None):
return x[:0]

Expand Down Expand Up @@ -173,7 +179,7 @@ def make_meta_object_cudf(x, index=None):
return x[:0]

if index is not None:
index = make_meta(index)
index = make_meta_dispatch(index)

if isinstance(x, dict):
return cudf.DataFrame(
Expand Down
13 changes: 7 additions & 6 deletions python/dask_cudf/dask_cudf/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
from dask.compatibility import apply
from dask.context import _globals
from dask.core import flatten
from dask.dataframe.core import Scalar, finalize, handle_out, map_partitions
from dask.dataframe.core import (
Scalar,
finalize,
handle_out,
make_meta as dask_make_meta,
map_partitions,
)
from dask.dataframe.utils import raise_on_meta_error
from dask.highlevelgraph import HighLevelGraph
from dask.optimization import cull, fuse
Expand All @@ -26,11 +32,6 @@
from dask_cudf import sorting
from dask_cudf.accessors import ListMethods

try:
from dask.dataframe.utils import make_meta_util as dask_make_meta
except ImportError:
from dask.dataframe.core import make_meta as dask_make_meta

DASK_VERSION = LooseVersion(dask.__version__)


Expand Down
12 changes: 3 additions & 9 deletions python/dask_cudf/dask_cudf/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@

import dask
from dask import dataframe as dd
from dask.dataframe.core import meta_nonempty

try:
from dask.dataframe.utils import make_meta_util as dask_make_meta
except ImportError:
from dask.dataframe.core import make_meta as dask_make_meta

from dask.dataframe.core import make_meta as dask_make_meta, meta_nonempty
from dask.utils import M

import cudf
Expand Down Expand Up @@ -827,9 +821,9 @@ def test_merging_categorical_columns():

def test_correct_meta():
try:
from dask.dataframe.utils import make_meta_util # noqa: F401
from dask.dataframe.dispatch import make_meta_obj # noqa: F401
except ImportError:
pytest.skip("need make_meta_util to be preset")
pytest.skip("need make_meta_obj to be preset")

# Need these local imports in this specific order.
# For context: https://github.com/rapidsai/cudf/issues/7946
Expand Down