-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from esm-tools/fix/dask_dashboard
Improve user interface for the dask dashboard
- Loading branch information
Showing
6 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
This module contains the functions to manage the Dask cluster. | ||
""" | ||
|
||
import dask | ||
|
||
from .logging import logger | ||
|
||
|
||
def set_dashboard_link(cluster): | ||
""" | ||
Checks whether the default user configuration for the dashboard link is valid. | ||
If the configuration is invalid it tried to catch the following errors: | ||
* ``KeyError``: 'JUPYTERHUB_SERVICE_PREFIX' -> The dashboard link is not valid because | ||
the cluster was not launched from JupyterHub. In this case, the default dashboard | ||
link is set to 'http://{host}:8787'. | ||
Parameters | ||
---------- | ||
cluster : dask_jobqueue.SLURMCluster | ||
The Dask cluster to set the dashboard link. | ||
""" | ||
try: | ||
_ = cluster.dashboard_link | ||
except KeyError as e: | ||
if "JUPYTERHUB_SERVICE_PREFIX" in str(e): | ||
logger.debug( | ||
"Trying to use JupyterHub prefix for the dashboard link, but the it " | ||
"was not launched from JupyterHub. Falling back to the default " | ||
"dashboard link." | ||
) | ||
default_dashboard_link = "http://{host}:8787" | ||
dask.config.set({"distributed.dashboard.link": default_dashboard_link}) | ||
else: | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import warnings | ||
|
||
|
||
def test_os_login(): | ||
try: | ||
assert os.getlogin() | ||
except OSError: | ||
warnings.warn("os.getlogin() failed") | ||
|
||
|
||
def test_os_uname(): | ||
assert os.uname() | ||
|
||
|
||
def test_os_uname_nodename(): | ||
assert os.uname().nodename |