jupyter-server-nbmodel 0.1.1a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. jupyter_server_nbmodel-0.1.1a1/.copier-answers.yml +15 -0
  2. jupyter_server_nbmodel-0.1.1a1/.gitignore +127 -0
  3. jupyter_server_nbmodel-0.1.1a1/.pre-commit-config.yaml +37 -0
  4. jupyter_server_nbmodel-0.1.1a1/.prettierignore +6 -0
  5. jupyter_server_nbmodel-0.1.1a1/.yarnrc.yml +1 -0
  6. jupyter_server_nbmodel-0.1.1a1/CHANGELOG.md +37 -0
  7. jupyter_server_nbmodel-0.1.1a1/LICENSE +29 -0
  8. jupyter_server_nbmodel-0.1.1a1/PKG-INFO +355 -0
  9. jupyter_server_nbmodel-0.1.1a1/README.md +283 -0
  10. jupyter_server_nbmodel-0.1.1a1/RELEASE.md +80 -0
  11. jupyter_server_nbmodel-0.1.1a1/babel.config.js +1 -0
  12. jupyter_server_nbmodel-0.1.1a1/conftest.py +12 -0
  13. jupyter_server_nbmodel-0.1.1a1/examples/basic.ipynb +100 -0
  14. jupyter_server_nbmodel-0.1.1a1/install.json +5 -0
  15. jupyter_server_nbmodel-0.1.1a1/jest.config.js +28 -0
  16. jupyter_server_nbmodel-0.1.1a1/jupyter-config/server-config/jupyter_server_nbmodel.json +7 -0
  17. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/__init__.py +19 -0
  18. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/_version.py +4 -0
  19. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/extension.py +59 -0
  20. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/handlers.py +608 -0
  21. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/labextension/package.json +220 -0
  22. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/labextension/static/728.f8d2e7dcd5b14868de42.js +1 -0
  23. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/labextension/static/73.f361eac87ef3162d9525.js +1 -0
  24. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/labextension/static/remoteEntry.070115c96b2030cf63d0.js +1 -0
  25. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/labextension/static/style.js +4 -0
  26. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/labextension/static/third-party-licenses.json +16 -0
  27. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/log.py +21 -0
  28. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/tests/__init__.py +1 -0
  29. jupyter_server_nbmodel-0.1.1a1/jupyter_server_nbmodel/tests/test_handlers.py +237 -0
  30. jupyter_server_nbmodel-0.1.1a1/package.json +215 -0
  31. jupyter_server_nbmodel-0.1.1a1/pyproject.toml +149 -0
  32. jupyter_server_nbmodel-0.1.1a1/src/__tests__/jupyter_server_nbmodel.spec.ts +9 -0
  33. jupyter_server_nbmodel-0.1.1a1/src/executor.ts +330 -0
  34. jupyter_server_nbmodel-0.1.1a1/src/index.ts +3 -0
  35. jupyter_server_nbmodel-0.1.1a1/style/base.css +5 -0
  36. jupyter_server_nbmodel-0.1.1a1/style/index.css +1 -0
  37. jupyter_server_nbmodel-0.1.1a1/style/index.js +1 -0
  38. jupyter_server_nbmodel-0.1.1a1/tsconfig.json +23 -0
  39. jupyter_server_nbmodel-0.1.1a1/tsconfig.test.json +6 -0
  40. jupyter_server_nbmodel-0.1.1a1/ui-tests/README.md +167 -0
  41. jupyter_server_nbmodel-0.1.1a1/ui-tests/jupyter_server_test_config.py +13 -0
  42. jupyter_server_nbmodel-0.1.1a1/ui-tests/package.json +15 -0
  43. jupyter_server_nbmodel-0.1.1a1/ui-tests/playwright.config.js +14 -0
  44. jupyter_server_nbmodel-0.1.1a1/ui-tests/tests/jupyter_server_nbmodel.spec.ts +23 -0
  45. jupyter_server_nbmodel-0.1.1a1/ui-tests/yarn.lock +0 -0
  46. jupyter_server_nbmodel-0.1.1a1/yarn.lock +10535 -0
@@ -0,0 +1,15 @@
1
+ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2
+ _commit: v4.3.4
3
+ _src_path: https://github.com/jupyterlab/extension-template
4
+ author_email: ''
5
+ author_name: Datalayer
6
+ has_binder: true
7
+ has_settings: false
8
+ kind: server
9
+ labextension_name: jupyter-server-nbmodel
10
+ project_short_description: A Jupyter Server extension to execute code cell from the
11
+ server.
12
+ python_name: jupyter_server_nbmodel
13
+ repository: https://github.com/datalayer/jupyter-server-nbmodel
14
+ test: true
15
+
@@ -0,0 +1,127 @@
1
+ *.bundle.*
2
+ lib/
3
+ node_modules/
4
+ *.log
5
+ .eslintcache
6
+ .stylelintcache
7
+ *.egg-info/
8
+ .ipynb_checkpoints
9
+ *.tsbuildinfo
10
+ jupyter_server_nbmodel/labextension
11
+ # Version file is handled by hatchling
12
+ jupyter_server_nbmodel/_version.py
13
+
14
+ # Integration tests
15
+ ui-tests/test-results/
16
+ ui-tests/playwright-report/
17
+
18
+ # Created by https://www.gitignore.io/api/python
19
+ # Edit at https://www.gitignore.io/?templates=python
20
+
21
+ ### Python ###
22
+ # Byte-compiled / optimized / DLL files
23
+ __pycache__/
24
+ *.py[cod]
25
+ *$py.class
26
+
27
+ # C extensions
28
+ *.so
29
+
30
+ # Distribution / packaging
31
+ .Python
32
+ build/
33
+ develop-eggs/
34
+ dist/
35
+ downloads/
36
+ eggs/
37
+ .eggs/
38
+ lib/
39
+ lib64/
40
+ parts/
41
+ sdist/
42
+ var/
43
+ wheels/
44
+ pip-wheel-metadata/
45
+ share/python-wheels/
46
+ .installed.cfg
47
+ *.egg
48
+ MANIFEST
49
+
50
+ # PyInstaller
51
+ # Usually these files are written by a python script from a template
52
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
53
+ *.manifest
54
+ *.spec
55
+
56
+ # Installer logs
57
+ pip-log.txt
58
+ pip-delete-this-directory.txt
59
+
60
+ # Unit test / coverage reports
61
+ htmlcov/
62
+ .tox/
63
+ .nox/
64
+ .coverage
65
+ .coverage.*
66
+ .cache
67
+ nosetests.xml
68
+ coverage/
69
+ coverage.xml
70
+ *.cover
71
+ .hypothesis/
72
+ .pytest_cache/
73
+
74
+ # Translations
75
+ *.mo
76
+ *.pot
77
+
78
+ # Scrapy stuff:
79
+ .scrapy
80
+
81
+ # Sphinx documentation
82
+ docs/_build/
83
+
84
+ # PyBuilder
85
+ target/
86
+
87
+ # pyenv
88
+ .python-version
89
+
90
+ # celery beat schedule file
91
+ celerybeat-schedule
92
+
93
+ # SageMath parsed files
94
+ *.sage.py
95
+
96
+ # Spyder project settings
97
+ .spyderproject
98
+ .spyproject
99
+
100
+ # Rope project settings
101
+ .ropeproject
102
+
103
+ # Mr Developer
104
+ .mr.developer.cfg
105
+ .project
106
+ .pydevproject
107
+
108
+ # mkdocs documentation
109
+ /site
110
+
111
+ # mypy
112
+ .mypy_cache/
113
+ .dmypy.json
114
+ dmypy.json
115
+
116
+ # Pyre type checker
117
+ .pyre/
118
+
119
+ # End of https://www.gitignore.io/api/python
120
+
121
+ # OSX files
122
+ .DS_Store
123
+ .jupyter_ystore.db
124
+ .vscode
125
+
126
+ # Yarn cache
127
+ .yarn/
@@ -0,0 +1,37 @@
1
+ ci:
2
+ autoupdate_schedule: monthly
3
+
4
+ repos:
5
+ - repo: https://github.com/pre-commit/pre-commit-hooks
6
+ rev: v4.4.0
7
+ hooks:
8
+ - id: end-of-file-fixer
9
+ - id: check-case-conflict
10
+ - id: check-executables-have-shebangs
11
+ - id: requirements-txt-fixer
12
+ - id: check-added-large-files
13
+ - id: check-case-conflict
14
+ - id: check-toml
15
+ - id: check-yaml
16
+ - id: debug-statements
17
+ - id: forbid-new-submodules
18
+ - id: check-builtin-literals
19
+ - id: trailing-whitespace
20
+
21
+ - repo: https://github.com/python-jsonschema/check-jsonschema
22
+ rev: 0.28.3
23
+ hooks:
24
+ - id: check-github-workflows
25
+
26
+ - repo: https://github.com/executablebooks/mdformat
27
+ rev: 0.7.16
28
+ hooks:
29
+ - id: mdformat
30
+ additional_dependencies:
31
+ [mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
32
+
33
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
34
+ rev: v0.4.4
35
+ hooks:
36
+ - id: ruff
37
+ args: ["--fix"]
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ **/node_modules
3
+ **/lib
4
+ **/package.json
5
+ !/package.json
6
+ jupyter_server_nbmodel
@@ -0,0 +1 @@
1
+ nodeLinker: node-modules
@@ -0,0 +1,37 @@
1
+ # Changelog
2
+
3
+ <!-- <START NEW CHANGELOG ENTRY> -->
4
+
5
+ ## 0.1.1a1
6
+
7
+ ([Full Changelog](https://github.com/datalayer/jupyter-server-nbmodel/compare/bf5719ce10580303de08342073b66e3d579e7cdc...2facfb378e11f8f564593f4329af5c71d7fa67f2))
8
+
9
+ ### Enhancements made
10
+
11
+ - Preparation for first release [#20](https://github.com/datalayer/jupyter-server-nbmodel/pull/20) ([@fcollonval](https://github.com/fcollonval))
12
+ - Add jupyter_client to dep to ensure it contains the needed fix [#17](https://github.com/datalayer/jupyter-server-nbmodel/pull/17) ([@fcollonval](https://github.com/fcollonval))
13
+ - Internalize frontend cell executor [#14](https://github.com/datalayer/jupyter-server-nbmodel/pull/14) ([@fcollonval](https://github.com/fcollonval))
14
+
15
+ ### Bugs fixed
16
+
17
+ - Internalize frontend cell executor [#14](https://github.com/datalayer/jupyter-server-nbmodel/pull/14) ([@fcollonval](https://github.com/fcollonval))
18
+ - Fix returning pending input for the correct request [#10](https://github.com/datalayer/jupyter-server-nbmodel/pull/10) ([@fcollonval](https://github.com/fcollonval))
19
+
20
+ ### Documentation improvements
21
+
22
+ - Optionally depend on server ydoc and docprovider [#21](https://github.com/datalayer/jupyter-server-nbmodel/pull/21) ([@krassowski](https://github.com/krassowski))
23
+ - Fix mermaidJS graph [#18](https://github.com/datalayer/jupyter-server-nbmodel/pull/18) ([@fcollonval](https://github.com/fcollonval))
24
+
25
+ ### Other merged PRs
26
+
27
+ - Multiple enhancements [#9](https://github.com/datalayer/jupyter-server-nbmodel/pull/9) ([@fcollonval](https://github.com/fcollonval))
28
+ - Bump actions/github-script from 3 to 7 [#4](https://github.com/datalayer/jupyter-server-nbmodel/pull/4) ([@dependabot](https://github.com/dependabot))
29
+ - Update pytest requirement from ~=7.0 to ~=8.2 [#1](https://github.com/datalayer/jupyter-server-nbmodel/pull/1) ([@dependabot](https://github.com/dependabot))
30
+
31
+ ### Contributors to this release
32
+
33
+ ([GitHub contributors page for this release](https://github.com/datalayer/jupyter-server-nbmodel/graphs/contributors?from=2024-05-06&to=2024-07-29&type=c))
34
+
35
+ [@dependabot](https://github.com/search?q=repo%3Adatalayer%2Fjupyter-server-nbmodel+involves%3Adependabot+updated%3A2024-05-06..2024-07-29&type=Issues) | [@fcollonval](https://github.com/search?q=repo%3Adatalayer%2Fjupyter-server-nbmodel+involves%3Afcollonval+updated%3A2024-05-06..2024-07-29&type=Issues) | [@github-actions](https://github.com/search?q=repo%3Adatalayer%2Fjupyter-server-nbmodel+involves%3Agithub-actions+updated%3A2024-05-06..2024-07-29&type=Issues) | [@krassowski](https://github.com/search?q=repo%3Adatalayer%2Fjupyter-server-nbmodel+involves%3Akrassowski+updated%3A2024-05-06..2024-07-29&type=Issues) | [@Wh1isper](https://github.com/search?q=repo%3Adatalayer%2Fjupyter-server-nbmodel+involves%3AWh1isper+updated%3A2024-05-06..2024-07-29&type=Issues)
36
+
37
+ <!-- <END NEW CHANGELOG ENTRY> -->
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Datalayer
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,355 @@
1
+ Metadata-Version: 2.3
2
+ Name: jupyter_server_nbmodel
3
+ Version: 0.1.1a1
4
+ Dynamic: Keywords
5
+ Summary: A Jupyter Server extension to execute code cell from the server.
6
+ Project-URL: Homepage, https://github.com/datalayer/jupyter-server-nbmodel
7
+ Project-URL: Bug Tracker, https://github.com/datalayer/jupyter-server-nbmodel/issues
8
+ Project-URL: Repository, https://github.com/datalayer/jupyter-server-nbmodel.git
9
+ Author: Datalayer
10
+ License: BSD 3-Clause License
11
+
12
+ Copyright (c) 2024, Datalayer
13
+ All rights reserved.
14
+
15
+ Redistribution and use in source and binary forms, with or without
16
+ modification, are permitted provided that the following conditions are met:
17
+
18
+ 1. Redistributions of source code must retain the above copyright notice, this
19
+ list of conditions and the following disclaimer.
20
+
21
+ 2. Redistributions in binary form must reproduce the above copyright notice,
22
+ this list of conditions and the following disclaimer in the documentation
23
+ and/or other materials provided with the distribution.
24
+
25
+ 3. Neither the name of the copyright holder nor the names of its
26
+ contributors may be used to endorse or promote products derived from
27
+ this software without specific prior written permission.
28
+
29
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
33
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
+ License-File: LICENSE
40
+ Classifier: Framework :: Jupyter
41
+ Classifier: Framework :: Jupyter :: JupyterLab
42
+ Classifier: Framework :: Jupyter :: JupyterLab :: 4
43
+ Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
44
+ Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
45
+ Classifier: License :: OSI Approved :: BSD License
46
+ Classifier: Programming Language :: Python
47
+ Classifier: Programming Language :: Python :: 3
48
+ Classifier: Programming Language :: Python :: 3.8
49
+ Classifier: Programming Language :: Python :: 3.9
50
+ Classifier: Programming Language :: Python :: 3.10
51
+ Classifier: Programming Language :: Python :: 3.11
52
+ Classifier: Programming Language :: Python :: 3.12
53
+ Requires-Python: >=3.8
54
+ Requires-Dist: jupyter-client>=8.6.2
55
+ Requires-Dist: jupyter-server<3,>=2.0.1
56
+ Provides-Extra: lab
57
+ Requires-Dist: jupyter-docprovider>=1.0.0b1; extra == 'lab'
58
+ Requires-Dist: jupyter-server-ydoc>=1.0.0b1; extra == 'lab'
59
+ Requires-Dist: jupyterlab>=4.2.0; extra == 'lab'
60
+ Provides-Extra: lint
61
+ Requires-Dist: mdformat-gfm>=0.3.5; extra == 'lint'
62
+ Requires-Dist: mdformat>0.7; extra == 'lint'
63
+ Requires-Dist: ruff>=0.4.0; extra == 'lint'
64
+ Provides-Extra: test
65
+ Requires-Dist: pytest-cov; extra == 'test'
66
+ Requires-Dist: pytest-jupyter[server]>=0.6; extra == 'test'
67
+ Requires-Dist: pytest-timeout; extra == 'test'
68
+ Requires-Dist: pytest~=8.2; extra == 'test'
69
+ Provides-Extra: typing
70
+ Requires-Dist: mypy>=0.990; extra == 'typing'
71
+ Description-Content-Type: text/markdown
72
+
73
+ # jupyter_server_nbmodel
74
+
75
+ [![Github Actions Status](https://github.com/datalayer/jupyter-server-nbmodel/workflows/Build/badge.svg)](https://github.com/datalayer/jupyter-server-nbmodel/actions/workflows/build.yml)
76
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/datalayer/jupyter-server-nbmodel/main?urlpath=lab)
77
+
78
+ A Jupyter Server extension to execute code cell from the server.
79
+
80
+ This extension is composed of a Python package named `jupyter_server_nbmodel`
81
+ for the server extension and a NPM package named `jupyter-server-nbmodel`
82
+ for the frontend extension.
83
+
84
+ ## Requirements
85
+
86
+ - Jupyter Server
87
+ - \[recommended\] Real-time collaboration for JupyterLab/Notebook:
88
+ This will push the kernels results in the notebook from the server.
89
+
90
+ ## Install
91
+
92
+ To install the extension for use in JupyterLab or Notebook 7, execute:
93
+
94
+ ```bash
95
+ pip install jupyter_server_nbmodel[lab]
96
+ ```
97
+
98
+ For API-only use:
99
+
100
+ ```bash
101
+ pip install jupyter_server_nbmodel
102
+ ```
103
+
104
+ Or with recommendations:
105
+
106
+ ```bash
107
+ pip install jupyter_server_nbmodel[rtc]
108
+ ```
109
+
110
+ ## Uninstall
111
+
112
+ To remove the extension, execute:
113
+
114
+ ```bash
115
+ pip uninstall jupyter_server_nbmodel
116
+ ```
117
+
118
+ ## Troubleshoot
119
+
120
+ If you are seeing the frontend extension, but it is not working, check
121
+ that the server extension is enabled:
122
+
123
+ ```bash
124
+ jupyter server extension list
125
+ ```
126
+
127
+ If the server extension is installed and enabled, but you are not seeing
128
+ the frontend extension, check the frontend extension is installed:
129
+
130
+ ```bash
131
+ jupyter labextension list
132
+ ```
133
+
134
+ ## How does it works
135
+
136
+ ### Generic case
137
+
138
+ Execution of a Python code snippet: `print("hello")`
139
+
140
+ ```mermaid
141
+ sequenceDiagram
142
+ Frontend->>+Server: POST /api/kernels/<id>/execute
143
+ Server->>+ExecutionStack: Queue request
144
+ ExecutionStack->>Kernel: Execute request msg
145
+ activate Kernel
146
+ ExecutionStack-->>Server: Task uid
147
+ Server-->>-Frontend: Returns task uid
148
+ loop Running
149
+ Kernel->>Shared Document: Add output
150
+ Shared Document->>Frontend: Document update
151
+ end
152
+ loop While status is 202
153
+ Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
154
+ Server->>ExecutionStack: Get task result
155
+ ExecutionStack-->>Server: null
156
+ Server-->>-Frontend: Request status 202
157
+ end
158
+ Kernel-->>ExecutionStack: Execution reply
159
+ deactivate Kernel
160
+ Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
161
+ Server->>ExecutionStack: Get task result
162
+ ExecutionStack-->>Server: Result
163
+ Server-->>-Frontend: Status 200 & result
164
+ ```
165
+
166
+ ### With input case
167
+
168
+ Execution of a Python code snippet: `input("Age:")`
169
+
170
+ ```mermaid
171
+ sequenceDiagram
172
+ Frontend->>+Server: POST /api/kernels/<id>/execute
173
+ Server->>+ExecutionStack: Queue request
174
+ ExecutionStack->>Kernel: Execute request msg
175
+ activate Kernel
176
+ ExecutionStack-->>Server: Task uid
177
+ Server-->>-Frontend: Returns task uid
178
+ loop Running
179
+ Kernel->>Shared Document: Add output
180
+ Shared Document->>Frontend: Document update
181
+ end
182
+ loop While status is 202
183
+ Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
184
+ Server->>ExecutionStack: Get task result
185
+ ExecutionStack-->>Server: null
186
+ Server-->>-Frontend: Request status 202
187
+ end
188
+ Kernel->>ExecutionStack: Set pending input
189
+ Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
190
+ Server->>ExecutionStack: Get task result
191
+ ExecutionStack-->>Server: Pending input
192
+ Server-->>-Frontend: Status 300 & Pending input
193
+ Frontend->>+Server: POST /api/kernels/<id>/input
194
+ Server->>Kernel: Send input msg
195
+ Server-->>-Frontend: Returns
196
+ loop While status is 202
197
+ Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
198
+ Server->>ExecutionStack: Get task result
199
+ ExecutionStack-->>Server: null
200
+ Server-->>-Frontend: Request status 202
201
+ end
202
+ Kernel-->>ExecutionStack: Execution reply
203
+ deactivate Kernel
204
+ Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
205
+ Server->>ExecutionStack: Get task result
206
+ ExecutionStack-->>Server: Result
207
+ Server-->>-Frontend: Status 200 & result
208
+ ```
209
+
210
+ > \[!NOTE\]
211
+ > The code snippet is always send in the body of the POST `/api/kernels/<id>/execute`
212
+ > request to avoid document model discrepancy; the document on the backend is only
213
+ > eventually identical with the frontends (document updates are not instantaneous).
214
+ >
215
+ > The `ExecutionStack` maintains an execution queue per kernels to ensure execution
216
+ > order.
217
+
218
+ ## Contributing
219
+
220
+ ### Development install
221
+
222
+ Note: You will need NodeJS to build the extension package.
223
+
224
+ The `jlpm` command is JupyterLab's pinned version of
225
+ [yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
226
+ `yarn` or `npm` in lieu of `jlpm` below.
227
+
228
+ ```bash
229
+ # Clone the repo to your local environment
230
+ # Change directory to the jupyter_server_nbmodel directory
231
+ # Install package in development mode
232
+ pip install -e ".[test]"
233
+ # Link your development version of the extension with JupyterLab
234
+ jupyter labextension develop . --overwrite
235
+ # Server extension must be manually installed in develop mode
236
+ jupyter server extension enable jupyter_server_nbmodel
237
+ # Rebuild extension Typescript source after making changes
238
+ jlpm build
239
+ ```
240
+
241
+ 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.
242
+
243
+ ```bash
244
+ # Watch the source directory in one terminal, automatically rebuilding when needed
245
+ jlpm watch
246
+ # Run JupyterLab in another terminal
247
+ jupyter lab --autoreload
248
+ ```
249
+
250
+ 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).
251
+
252
+ 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:
253
+
254
+ ```bash
255
+ jupyter lab build --minimize=False
256
+ ```
257
+
258
+ ### Development uninstall
259
+
260
+ ```bash
261
+ # Server extension must be manually disabled in develop mode
262
+ jupyter server extension disable jupyter_server_nbmodel
263
+ pip uninstall jupyter_server_nbmodel
264
+ ```
265
+
266
+ In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
267
+ command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
268
+ folder is located. Then you can remove the symlink named `jupyter-server-nbmodel` within that folder.
269
+
270
+ ### Testing the extension
271
+
272
+ #### Server tests
273
+
274
+ This extension is using [Pytest](https://docs.pytest.org/) for Python code testing.
275
+
276
+ Install test dependencies (needed only once):
277
+
278
+ ```sh
279
+ pip install -e ".[test]"
280
+ # Each time you install the Python package, you need to restore the front-end extension link
281
+ jupyter labextension develop . --overwrite
282
+ ```
283
+
284
+ To execute them, run:
285
+
286
+ ```sh
287
+ pytest -vv -r ap --cov jupyter_server_nbmodel
288
+ ```
289
+
290
+ #### Frontend tests
291
+
292
+ This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.
293
+
294
+ To execute them, execute:
295
+
296
+ ```sh
297
+ jlpm
298
+ jlpm test
299
+ ```
300
+
301
+ #### Integration tests
302
+
303
+ This extension uses [Playwright](https://playwright.dev/docs/intro) for the integration tests (aka user level tests).
304
+ More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.
305
+
306
+ More information are provided within the [ui-tests](./ui-tests/README.md) README.
307
+
308
+ ### Manual testing
309
+
310
+ ```bash
311
+ # Terminal 1.
312
+ jupyter server --port 8888 --autoreload --ServerApp.disable_check_xsrf=True --IdentityProvider.token= --ServerApp.port_retries=0
313
+
314
+ # Terminal 2.
315
+ KERNEL=$(curl -X POST http://localhost:8888/api/kernels)
316
+ echo $KERNEL
317
+ KERNEL_ID=$(echo $KERNEL | jq --raw-output '.id')
318
+ echo $KERNEL_ID
319
+ REQUEST=$(curl --include http://localhost:8888/api/kernels/$KERNEL_ID/execute -d "{ \"code\": \"print('1+1')\" }")
320
+ RESULT=$(echo $REQUEST | grep -i ^Location: | cut -d' ' -f2 | tr -d '\r')
321
+ echo $RESULT
322
+
323
+ curl http://localhost:8888$RESULT
324
+ {"status": "ok", "execution_count": 1, "outputs": "[{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": \"1+1\\n\"}]"}
325
+ ```
326
+
327
+ ### Running Tests
328
+
329
+ Install dependencies:
330
+
331
+ ```bash
332
+ pip install -e ".[test]"
333
+ ```
334
+
335
+ To run the python tests, use:
336
+
337
+ ```bash
338
+ pytest
339
+
340
+ # To test a specific file
341
+ pytest jupyter_server_nbmodel/tests/test_handlers.py
342
+
343
+ # To run a specific test
344
+ pytest jupyter_server_nbmodel/tests/test_handlers.py -k "test_post_execute"
345
+ ```
346
+
347
+ ### Development uninstall
348
+
349
+ ```bash
350
+ pip uninstall jupyter_server_nbmodel
351
+ ```
352
+
353
+ ### Packaging the extension
354
+
355
+ See [RELEASE](RELEASE.md)