Repository: dask/distributed

Issue:
Rename `ensure_default_get`
We have a utility function currently named `ensure_default_get`

https://github.com/dask/distributed/blob/4cc0b0618ff4aa6c29643da3bc9d460630aa8556/distributed/client.py#L4750-L4752

however, our usage of `get` has generally been replaced by `scheduler` or `client` throughout the codebase. We might consider renaming `ensure_default_get` to `ensure_default_client` to better match the `default_client()` method and be more consistent with our naming standard. 

Additionally, I noticed `ensure_default_get` doesn't have any tests. We should also add a test to ensure that this utility works as expected.


Discussion:
@ncclementi this might be something you'd find interesting 
For reference, a test might look something like the following (I've not tested the code below):

```python
@gen_cluster(client=True)
def test_ensure_default_client(c, s, a, b):
    assert c is default_client()
    async with Client(s.address, asynchronous=True, set_as_default=False) as c2:
        assert c is default_client()
        assert c2 is not default_client()
        ensure_default_client(c2)
        assert c is not default_client()
        assert c2 is default_client()
```

Resolving patch:
diff --git a/distributed/client.py b/distributed/client.py
--- a/distributed/client.py
+++ b/distributed/client.py
@@ -4741,7 +4741,8 @@ def default_client(c=None):
         )
 
 
-def ensure_default_get(client):
+def ensure_default_client(client):
+    """Ensures the client passed as argument is set as the default"""
     dask.config.set(scheduler="dask.distributed")
     _set_global_client(client)
 
@@ -5060,3 +5061,16 @@ def _close_global_client():
 
 
 atexit.register(_close_global_client)
+
+
+def __getattr__(name):
+    if name == "ensure_default_get":
+        warnings.warn(
+            "`ensure_default_get` is deprecated and will be removed in a future release. "
+            "Please use `distributed.client.ensure_default_client` instead.",
+            category=FutureWarning,
+            stacklevel=2,
+        )
+        return ensure_default_client
+    else:
+        raise AttributeError(f"module {__name__} has no attribute {name}")


Test patch:
diff --git a/distributed/tests/test_client.py b/distributed/tests/test_client.py
--- a/distributed/tests/test_client.py
+++ b/distributed/tests/test_client.py
@@ -52,6 +52,7 @@
     _get_global_client,
     as_completed,
     default_client,
+    ensure_default_client,
     futures_of,
     get_task_metadata,
     temp_default_client,
@@ -3332,6 +3333,24 @@ def test_default_get():
         assert dask.base.get_scheduler() == pre_get
 
 
+@gen_cluster(client=True)
+async def test_ensure_default_client(c, s, a, b):
+    assert c is default_client()
+
+    async with Client(s.address, set_as_default=False, asynchronous=True) as c2:
+        assert c is default_client()
+        assert c2 is not default_client()
+        ensure_default_client(c2)
+        assert c is not default_client()
+        assert c2 is default_client()
+
+
+def test_ensure_default_get_deprecated():
+    with pytest.warns(FutureWarning, match="`ensure_default_get` is deprecated"):
+        from distributed.client import ensure_default_get
+    assert ensure_default_get is ensure_default_client
+
+
 @gen_cluster()
 async def test_set_as_default(s, a, b):
     with pytest.raises(ValueError):