|
| 1 | +# Scope |
| 2 | + |
| 3 | +This document is intended for contributors and maintainers working on the extension's source code. For general usage and installation instructions, please refer to the README. |
| 4 | + |
| 5 | +# Contributing to `jupyterlab-deepnote` |
| 6 | + |
| 7 | +## Development install |
| 8 | + |
| 9 | +Note: You will need NodeJS to build the extension package. |
| 10 | + |
| 11 | +Use any Python environment and dependency manager you like, for example [uv](https://docs.astral.sh/uv/getting-started/installation/): |
| 12 | + |
| 13 | +```shell |
| 14 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 15 | +``` |
| 16 | + |
| 17 | +Create a Python environment in the project directory: |
| 18 | + |
| 19 | +```shell |
| 20 | +uv venv --python 3.12 --managed-python |
| 21 | +``` |
| 22 | + |
| 23 | +Activate the Python environment: |
| 24 | + |
| 25 | +```shell |
| 26 | +source .venv/bin/activate |
| 27 | +``` |
| 28 | + |
| 29 | +Install `jupyterlab`. The extension package itself doesn’t depend on `jupyterlab`, you just need `jupyterlab` in the environment where you will be testing the extension. |
| 30 | + |
| 31 | +```shell |
| 32 | +uv pip install jupyterlab |
| 33 | +``` |
| 34 | + |
| 35 | +### Configure Access to @deepnote/blocks Package |
| 36 | + |
| 37 | +The `@deepnote/blocks` package is published on GitHub Packages. To install it, you'll need to authenticate with GitHub: |
| 38 | + |
| 39 | +1. Create a GitHub Personal Access Token (classic) with `read:packages` scope: |
| 40 | + - Go to https://github.com/settings/tokens |
| 41 | + - Click "Generate new token (classic)" |
| 42 | + - Select the `read:packages` scope |
| 43 | + - Generate and copy the token |
| 44 | + |
| 45 | +2. Set the `GITHUB_TOKEN` environment variable to ensure `jlpm` (which is a wrapper around Yarn) can download the `@deepnote/blocks` package from the GitHub package registry. You can export the variable in `.zshrc` (or by reading a `~/.env` file): |
| 46 | + ```shell |
| 47 | + export GITHUB_TOKEN=your_token_here |
| 48 | + ``` |
| 49 | + Replace `YOUR_TOKEN_HERE` with your actual token. |
| 50 | + |
| 51 | +Install the extension package in editable mode. It installs the package’s dependencies, too: |
| 52 | + |
| 53 | +```shell |
| 54 | +uv pip install --editable . --verbose |
| 55 | +``` |
| 56 | + |
| 57 | +Link your development version of the extension with JupyterLab: |
| 58 | + |
| 59 | +```shell |
| 60 | +jupyter labextension develop . --overwrite |
| 61 | +``` |
| 62 | + |
| 63 | +Enable the extension in Jupyter Server: |
| 64 | + |
| 65 | +```shell |
| 66 | +jupyter server extension enable jupyterlab_deepnote |
| 67 | +``` |
| 68 | + |
| 69 | +Rebuild the extension’s Typescript source after making changes: |
| 70 | + |
| 71 | +```shell |
| 72 | +jlpm run watch |
| 73 | +``` |
| 74 | + |
| 75 | +The `jlpm` command is JupyterLab's pinned version of |
| 76 | +[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use |
| 77 | +`yarn` or `npm` instead of `jlpm` below. |
| 78 | + |
| 79 | +In a separate terminal, run `jupyter lab`. You can add the `--debug` option to see HTTP requests in the logs, which can be helpful for debugging. |
| 80 | + |
| 81 | +```shell |
| 82 | +jupyter lab --debug |
| 83 | +``` |
| 84 | + |
| 85 | +You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension. |
| 86 | + |
| 87 | +```bash |
| 88 | +# Watch the source directory in one terminal, automatically rebuilding when needed |
| 89 | +jlpm watch |
| 90 | +# Run JupyterLab in another terminal |
| 91 | +jupyter lab |
| 92 | +``` |
| 93 | + |
| 94 | +With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt). |
| 95 | + |
| 96 | +By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command: |
| 97 | + |
| 98 | +```bash |
| 99 | +jupyter lab build --minimize=False |
| 100 | +``` |
| 101 | + |
| 102 | +## Development uninstall |
| 103 | + |
| 104 | +```bash |
| 105 | +# Server extension must be manually disabled in develop mode |
| 106 | +jupyter server extension disable jupyterlab_deepnote |
| 107 | +pip uninstall jupyterlab_deepnote |
| 108 | +``` |
| 109 | + |
| 110 | +In development mode, you will also need to remove the symlink created by `jupyter labextension develop` |
| 111 | +command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions` |
| 112 | +folder is located. Then you can remove the symlink named `jupyterlab-deepnote` within that folder. |
| 113 | + |
| 114 | +## Testing the extension |
| 115 | + |
| 116 | +### Server tests |
| 117 | + |
| 118 | +This extension is using [Pytest](https://docs.pytest.org/) for Python code testing. |
| 119 | + |
| 120 | +Install test dependencies (needed only once): |
| 121 | + |
| 122 | +```sh |
| 123 | +pip install -e ".[test]" |
| 124 | +# Each time you install the Python package, you need to restore the front-end extension link |
| 125 | +jupyter labextension develop . --overwrite |
| 126 | +``` |
| 127 | + |
| 128 | +To execute them, run: |
| 129 | + |
| 130 | +```sh |
| 131 | +pytest -vv -r ap --cov jupyterlab_deepnote |
| 132 | +``` |
| 133 | + |
| 134 | +### Frontend tests |
| 135 | + |
| 136 | +This extension is using [Jest](https://jestjs.io/) for JavaScript code testing. |
| 137 | + |
| 138 | +To execute them, execute: |
| 139 | + |
| 140 | +```sh |
| 141 | +jlpm |
| 142 | +jlpm test |
| 143 | +``` |
| 144 | + |
| 145 | +## Versioning and compatibility |
| 146 | + |
| 147 | +We follow [Semantic Versioning (semver)](https://semver.org/). |
| 148 | + |
| 149 | +The extension pins JupyterLab to the current major version in both Python and JavaScript dependencies to ensure compatibility. |
| 150 | + |
| 151 | +**Example `pyproject.toml` dependency:** |
| 152 | + |
| 153 | +```toml |
| 154 | +[project.optional-dependencies] |
| 155 | +jupyterlab = ["jupyterlab>=4.0.0,<5.0.0"] |
| 156 | +``` |
| 157 | + |
| 158 | +**Example `package.json` peerDependencies:** |
| 159 | + |
| 160 | +```json |
| 161 | + "peerDependencies": { |
| 162 | + "@jupyterlab/application": "^4.0.0", |
| 163 | + "@jupyterlab/apputils": "^4.0.0", |
| 164 | + "jupyterlab": "^4.0.0" |
| 165 | + } |
| 166 | +``` |
| 167 | + |
| 168 | +## Sync with the JupyterLab extension template |
| 169 | + |
| 170 | +This project was bootstrapped using the [JupyterLab extension template](https://github.com/jupyterlab/extension-template). To keep your project up to date with improvements and best practices from the template, run: |
| 171 | + |
| 172 | +```sh |
| 173 | +copier update --trust |
| 174 | +``` |
| 175 | + |
| 176 | +This will apply the latest template changes interactively. Review and commit any updates as appropriate. |
| 177 | + |
| 178 | +## Release workflow |
| 179 | + |
| 180 | +See [RELEASE](RELEASE.md) for details on the release process. We recommend using [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser) and [PyPI trusted publishing](https://docs.pypi.org/trusted-publishers/) for secure and automated releases. |
0 commit comments