Skip to content

Commit c8dd980

Browse files
committed
Add --run-browser-gui option and add documentation
1 parent 17fa14c commit c8dd980

File tree

4 files changed

+127
-4
lines changed

4 files changed

+127
-4
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,43 @@ jupyter lite serve --XeusAddon.prefix=$PREFIX \
163163
--contents notebooks/xeus-cpp-lite-demo.ipynb \
164164
--contents notebooks/images/marie.png \
165165
--contents notebooks/audio/audio.wav
166+
167+
### xeus-cpp Jupyter Lite tests
168+
169+
It is possible to run test the xeus-cpp in Jupyter Lite deployment, using a Selenium based script and the nbdiff Jupyter tool.
170+
In order to install these dependencies execute the following (you will need the Jupyter Lite website running in the background when
171+
executing the python script)
172+
173+
```bash
174+
python -m pip install nbdime==3.2.0 selenium
175+
```
176+
177+
Then to run the by executing (--run-browser-gui option exists if you want Chrome or Firefox to show a gui browser as they run)
178+
179+
```bash
180+
python -u scripts/automated-notebook-run-script.py --driver browser --notebook notebook --kernel kernel --stdin Test_Input --timeout timeout
181+
```
182+
183+
For example
184+
185+
```bash
186+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook xeus-cpp-lite-demo.ipynb --kernel C++20 --stdin Test_Name --timeout 200
187+
```
188+
189+
will run the xeus-cpp-lite-demo.ipynb notebook in chrome, with the C++20 kernel, enter Test_Name in the standard input box in this notebook,
190+
and stop the script, if the notebook has finished running after 200 seconds. This works for Safari, Chrome and Firefox. It should be noted
191+
that in the case of Safari, safari driver must be enabled, and downloads must be enabled from 127.0.0.1 . Once the script has finished
192+
executing you can compare the notebook download from the one in the repo, to check the deployment works as expected, by executing
193+
(replace notebok_run with the notebook chosen for the Python script)
194+
195+
```bash
196+
nbdiff notebook_run $HOME/Downlaods/notebook_run
197+
```
198+
199+
For example after running the above test command, to test no changes have occured, execute
200+
201+
```bash
202+
nbdiff xeus-cpp-lite-demo.ipynb $HOME/Downlaods/xeus-cpp-lite-demo.ipynb
203+
```
204+
166205
```

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,44 @@ jupyter lite serve --XeusAddon.prefix=$PREFIX \
180180
--contents notebooks/audio/audio.wav
181181
```
182182

183+
### xeus-cpp Jupyter Lite tests
184+
185+
It is possible to run test the xeus-cpp in Jupyter Lite deployment, using a Selenium based script and the nbdiff Jupyter tool.
186+
In order to install these dependencies execute the following (you will need the Jupyter Lite website running in the background when
187+
executing the python script)
188+
189+
```bash
190+
python -m pip install nbdime==3.2.0 selenium
191+
```
192+
193+
Then to run the by executing (--run-browser-gui option exists if you want Chrome or Firefox to show a gui browser as they run)
194+
195+
```bash
196+
python -u scripts/automated-notebook-run-script.py --driver browser --notebook notebook --kernel kernel --stdin Test_Input --timeout timeout
197+
```
198+
199+
For example
200+
201+
```bash
202+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook xeus-cpp-lite-demo.ipynb --kernel C++20 --stdin Test_Name --timeout 200
203+
```
204+
205+
will run the xeus-cpp-lite-demo.ipynb notebook in chrome, with the C++20 kernel, enter Test_Name in the standard input box in this notebook,
206+
and stop the script, if the notebook has finished running after 200 seconds. This works for Safari, Chrome and Firefox. It should be noted
207+
that in the case of Safari, safari driver must be enabled, and downloads must be enabled from 127.0.0.1 . Once the script has finished
208+
executing you can compare the notebook download from the one in the repo, to check the deployment works as expected, by executing
209+
(replace notebok_run with the notebook chosen for the Python script)
210+
211+
```bash
212+
nbdiff notebook_run $HOME/Downlaods/notebook_run
213+
```
214+
215+
For example after running the above test command, to test no changes have occured, execute
216+
217+
```bash
218+
nbdiff xeus-cpp-lite-demo.ipynb $HOME/Downlaods/xeus-cpp-lite-demo.ipynb
219+
```
220+
183221
## Trying it online
184222

185223
To try out xeus-cpp interactively in your web browser, just click on the binder link:

docs/source/InstallationAndUsage.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,45 @@ To build and test Jupyter Lite with this kernel locally you can execute the foll
161161
--contents notebooks/images/marie.png \
162162
--contents notebooks/audio/audio.wav
163163
164+
### xeus-cpp Jupyter Lite tests
165+
166+
It is possible to run test the xeus-cpp in Jupyter Lite deployment, using a Selenium based script and the nbdiff Jupyter tool.
167+
In order to install these dependencies execute the following (you will need the Jupyter Lite website running in the background when
168+
executing the python script)
169+
170+
.. code-block:: bash
171+
172+
python -m pip install nbdime==3.2.0 selenium
173+
174+
Then to run the by executing (--run-browser-gui option exists if you want Chrome or Firefox to show a gui browser as they run)
175+
176+
.. code-block:: bash
177+
178+
python -u scripts/automated-notebook-run-script.py --driver browser --notebook notebook --kernel kernel --stdin Test_Input --timeout timeout
179+
180+
For example
181+
182+
.. code-block:: bash
183+
184+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook xeus-cpp-lite-demo.ipynb --kernel C++20 --stdin Test_Name --timeout 200
185+
186+
will run the xeus-cpp-lite-demo.ipynb notebook in chrome, with the C++20 kernel, enter Test_Name in the standard input box in this notebook,
187+
and stop the script, if the notebook has finished running after 200 seconds. This works for Safari, Chrome and Firefox. It should be noted
188+
that in the case of Safari, safari driver must be enabled, and downloads must be enabled from 127.0.0.1 . Once the script has finished
189+
executing you can compare the notebook download from the one in the repo, to check the deployment works as expected, by executing
190+
(replace notebok_run with the notebook chosen for the Python script)
191+
192+
.. code-block:: bash
193+
194+
nbdiff notebook_run $HOME/Downlaods/notebook_run
195+
196+
197+
For example after running the above test command, to test no changes have occured, execute
198+
199+
.. code-block:: bash
200+
201+
nbdiff xeus-cpp-lite-demo.ipynb $HOME/Downlaods/xeus-cpp-lite-demo.ipynb
202+
164203
Installing from conda-forge
165204
===========================
166205

scripts/automated-notebook-run-script.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,28 @@ def main():
239239
default=120,
240240
help="Maximum time (in seconds) allowed for notebook execution before timeout.",
241241
)
242-
242+
parser.add_argument(
243+
"--run-browser-gui",
244+
action="store_true",
245+
help="Run browser with a visible GUI (disables headless mode).",
246+
)
247+
243248
args = parser.parse_args()
244249
URL = f"http://127.0.0.1:8000/lab/index.html?path={args.notebook}"
245250

246251
# This will start the right driver depending on what
247252
# driver option is chosen
248253
if args.driver == "chrome":
249254
options = ChromeOptions()
250-
options.add_argument("--headless")
251-
options.add_argument("--no-sandbox")
255+
if not args.run_browser_gui:
256+
options.add_argument("--headless")
257+
options.add_argument("--no-sandbox")
252258
driver = webdriver.Chrome(options=options)
253259

254260
elif args.driver == "firefox":
255261
options = FirefoxOptions()
256-
options.add_argument("--headless")
262+
if not args.run_browser_gui:
263+
options.add_argument("--headless")
257264
driver = webdriver.Firefox(options=options)
258265

259266
elif args.driver == "safari":

0 commit comments

Comments
 (0)