MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / test_dask_client_create

Function test_dask_client_create

pyxrf/core/tests/test_map_processing.py:36–64  ·  view source on GitHub ↗

`dask_client_create` is a trivial function that instantiates Dask client in uniform way throughout the program. We test that we can pass addition kwargs to the object constructor or override default parameters.

(tmpdir)

Source from the content-addressed store, hash-verified

34
35
36def test_dask_client_create(tmpdir):
37 """
38 `dask_client_create` is a trivial function that instantiates Dask client
39 in uniform way throughout the program. We test that we can pass addition
40 kwargs to the object constructor or override default parameters.
41 """
42 # Set current directory. This is not required to create Dask client, but
43 # we will check to make sure that the directory for temporary files is
44 # not created in the current directory.
45 os.chdir(tmpdir)
46 dask_worker_space_path = os.path.join(tmpdir, "dask-worker-space")
47
48 # Set the number of workers to some strange number (11 is unusual)
49 # (pass another kwarg in addition to default)
50 client = dask_client_create(n_workers=11)
51 n_workers = len(client.scheduler_info()["workers"])
52 assert n_workers == 11, "The number of workers was set incorrectly"
53 client.close()
54
55 assert not os.path.exists(dask_worker_space_path), "Temporary directory was created in the current directory"
56
57 # Disable multiprocessing: client is expected to have a single worker
58 # (replace the default value of the parameter)
59 client = dask_client_create(processes=False)
60 n_workers = len(client.scheduler_info()["workers"])
61 assert n_workers == 1, "Dask client is expected to have one worker"
62 client.close()
63
64 assert not os.path.exists(dask_worker_space_path), "Temporary directory was created in the current directory"
65
66
67def test_TerminalProgressBar():

Callers

nothing calls this directly

Calls 1

dask_client_createFunction · 0.90

Tested by

no test coverage detected