Skip to content

Commit

Permalink
Merge pull request #5484 from lucabem/master
Browse files Browse the repository at this point in the history
Added functionality to allow filter kernels by Jupyter Enterprise Gat…
  • Loading branch information
kevin-bates authored May 27, 2020
2 parents 6e9256b + 266e297 commit b44fc3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions notebook/gateway/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,25 @@ def shutdown_all(self, now=False):
self.remove_kernel(kernel_id)



class GatewayKernelSpecManager(KernelSpecManager):

def __init__(self, **kwargs):
super(GatewayKernelSpecManager, self).__init__(**kwargs)
self.base_endpoint = url_path_join(GatewayClient.instance().url,
GatewayClient.instance().kernelspecs_endpoint)
base_endpoint = url_path_join(GatewayClient.instance().url,
GatewayClient.instance().kernelspecs_endpoint)

self.base_endpoint = GatewayKernelSpecManager._get_endpoint_for_user_filter(base_endpoint)
self.base_resource_endpoint = url_path_join(GatewayClient.instance().url,
GatewayClient.instance().kernelspecs_resource_endpoint)

@staticmethod
def _get_endpoint_for_user_filter(default_endpoint):
kernel_user = os.environ.get('KERNEL_USERNAME')
if kernel_user:
return '?user='.join([default_endpoint, kernel_user])
return default_endpoint

def _get_kernelspecs_endpoint_url(self, kernel_name=None):
"""Builds a url for the kernels endpoint
Expand Down

0 comments on commit b44fc3b

Please sign in to comment.