Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #51 from vpavlin/feature/cleanup-jsp
Browse files Browse the repository at this point in the history
Update SingleuserProfiles initialization to match new version
  • Loading branch information
vpavlin committed May 22, 2020
2 parents 592bb90 + 986185b commit e36ea98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
33 changes: 7 additions & 26 deletions .jupyter/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@
# Work out hostname for the exposed route of the JupyterHub server. This
# is tricky as we need to use the REST API to query it.

verify_ssl = False

from kubernetes import client, config
from openshift.dynamic import DynamicClient

config.load_incluster_config()

configuration = client.Configuration()
configuration.verify_ssl = False
configuration.verify_ssl = verify_ssl

oapi_client = DynamicClient(
client.ApiClient(configuration=configuration)
Expand Down Expand Up @@ -159,8 +161,9 @@ class OpenShiftSpawner(KubeSpawner):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.single_user_services = []
self.single_user_profiles = SingleuserProfiles(server_url, client_secret, gpu_mode=os.environ.get('GPU_MODE'))
self.single_user_profiles = SingleuserProfiles(gpu_mode=os.environ.get('GPU_MODE'), verify_ssl=verify_ssl)
self.gpu_mode = self.single_user_profiles.gpu_mode
self.gpu_count = 0
self.deployment_size = None

def _options_form_default(self):
Expand Down Expand Up @@ -215,31 +218,9 @@ def options_from_form(self, formdata):
del formdata['custom_image']
del formdata['size']

gpu = formdata['gpu'][0]
self.gpu_count = formdata['gpu'][0]
del formdata['gpu']

GPU_KEY = "nvidia.com/gpu"

if int(gpu) > 0:
if self.gpu_mode and self.gpu_mode == self.single_user_profiles.GPU_MODE_PRIVILEGED:
self.privileged = True
else:
self.privileged = False

if not self.extra_resource_guarantees:
self.extra_resource_guarantees = {}
self.extra_resource_guarantees[GPU_KEY] = gpu

if not self.extra_resource_limits:
self.extra_resource_limits = {}
self.extra_resource_limits[GPU_KEY] = gpu
else:
if self.extra_resource_guarantees and self.extra_resource_guarantees.get(GPU_KEY):
del self.extra_resource_guarantees[GPU_KEY]
if self.extra_resource_limits and self.extra_resource_limits.get(GPU_KEY):
del self.extra_resource_limits[GPU_KEY]
self.privileged = False

data = {} #'AWS_ACCESS_KEY_ID': formdata['AWS_ACCESS_KEY_ID'][0], 'AWS_SECRET_ACCESS_KEY': formdata['AWS_SECRET_ACCESS_KEY'][0]
for key, val in formdata.items():
if key.startswith("variable_name"):
Expand All @@ -252,7 +233,7 @@ def options_from_form(self, formdata):
cm_data = {
'env': data,
'last_selected_image': self.singleuser_image_spec,
'gpu': gpu,
'gpu': self.gpu_count,
'last_selected_size': self.deployment_size
}

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
openshift
jupyterhub-kubespawner==0.11.1
git+https://github.com/vpavlin/jupyterhub-singleuser-profiles.git@76e9381ef8be03112e477f65b5992fea5d56df32
git+https://github.com/vpavlin/jupyterhub-singleuser-profiles.git@068b9ea058666ae662919bdec7928c4ab186caa0
git+https://github.com/vpavlin/jupyter-publish-extension.git@7cbf34e494fd9a0a79e9cd9a8c1d48a6775b9f49
git+https://github.com/vpavlin/oauthenticator.git

0 comments on commit e36ea98

Please sign in to comment.