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

[WIP] Make dask an optional dependency #6240

Open
wants to merge 4 commits into
base: branch-25.02
Choose a base branch
from

Conversation

jcrist
Copy link
Member

@jcrist jcrist commented Jan 21, 2025

This PR makes dask/distributed/dask_cudf/raft_dask/dask_cuda optional dependencies.

By default, an install of cuml will not include these dependencies. Users will not be able to use the functionality available in cuml.dask, but everything else will work as is.

To install cuml with dask support, users can pip or conda install the extra deps as

pip install cuml[dask]
conda install cuml-dask

Fixes #5934.

This moves all dask dependencies of `cuml` to be optional. `pip` users
can install them via a `dask` extra (e.g. `pip install cuml[dask]`),
while conda users can install them with a conda metapackage (e.g. `pip
install cuml-dask`). Dask dependency versions are pinned accordingly as
needed.
We now only install dask dependencies for the dask test runs.
- Removes dask imports from everywhere except the `cuml.dask` namespace
- Cleans up the imports in the `cuml.dask` namespace. In particular, non
  of the existing warning code was actually functional.
- Adds a nice `ImportError` for users trying to import `cuml.dask`
  without the required dependencies.
@jcrist jcrist requested review from a team as code owners January 21, 2025 22:36
@github-actions github-actions bot added conda conda issue Cython / Python Cython or Python issue ci labels Jan 21, 2025
Copy link
Member Author

@jcrist jcrist left a comment

Choose a reason for hiding this comment

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

There's still some failing tests in cuml/tests/ that rely on dask being present:

  • test_base/test_pickle: these create shared tests for all estimators, but obviously the dask tests can't run when dask isn't installed. Easiest fix would be to skip those automatically if dask isn't installed, and add these files to the dask test runs in CI so they still run somewhere.
  • test_benchmark: some benchmarks rely on dask. Could skip these if dask isn't installed?
  • test_serialize.py:test_naive_bayes_cuda: this is a dask specific test, but afaict we're just testing that dask's serializers can serialize a cuml class? This test should probably be moved into the tests/dask folder.

- cuda-cudart-dev
{% endif %}
- cuda-python
outputs:
Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't verified this recipe works at all, just based it on other recipes I've done in the past that have used multiple outputs for metapackages. Hoping CI/review will catch any issues here 🤞 .

" conda install cuml-dask # either conda install\n"
' pip install -U "cuml[dask]" # or pip install\n'
)
raise ImportError(msg) from exc
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we raise a nicer ImportError when a user tries to import something from cuml.dask when all dependencies aren't installed.

else:
warnings.warn(
"Dask not found. All Dask-based multi-GPU operation is disabled."
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This previous warnings code would never run. If a dep wasn't present, the error would occur far before here. Better to just use normal imports.

@jcrist jcrist added Build or Dep Issues related to building the code or dependencies Dask / cuml.dask Issue/PR related to Python level dask or cuml.dask features. non-breaking Non-breaking change improvement Improvement / enhancement to an existing function labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build or Dep Issues related to building the code or dependencies ci conda conda issue Cython / Python Cython or Python issue Dask / cuml.dask Issue/PR related to Python level dask or cuml.dask features. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Convert Dask into an optional dependency
1 participant