From e326d4b5041b6cadd004b78ed7c8c9ebf85de931 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Sat, 9 Dec 2023 15:15:22 -0800 Subject: [PATCH] Simplify Dask tutorial --- docs/user/wflow_engine/wflow_engines1.md | 4 ++-- docs/user/wflow_engine/wflow_engines2.md | 6 +----- tests/dask/test_dask_tutorials.py | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/docs/user/wflow_engine/wflow_engines1.md b/docs/user/wflow_engine/wflow_engines1.md index 461cc74739..2c0a9ae5fb 100644 --- a/docs/user/wflow_engine/wflow_engines1.md +++ b/docs/user/wflow_engine/wflow_engines1.md @@ -252,11 +252,11 @@ graph LR delayed = bulk_to_slabs_flow(atoms) # Print the results - result = dask.compute(*client.gather(delayed)) # (1)! + result = client.gather(client.compute(delayed)) # (1)! print(result) ``` - 1. Calling `client.gatheer()` will collect the outputs from multiple `Delayed` objects. + 1. Calling `client.gather()` will collect the outputs from multiple `Delayed` objects. === "Redun" diff --git a/docs/user/wflow_engine/wflow_engines2.md b/docs/user/wflow_engine/wflow_engines2.md index 914830862c..2a3612c39e 100644 --- a/docs/user/wflow_engine/wflow_engines2.md +++ b/docs/user/wflow_engine/wflow_engines2.md @@ -159,10 +159,6 @@ graph LR 2. The use of `client.compute()` submits the job to the cluster, and `.result()` serves to block any further calculations from running until it is resolved. Calling `.result()` also returns the function output as opposed to the `Delayed` object. - !!! Note - - Dask will implicitly know to call `.result()` on any `Delayed` it receives, and it is good to rely on this fact to avoid unnecessary blocking. - === "Redun" !!! Important @@ -501,7 +497,7 @@ graph LR delayed = workflow(atoms) # Fetch the results - result = dask.compute(*client.gather(delayed)) + result = client.gather(client.compute(delayed)) print(result) ``` diff --git a/tests/dask/test_dask_tutorials.py b/tests/dask/test_dask_tutorials.py index ab5b08a5eb..c14ec5c40e 100644 --- a/tests/dask/test_dask_tutorials.py +++ b/tests/dask/test_dask_tutorials.py @@ -48,7 +48,7 @@ def test_tutorial1b(tmp_path, monkeypatch): future = bulk_to_slabs_flow(atoms) # (1)! # Print the results - assert "atoms" in dask.compute(*client.gather(future))[0] + assert "atoms" in client.gather(client.compute(future))[0] def test_tutorial2a(tmp_path, monkeypatch): @@ -116,7 +116,7 @@ def workflow(atoms): future = workflow(atoms) # Fetch the results - result = dask.compute(*client.gather(future)) + result = client.gather(client.compute(future)) # Print the results assert len(result) == 4