`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)
| 34 | |
| 35 | |
| 36 | def 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 | |
| 67 | def test_TerminalProgressBar(): |
nothing calls this directly
no test coverage detected