-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Voila configuration option for default kernel environmental varia…
…bles (#1175) * Adds default kernel env varaibles to configuration options * Adds test for default kernel env variables * Docs update for default kernal env variables CLI option * Move default_env_variables to ViolaKernelManager * Update documentation Co-authored-by: dcnadler <[email protected]> Co-authored-by: Duc Trung LE <[email protected]>
- Loading branch information
1 parent
211ca29
commit acdd9c1
Showing
5 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import asyncio | ||
import os | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture() | ||
def voila_args_extra(): | ||
return ['--VoilaKernelManager.default_env_variables={"FOO": "BAR"}'] | ||
|
||
|
||
@pytest.fixture | ||
def preheat_mode(): | ||
return True | ||
|
||
|
||
@pytest.fixture | ||
def voila_notebook(notebook_directory): | ||
return os.path.join(notebook_directory, 'preheat', 'default_env_variables.ipynb') | ||
|
||
|
||
NOTEBOOK_EXECUTION_TIME = 2 | ||
|
||
|
||
async def send_request(sc, url, wait=0): | ||
await asyncio.sleep(wait) | ||
response = await sc.fetch(url) | ||
return response.body.decode('utf-8') | ||
|
||
|
||
async def test_default_kernel_env_variable(http_server_client, base_url): | ||
html_text = await send_request(sc=http_server_client, | ||
url=base_url, | ||
wait=NOTEBOOK_EXECUTION_TIME + 1) | ||
assert 'BAR' in html_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7efe3e8f-4b8d-4fd3-99d1-b06d79b88ae2", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import time\n", | ||
"time.sleep(2)\n", | ||
"print('hello world')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "782377cd-2bc0-4d0d-8b63-74dcb7e9d645", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"os.getenv('FOO')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.10.5 ('voila')", | ||
"language": "python", | ||
"name": "python3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters