mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-01 12:56:54 +08:00
Allow kernel id to take precedence over name
Allow kernel id to take precidence over name Fix spelling
This commit is contained in:
parent
f3e2b02be5
commit
56c653927f
@ -106,16 +106,17 @@ class SessionHandler(APIHandler):
|
||||
if notebook.get('path') is not None:
|
||||
changes['path'] = notebook['path']
|
||||
if 'kernel' in model:
|
||||
if model['kernel'].get('name') is not None:
|
||||
kernel_name = model['kernel']['name']
|
||||
kernel_id = yield sm.start_kernel_for_session(
|
||||
session_id, kernel_name=kernel_name, path=before['notebook']['path'])
|
||||
changes['kernel_id'] = kernel_id
|
||||
# Kernel id takes precedence over name.
|
||||
if model['kernel'].get('id') is not None:
|
||||
kernel_id = model['kernel']['id']
|
||||
if kernel_id not in km:
|
||||
raise web.HTTPError(400, "No such kernel: %s" % kernel_id)
|
||||
changes['kernel_id'] = kernel_id
|
||||
elif model['kernel'].get('name') is not None:
|
||||
kernel_name = model['kernel']['name']
|
||||
kernel_id = yield sm.start_kernel_for_session(
|
||||
session_id, kernel_name=kernel_name, path=before['notebook']['path'])
|
||||
changes['kernel_id'] = kernel_id
|
||||
|
||||
yield gen.maybe_future(sm.update_session(session_id, **changes))
|
||||
model = yield gen.maybe_future(sm.get_session(session_id=session_id))
|
||||
|
@ -53,7 +53,8 @@ class SessionAPI(object):
|
||||
return self._req('PATCH', id, body)
|
||||
|
||||
def modify_kernel_id(self, id, kernel_id):
|
||||
body = json.dumps({'kernel': {'id': kernel_id}})
|
||||
# Also send a dummy name to show that id takes precedence.
|
||||
body = json.dumps({'kernel': {'id': kernel_id, 'name': 'foo'}})
|
||||
return self._req('PATCH', id, body)
|
||||
|
||||
def delete(self, id):
|
||||
|
Loading…
Reference in New Issue
Block a user