Skip to content

Commit

Permalink
Merge branch 'main' into gpuci-query-planning
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzamora authored Apr 24, 2024
2 parents 63de884 + 48c418c commit 0f76817
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/additional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
timeout-minutes: 90
steps:
- name: Checkout source
uses: actions/[email protected].2
uses: actions/[email protected].3

- name: Setup Conda Environment
uses: conda-incubator/[email protected]
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout source
uses: actions/[email protected].2
uses: actions/[email protected].3

- name: Setup Conda
uses: conda-incubator/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: Build (and upload)
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].2
- uses: actions/[email protected].3
with:
fetch-depth: 0
- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].2
- uses: actions/[email protected].3
- uses: actions/setup-python@v5
with:
python-version: '3.9'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
with:
disable-autolabeler: true
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set version env
# Use a little bit of bash to extract the tag name from the GitHub ref
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
with:
disable-autolabeler: true
# Override the Release name/tag/version with the actual tag name
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run:
shell: bash -l {0}
steps:
- uses: actions/[email protected].2
- uses: actions/[email protected].3
with:
repository: dask/distributed

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
mv test_report.html test_short_report.html deploy/
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.5.0
uses: JamesIves/github-pages-deploy-action@v4.6.0
with:
branch: gh-pages
folder: deploy
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/[email protected].2
uses: actions/[email protected].3
with:
fetch-depth: 0 # Needed by codecov.io

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-gpuci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
if: github.repository == 'dask/dask'

steps:
- uses: actions/[email protected].2
- uses: actions/[email protected].3

- name: Parse current axis YAML
id: rapids_current
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
outputs:
test-upstream: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/[email protected].2
- uses: actions/[email protected].3
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
Expand All @@ -47,7 +47,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/[email protected].2
uses: actions/[email protected].3

- name: Setup Conda Environment
uses: conda-incubator/[email protected]
Expand Down
12 changes: 12 additions & 0 deletions dask/dataframe/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ def test_concat_unions_categoricals():
tm.assert_frame_equal(_concat(frames5), pd.concat(frames6))


@pytest.mark.gpu
def test_unknown_categories_cudf():
# We should always start with unknown categories
# if `clear_known_categories` is working.
pytest.importorskip("dask_cudf")

with dask.config.set({"dataframe.backend": "cudf"}):
ddf = dd.from_dict({"a": [0, 1, 0]}, npartitions=1)
ddf["a"] = ddf["a"].astype("category")
assert not ddf["a"].cat.known


# TODO: Remove the filterwarnings below
@pytest.mark.parametrize(
"numeric_only",
Expand Down
13 changes: 7 additions & 6 deletions dask/dataframe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
)
from dask.dataframe._compat import PANDAS_GE_150, tm # noqa: F401
from dask.dataframe.dispatch import ( # noqa : F401
is_categorical_dtype_dispatch,
make_meta,
make_meta_obj,
meta_nonempty,
Expand Down Expand Up @@ -283,22 +284,22 @@ def clear_known_categories(x, cols=None, index=True, dtype_backend=None):
# categorical accessor is not yet available
return x

if isinstance(x, (pd.Series, pd.DataFrame)):
if not is_index_like(x):
x = x.copy()
if isinstance(x, pd.DataFrame):
if is_dataframe_like(x):
mask = x.dtypes == "category"
if cols is None:
cols = mask[mask].index
elif not mask.loc[cols].all():
raise ValueError("Not all columns are categoricals")
for c in cols:
x[c] = x[c].cat.set_categories([UNKNOWN_CATEGORIES])
elif isinstance(x, pd.Series):
if isinstance(x.dtype, pd.CategoricalDtype):
elif is_series_like(x):
if is_categorical_dtype_dispatch(x.dtype):
x = x.cat.set_categories([UNKNOWN_CATEGORIES])
if index and isinstance(x.index, pd.CategoricalIndex):
if index and is_categorical_dtype_dispatch(x.index.dtype):
x.index = x.index.set_categories([UNKNOWN_CATEGORIES])
elif isinstance(x, pd.CategoricalIndex):
elif is_categorical_dtype_dispatch(x.dtype):
x = x.set_categories([UNKNOWN_CATEGORIES])
return x

Expand Down

0 comments on commit 0f76817

Please sign in to comment.