From a99b1b1644ec0c2bcb650513cd5f60271cb1a999 Mon Sep 17 00:00:00 2001 From: Rollin Thomas Date: Mon, 13 Jul 2020 08:34:38 -0700 Subject: [PATCH 1/5] Easy way to deny users access --- jupyter-nersc/web-jupyterhub/jupyterhub_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jupyter-nersc/web-jupyterhub/jupyterhub_config.py b/jupyter-nersc/web-jupyterhub/jupyterhub_config.py index ffac7b4..4650cf7 100644 --- a/jupyter-nersc/web-jupyterhub/jupyterhub_config.py +++ b/jupyter-nersc/web-jupyterhub/jupyterhub_config.py @@ -860,6 +860,7 @@ def comma_split(string): # # .. versionadded: 0.9 #c.Authenticator.blacklist = set() +c.Authenticator.blacklist = set(comma_split(os.environ.get("BLACKLIST"))) ## Enable persisting auth_state (if available). # From cf6a9dbc86a539b29f8857b56a7ec9c154badad6 Mon Sep 17 00:00:00 2001 From: Rollin Thomas Date: Mon, 13 Jul 2020 08:38:41 -0700 Subject: [PATCH 2/5] Now JupyterLab 2 will be default --- jupyter-nersc/web-jupyterhub/templates/home.html | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/jupyter-nersc/web-jupyterhub/templates/home.html b/jupyter-nersc/web-jupyterhub/templates/home.html index a0853f4..215379e 100644 --- a/jupyter-nersc/web-jupyterhub/templates/home.html +++ b/jupyter-nersc/web-jupyterhub/templates/home.html @@ -89,17 +89,6 @@ {{ setup.use_cases }} {% endif %} {% endfor %} - -
- - What is the "Cori2" option?
- - {%- endmacro %} @@ -113,8 +102,6 @@ {{ spawner_table() }} {% endif %} - - {% endblock %} From f79dec90f4923790d50bdc0c3ab466b0ac56e0e1 Mon Sep 17 00:00:00 2001 From: Rollin Thomas Date: Mon, 13 Jul 2020 08:41:09 -0700 Subject: [PATCH 3/5] Now jupyterlab 2 is default --- .../web-jupyterhub/jupyterhub_config.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/jupyter-nersc/web-jupyterhub/jupyterhub_config.py b/jupyter-nersc/web-jupyterhub/jupyterhub_config.py index 4650cf7..191b233 100644 --- a/jupyter-nersc/web-jupyterhub/jupyterhub_config.py +++ b/jupyter-nersc/web-jupyterhub/jupyterhub_config.py @@ -1015,7 +1015,6 @@ def comma_split(string): { "name": "gerty-shared-node-cpu" }, { "name": "gerty-exclusive-node-cpu" }, { "name": "cori-shared-node-cpu" }, - { "name": "cori2-shared-node-cpu" }, { "name": "cori-shared-node-gpu" }, { "name": "cori-exclusive-node-cpu" }, { "name": "cori-configurable-gpu" }, @@ -1075,10 +1074,6 @@ def comma_split(string): "name": "cori", "roles": [] }, - { - "name": "cori2", - "roles": [] - }, { "name": "spin", "roles": [] @@ -1118,19 +1113,6 @@ def comma_split(string): } ), "cori-shared-node-cpu": ( - "sshspawner.sshspawner.SSHSpawner", { - "cmd": ["/global/common/cori/das/jupyterhub/jupyter-launcher.sh", - "/usr/common/software/jupyter/19-11/bin/jupyter-labhub"], - "args": ["--transport=ipc"], - "environment": {"OMP_NUM_THREADS" : "2", "PYTHONFAULTHANDLER": "1"}, - "remote_hosts": ["corijupyter.nersc.gov"], - "remote_port_command": "/usr/bin/python /global/common/cori/das/jupyterhub/new-get-port.py --ip", - "hub_api_url": f"https://{nersc_jupyterhub_subdomain}.nersc.gov/hub/api", - "path": "/usr/common/software/jupyter/19-11/bin:/global/common/cori/das/jupyterhub:/usr/common/usg/bin:/usr/bin:/bin", - "ssh_keyfile": '/certs/{username}.key' - } - ), - "cori2-shared-node-cpu": ( "sshspawner.sshspawner.SSHSpawner", { "cmd": ["/global/common/cori/das/jupyterhub/jupyter-launcher.sh", "/global/common/cori_cle7/software/jupyter/20-06/bin/jupyterhub-singleuser"], From a985d3fc3a42f31ca04a3e0fb5e023e1fd8f30f7 Mon Sep 17 00:00:00 2001 From: Rollin Thomas Date: Thu, 2 Jul 2020 14:10:12 -0700 Subject: [PATCH 4/5] Expect the CPU info to come from Iris --- jupyter-nersc/web-jupyterhub/nerscspawner.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jupyter-nersc/web-jupyterhub/nerscspawner.py b/jupyter-nersc/web-jupyterhub/nerscspawner.py index 32cd8a9..4938dae 100644 --- a/jupyter-nersc/web-jupyterhub/nerscspawner.py +++ b/jupyter-nersc/web-jupyterhub/nerscspawner.py @@ -1,6 +1,4 @@ -import os - from jupyterhub.spawner import LocalProcessSpawner from tornado import httpclient, web @@ -44,15 +42,18 @@ def check_role(self, auth_state, role): if role == "staff": return self.check_role_staff(auth_state) if role == "cori-exclusive-node-cpu": - return self.check_role_cori_exclusive_node_cpu() + return self.check_role_cori_exclusive_node_cpu(auth_state) return False - def check_role_cori_exclusive_node_cpu(self): - users = os.environ.get("CORI_EXCLUSIVE_NODE_CPU_USERS") - if users: - return self.user.name in users.split(",") - else: - return True + def check_role_cori_exclusive_node_cpu(self, auth_state): + return self.default_jupyter_repo(auth_state) is not None + + def default_jupyter_repo(self, auth_state): + for allocation in self.user_allocations(auth_state): + for qos in allocation["userAllocationQos"]: + if qos["qos"]["qos"] in ["jupyter"]: + return allocation["computeAllocation"]["repoName"] + return None def check_role_gpu(self, auth_state): return self.default_gpu_repo(auth_state) is not None @@ -63,7 +64,6 @@ def check_role_staff(self, auth_state): return False def default_gpu_repo(self, auth_state): -# for allocation in self.user_allocations(auth_state, ["nstaff", "m1759", "dasrepo", "gpu4sci"]): for allocation in self.user_allocations(auth_state): for qos in allocation["userAllocationQos"]: if qos["qos"]["qos"] in ["gpu", "gpu_special_m1759"]: From bc1f7ea78163ef76ed60452c9920c27370762a51 Mon Sep 17 00:00:00 2001 From: Rollin Thomas Date: Mon, 13 Jul 2020 13:56:10 -0700 Subject: [PATCH 5/5] Fully convert to JupyterLab2 --- jupyter-nersc/web-jupyterhub/jupyterhub_config.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jupyter-nersc/web-jupyterhub/jupyterhub_config.py b/jupyter-nersc/web-jupyterhub/jupyterhub_config.py index 191b233..a9bbe4a 100644 --- a/jupyter-nersc/web-jupyterhub/jupyterhub_config.py +++ b/jupyter-nersc/web-jupyterhub/jupyterhub_config.py @@ -1161,8 +1161,7 @@ def comma_split(string): ), "cori-configurable-gpu": ( "nerscslurmspawner.NERSCConfigurableGPUSlurmSpawner", { - "cmd": ["/global/common/cori/das/jupyterhub/jupyter-launcher.sh", - "/usr/common/software/jupyter/19-11/bin/jupyter-labhub"], + "cmd": ["/global/common/cori_cle7/software/jupyter/20-06/bin/jupyterhub-singleuser"], "args": ["--transport=ipc"], "exec_prefix": "/usr/bin/ssh -q -o StrictHostKeyChecking=no -o preferredauthentications=publickey -l {username} -i /certs/{username}.key {remote_host}", "startup_poll_interval": 30.0, @@ -1171,19 +1170,23 @@ def comma_split(string): "req_ngpus": "1", "req_runtime": "240", "hub_api_url": f"https://{nersc_jupyterhub_subdomain}.nersc.gov/hub/api", - "path": "/usr/common/software/jupyter/19-11/bin:/global/common/cori/das/jupyterhub:/usr/common/usg/bin:/usr/bin:/bin", + "path": "/usr/common/software/jupyter/20-06/bin:/global/common/cori/das/jupyterhub:/usr/common/usg/bin:/usr/bin:/bin", + "batchspawner_singleuser_cmd" : " ".join([ + "/global/common/cori/das/jupyterhub/jupyter-launcher.sh", + "/global/common/cori_cle7/software/jupyter/20-06/bin/batchspawner-singleuser", + ]) } ), "spin-shared-node-cpu": ( "sshspawner.sshspawner.SSHSpawner", { - "cmd": ["/global/common/cori/das/jupyterhub/jupyter-launcher.sh", - "/global/common/cori_cle7/software/jupyter/19-11/bin/jupyter-labhub"], + "cmd": ["/global/common/cori/das/jupyterhub/jupyter-launcher.sh", + "/global/common/cori_cle7/software/jupyter/20-06/bin/jupyterhub-singleuser"], "args": ["--transport=ipc"], "environment": {"OMP_NUM_THREADS" : "2"}, "remote_hosts": ["app-notebooks"], "remote_port_command": "/usr/bin/python /global/common/cori/das/jupyterhub/new-get-port.py --ip", "hub_api_url": f"https://{nersc_jupyterhub_subdomain}.nersc.gov/hub/api", - "path": "/global/common/cori_cle7/software/jupyter/19-11/bin:/global/common/cori/das/jupyterhub:/usr/common/usg/bin:/usr/bin:/bin", + "path": "/global/common/cori_cle7/software/jupyter/20-06/bin:/global/common/cori/das/jupyterhub:/usr/common/usg/bin:/usr/bin:/bin", "ssh_keyfile": '/certs/{username}.key' } )