abagali1

jupyterhub_config.py

Sep 19th, 2020 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. ### AUTHENTICATION SETUP
  2. from oauthenticator.generic import GenericOAuthenticator
  3. OAUTH_CLIENT_ID = REDACTED
  4. OAUTH_CLIENT_SECRET = REDACTED
  5.  
  6. c.JupyterHub.authenticator_class = GenericOAuthenticator
  7.  
  8. c.Authenticator.admin_users = [REDACTED]
  9. c.JupyterHub.pid_file = '/opt/jupyterhub/jupyterhub-proxy.pid'
  10. c.JupyterHub.cookie_secret_file = '/opt/jupyterhub/jupyterhub_cookie_secret'
  11.  
  12. ### DATABASE SETUP
  13. POSTGRES_HOST = REDACTED
  14. POSTGRES_USER = REDACTED
  15. POSTGRES_PASSWORD = REDACTED
  16. POSTGRES_DATABASE = REDACTED
  17. c.JupyterHub.db_url = "postgres://{}:{}@/{}?host={}".format(POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DATABASE, POSTGRES_HOST)
  18.  
  19.  
  20. ### SSL SETUP
  21. c.KernelManager.transport = 'ipc'
  22. c.JupyterHub.bind_url = 'http://:8000'
  23.  
  24. c.JupyterHub.ssl_key = '/etc/jupyter/ssl/jupyterhub.key'
  25. c.JupyterHub.ssl_cert = '/etc/jupyter/ssl/jupyterhub.crt'
  26. c.JupyterHub.trusted_alt_names = ["DNS:jupyterhub.XXX.XXX"]
  27. c.JupyterHub.trusted_downstream_ips = ["IP:198.38.16.107"]
  28. #c.JupyterHub.internal_ssl = True
  29. #c.JupyterHub.internal_certs_location = '/etc/jupyter/ssl/internal-ssl'
  30.  
  31.  
  32. ### SPAWNER CONFIG
  33. import batchspawner
  34. c.JupyterHub.hub_connect_ip = '198.38.16.107'
  35. c.Spawner.http_timeout = 120
  36. c.Spawner.default_url = '/lab'
  37.  
  38. c.JupyterHub.spawner_class = 'batchspawner.SlurmSpawner'
  39. c.JupyterHub.shutdown_on_logout = True
  40. c.BatchSpawnerBase.disable_user_config = True
  41. c.BatchSpawnerBase.req_nprocs = '4'
  42. c.BatchSpawnerBase.req_host = 'infocube.XXX.XXX.XXX'
  43. c.BatchSpawnerBase.req_runtime = '4:30:00'
  44. c.BatchSpawnerBase.req_memory = '8000'
  45. c.BatchSpawnerBase.req_partition = 'compute'
  46. c.SlurmSpawner.req_queue = 'compute'
  47. c.SlurmSpawner.cmd = ["/opt/jupyterhub/bin/python", "/opt/jupyterhub/bin/jupyterhub-singleuser"]
  48. c.SlurmSpawner.batch_script='''#!/bin/bash
  49. #SBATCH --time={runtime}
  50. #SBATCH --output=/cluster/{username}/.jupyterhub_slurmspawner.log
  51. #SBATCH --job-name=spawner-jupyterhub
  52. #SBATCH --chdir=/cluster/{username}
  53. #SBATCH --mem={memory}
  54. #SBATCH --export=PATH,LANG,JUPYTERHUB_API_TOKEN,JPY_API_TOKEN,JUPYTERHUB_CLIENT_ID,JUPYTERHUB_HOST,JUPYTERHUB_OAUTH_CALLBACK_URL,JUPYTERHUB_USER,JUPYTERHUB_SERVER_NAME,JUPYTERHUB_API_URL,JUPYTERHUB_ACTIVITY_URL,JUPYTERHUB_BASE_URL,JUPYTERHUB_SERVICE_PREFIX,USER,HOME,SHELL
  55. #SBATCH --get-user-env=L
  56. #SBATCH --partition={queue}
  57. #SBATCH
  58.  
  59. set -euo pipefail
  60. trap 'echo SIGTERM received' TERM
  61. {cmd}
  62. echo "jupyterhub-singleuser ended gracefully"
  63. '''
  64.  
Add Comment
Please, Sign In to add comment