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

resolve deprecation warning about serialize_for_cli() #303

Merged
merged 3 commits into from
Aug 11, 2021
Merged

resolve deprecation warning about serialize_for_cli() #303

merged 3 commits into from
Aug 11, 2021

Conversation

jameslamb
Copy link
Member

In recent versions of dask and distributed, some utility functions were moved from distributed to dask.

For example, if you use dask=2021.7.2, distributed=20121.7.2, and dask-cloudprovider=2021.6.0, you will see the following warning.

.../python3.8/site-packages/dask_cloudprovider/generic/vmcluster.py:14: FutureWarning: serialize_for_cli is deprecated and will be removed in a future release. Please use dask.config.serialize instead.
from distributed.utils import warn_on_duration, serialize_for_cli, cli_keywords

This can be reproduced with the following (run from anywhere except the root of this repo), for example:

pip install --upgrade \
    'dask==2021.7.2' \
    'distributed==2021.7.2' \
    'dask-cloudprovider==2021.6.0'

python -c "import dask_cloudprovider.generic.vmcluster"

This PR proposes a change to suppress that warning and to protect future releases of dask-cloudprovider from being broken when serialize_for_cli() is eventually removed from distributed.

How I tested this

I used FargateCluster with dask=2021.7.2 and distributed=2021.7.2 to test these changes. Confirmed that after this change, the following code does not raise the deprecation warning, that it creates the cluster successfully, and that a small task like creating and taking the mean of a Dask array is successfully run out on the cluster.

import os
import dask.array as da
from dask.distributed import Client
from dask_cloudprovider.aws import FargateCluster

os.environ["AWS_DEFAULT_REGION"] = "us-west-2"
n_workers = 3
cluster = FargateCluster(
    image="daskdev/dask:2021.7.2",
    worker_cpu=512,
    worker_mem=4096,
    n_workers=n_workers,
    fargate_use_private_ip=False,
    scheduler_timeout="40 minutes",
    find_address_timeout=60 * 10,
)
client = Client(cluster)
client.wait_for_workers(n_workers)

print(f"View dashboard: {cluster.dashboard_link}")

X = da.random.random((1e6, 10), chunks=(1e3, 10))
X.mean().compute()

I also ran git grep -E "distributed.*utils" to check for other things that have been moved, annd didn't see any other that needed to be addressed.

Notes for Reviewers

I'm proposing introduce this _compat layer with conditional imports so that dask-cloudprovider doesn't have to bump its version floor on distributed or dask.

Thanks for your time and consideration.

Copy link
Member

@jacobtomlinson jacobtomlinson left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @jameslamb.

We frequently bump the dependency floor here anyway as enhancements often require upstream changes. So I have no problem doing that here. I appreciate you trying to maintain backward compatibility but I don't feel that the increased indirection is worth it.

@jameslamb
Copy link
Member Author

I don't feel that the increased indirection is worth it.

alright no problem. Since #6987 was merged on December 18, 2020, I guess the existing floor of dask>=2021.1.0 doesn't have to be changed anyway!

dask>=2021.01.1
distributed>=2021.01.1

https://pypi.org/project/dask/#history

Updated in 208b43b.

@jacobtomlinson
Copy link
Member

Thanks @jameslamb!

@jacobtomlinson jacobtomlinson merged commit a344aec into dask:main Aug 11, 2021
@jameslamb jameslamb deleted the fix/serialize-deprecation branch August 11, 2021 13:36
@dangercrow
Copy link

What's the release timeline looking like for this PR?
I was glad to see someone had fixed this as the error was starting to bug me, too!
However, I didn't see any new version of dask-cloudprovider that included this commit :(

@jacobtomlinson
Copy link
Member

I'll likely do a release at the start of September. For now you can install from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants