2022-01-18 23:43:12 +08:00
# Contributing to Jupyter Notebook
2020-12-17 03:12:40 +08:00
2022-01-18 23:43:12 +08:00
Thanks for contributing to Jupyter Notebook!
2020-12-17 03:12:40 +08:00
Make sure to follow [Project Jupyter's Code of Conduct ](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md )
for a friendly and welcoming collaborative environment.
## Setting up a development environment
Note: You will need NodeJS to build the extension package.
The `jlpm` command is JupyterLab's pinned version of [yarn ](https://yarnpkg.com/ ) that is installed with JupyterLab. You may use
`yarn` or `npm` in lieu of `jlpm` below.
**Note**: we recomment using `mamba` to speed the creating of the environment.
```bash
# create a new environment
2022-01-18 23:43:12 +08:00
mamba create -n notebook -c conda-forge python nodejs -y
2020-12-17 03:12:40 +08:00
# activate the environment
2022-02-25 17:19:03 +08:00
mamba activate notebook
2020-12-17 03:12:40 +08:00
# Install package in development mode
pip install -e .
2021-07-14 21:11:46 +08:00
2022-01-18 23:43:12 +08:00
# Link the notebook extension and @jupyter-notebook schemas
2021-11-01 23:04:15 +08:00
jlpm develop
2021-07-14 21:11:46 +08:00
# Enable the server extension
2022-01-18 23:43:12 +08:00
jupyter server extension enable notebook
2020-12-17 03:12:40 +08:00
```
2022-01-18 23:43:12 +08:00
`notebook` follows a monorepo structure. To build all the packages at once:
2020-12-17 03:12:40 +08:00
```bash
2021-04-20 18:11:00 +08:00
jlpm build
```
There is also a `watch` script to watch for changes and rebuild the app automatically:
```bash
jlpm watch
2020-12-17 03:12:40 +08:00
```
2022-01-18 23:43:12 +08:00
To make sure the `notebook` server extension is installed:
2020-12-17 03:12:40 +08:00
```bash
$ jupyter server extension list
Config dir: /home/username/.jupyter
2022-01-18 23:43:12 +08:00
Config dir: /home/username/miniforge3/envs/notebook/etc/jupyter
2020-12-17 03:12:40 +08:00
jupyterlab enabled
- Validating jupyterlab...
2020-12-24 17:30:34 +08:00
jupyterlab 3.0.0 OK
2022-01-18 23:43:12 +08:00
notebook enabled
- Validating notebook...
notebook 7.0.0a0 OK
2020-12-17 03:12:40 +08:00
Config dir: /usr/local/etc/jupyter
```
2022-01-18 23:43:12 +08:00
Then start Jupyter Notebook with:
2020-12-17 03:12:40 +08:00
```bash
2022-01-18 23:43:12 +08:00
jupyter notebook
2020-12-17 03:12:40 +08:00
```
2021-01-30 00:15:02 +08:00
## Running Tests
To run the tests:
```bash
jlpm run build:test
jlpm run test
```
2022-03-09 21:00:26 +08:00
There are also end to end tests to cover higher level user interactions, located in the `ui-tests` folder. To run these tests:
2021-01-30 00:15:02 +08:00
```bash
2021-11-11 17:36:44 +08:00
cd ui-tests
2021-01-30 00:15:02 +08:00
# start a new Jupyter server in a terminal
2021-11-11 17:36:44 +08:00
jlpm start
2021-01-30 00:15:02 +08:00
2021-11-11 17:36:44 +08:00
# in a new terminal, run the tests
jlpm test
```
2021-01-30 00:15:02 +08:00
2021-11-11 17:36:44 +08:00
The `test` script calls the Playwright test runner. You can pass additional arguments to `playwright` by appending parameters to the command. For example to run the test in headed mode, `jlpm test --headed` .
2021-01-30 00:15:02 +08:00
2021-11-11 17:36:44 +08:00
Checkout the [Playwright Command Line Reference ](https://playwright.dev/docs/test-cli/ ) for more information about the available command line options.
2021-01-30 00:15:02 +08:00
Running the end to end tests in headful mode will trigger something like the following:
2021-11-11 17:36:44 +08:00
![playwight-headed-demo ](https://user-images.githubusercontent.com/591645/141274633-ca9f9c2f-eef6-430e-9228-a35827f8133d.gif )