-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of using custom env variables #1448
base: main
Are you sure you want to change the base?
Changes from 21 commits
97747e6
887f522
63e634e
9355a31
2ee8b19
86ddf23
ae37186
93b14be
4b04556
ef07d15
084b5ba
0c49734
ba231eb
56a6b42
b0feeba
6bea16b
90418ca
c1c84c8
9a9958a
f1c3d55
01db90a
e51f647
4d48ec4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ async def post(self): | |
kernel = model.get("kernel", {}) | ||
kernel_name = kernel.get("name", None) | ||
kernel_id = kernel.get("id", None) | ||
custom_env_vars = kernel.get("env", {}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be conditional based on the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dear @Zsailer I think it is a good idea. Sure, I agree. Thank you for suggestion. |
||
|
||
if not kernel_id and not kernel_name: | ||
self.log.debug("No kernel specified, using default kernel") | ||
|
@@ -93,6 +94,7 @@ async def post(self): | |
kernel_id=kernel_id, | ||
name=name, | ||
type=mtype, | ||
custom_env_vars=custom_env_vars, | ||
) | ||
except NoSuchKernel: | ||
msg = ( | ||
|
@@ -152,6 +154,8 @@ async def patch(self, session_id): | |
changes["name"] = model["name"] | ||
if "type" in model: | ||
changes["type"] = model["type"] | ||
if "env" in model: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here, shouldn't this be conditional based on the value of |
||
changes["custom_env_vars"] = model["env"] | ||
if "kernel" in model: | ||
# Kernel id takes precedence over name. | ||
if model["kernel"].get("id") is not None: | ||
|
@@ -160,13 +164,16 @@ async def patch(self, session_id): | |
raise web.HTTPError(400, "No such kernel: %s" % kernel_id) | ||
changes["kernel_id"] = kernel_id | ||
elif model["kernel"].get("name") is not None: | ||
custom_env_vars = model["kernel"]["env"] if "env" in model["kernel"] else {} | ||
|
||
kernel_name = model["kernel"]["name"] | ||
kernel_id = await sm.start_kernel_for_session( | ||
session_id, | ||
kernel_name=kernel_name, | ||
name=before["name"], | ||
path=before["path"], | ||
type=before["type"], | ||
custom_env_vars=custom_env_vars, | ||
) | ||
changes["kernel_id"] = kernel_id | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of comments on this new trait:
kernel
in the name somewhere 😆 . How aboutaccept_kernel_env_vars
? It's slightly shorter and more clear (IMO).