Skip to content

Commit 73ee845

Browse files
Merge pull request #37 from datalayer/fix/npm
Split javascript and python source files
2 parents f8921db + b501fde commit 73ee845

27 files changed

+1197
-11617
lines changed

.licenserc.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
header:
2+
license:
3+
spdx-id: Datalayer
4+
copyright-owner: Datalayer, Inc.
5+
copyright-year: 2024-2025
6+
content: |
7+
Copyright (c) [year] [owner]
8+
9+
Distributed under the terms of the Modified BSD License.
10+
11+
paths-ignore:
12+
- '**/*.apt'
13+
- '**/*.cedar'
14+
- '**/*.dash'
15+
- '**/*.fga'
16+
- '**/*.ipynb'
17+
- '**/*.j2'
18+
- '**/*.json'
19+
- '**/*.mamba'
20+
- '**/*.md'
21+
- '**/*.mod'
22+
- '**/*.nblink'
23+
- '**/*.rego'
24+
- '**/*.sum'
25+
- '**/*.svg'
26+
- '**/*.template'
27+
- '**/*.tsbuildinfo'
28+
- '**/*.txt'
29+
- '**/*.yaml'
30+
- '**/*.yml'
31+
- '**/*_key'
32+
- '**/*_key.pub'
33+
- '**/.*'
34+
- '**/LICENSE.txt'
35+
- '**/MANIFEST.in'
36+
- '**/build'
37+
- '**/lib'
38+
- '**/node_modules'
39+
- '**/schemas'
40+
- '**/ssh/*'
41+
- '**/static'
42+
- '**/themes'
43+
- '**/typings'
44+
- '**/*.patch'
45+
- '**/*.bundle.js'
46+
- '**/*.map.js'
47+
- 'LICENSE'
48+
49+
comment: on-failure

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2023-2024 Datalayer, Inc.
2+
#
3+
# BSD 3-Clause License
4+
5+
SHELL=/bin/bash
6+
7+
.DEFAULT_GOAL := default
8+
9+
.PHONY: clean build
10+
11+
default: all ## Default target is all.
12+
13+
help: ## display this help.
14+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
15+
16+
all: clean dev ## Clean Install and Build
17+
18+
install:
19+
pip install .
20+
21+
dev:
22+
pip install ".[test,lint,typing]"
23+
24+
build:
25+
pip install build
26+
python -m build .
27+
28+
clean: ## clean
29+
git clean -fdx
30+
31+
jupyter-server: ## jupyter-server
32+
jupyter server --port 8888 --autoreload --ServerApp.disable_check_xsrf=True --IdentityProvider.token= --ServerApp.port_retries=0
33+
34+
publish-pypi: # publish the pypi package
35+
git clean -fdx && \
36+
python -m build
37+
@exec echo
38+
@exec echo twine upload ./dist/*-py3-none-any.whl
39+
@exec echo
40+
@exec echo https://pypi.org/project/jupyter-server-nbmodel/#history

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
# jupyter_server_nbmodel
1+
2+
[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)
3+
4+
[![Become a Sponsor](https://img.shields.io/static/v1?label=Become%20a%20Sponsor&message=%E2%9D%A4&logo=GitHub&style=flat&color=1ABC9C)](https://github.com/sponsors/datalayer)
5+
6+
# 🪐 Jupyter Server NbModel
27

38
[![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)
49
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/datalayer/jupyter-server-nbmodel/main?urlpath=lab)
510

6-
A Jupyter Server extension to execute code cell from the server.
11+
> Stop session timeouts and lost.
12+
13+
A Jupyter Server extension to execute code from the server-side NbModel.
714

815
This extension is composed of a Python package named `jupyter_server_nbmodel`
9-
for the server extension and a NPM package named `jupyter-server-nbmodel`
16+
for the server extension and a NPM package named `@datalayer/jupyter-server-nbmodel`
1017
for the frontend extension.
1118

1219
## Requirements
1320

1421
- Jupyter Server
15-
- \[recommended\] Real-time collaboration for JupyterLab/Notebook:
22+
- \[RECOMMENDED\] Real-time collaboration for JupyterLab/Notebook:
1623
This will push the kernels results in the notebook from the server.
1724

1825
## Install
@@ -231,19 +238,29 @@ More information are provided within the [ui-tests](./ui-tests/README.md) README
231238

232239
```bash
233240
# Terminal 1.
241+
# You can also invoke `make jupyter-server`
234242
jupyter server --port 8888 --autoreload --ServerApp.disable_check_xsrf=True --IdentityProvider.token= --ServerApp.port_retries=0
243+
```
235244

245+
```bash
236246
# Terminal 2.
237247
KERNEL=$(curl -X POST http://localhost:8888/api/kernels)
238248
echo $KERNEL
249+
239250
KERNEL_ID=$(echo $KERNEL | jq --raw-output '.id')
240251
echo $KERNEL_ID
241-
REQUEST=$(curl --include http://localhost:8888/api/kernels/$KERNEL_ID/execute -d "{ \"code\": \"print('1+1')\" }")
242-
RESULT=$(echo $REQUEST | grep -i ^Location: | cut -d' ' -f2 | tr -d '\r')
243-
echo $RESULT
244252

245-
curl http://localhost:8888$RESULT
246-
{"status": "ok", "execution_count": 1, "outputs": "[{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": \"1+1\\n\"}]"}
253+
RESPONSE=$(curl --include http://localhost:8888/api/kernels/$KERNEL_ID/execute -d "{ \"code\": \"print('1+1')\" }")
254+
echo $RESPONSE
255+
256+
RESULT_PATH=$(echo $RESPONSE | grep -oP 'Location:\s*\K[^ ]+' | tr -d '\r\n')
257+
echo $RESULT_PATH
258+
259+
URL="http://localhost:8888${RESULT_PATH}"
260+
echo $URL
261+
262+
curl "$URL"
263+
# {"status": "ok", "execution_count": 1, "outputs": "[{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": \"1+1\\n\"}]"}
247264
```
248265

249266
### Running Tests

jupyter_server_nbmodel/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
# Copyright (c) 2024-2025 Datalayer, Inc.
2+
#
3+
# Distributed under the terms of the Modified BSD License.
4+
15
try:
26
from ._version import __version__
37
except ImportError:
48
# Fallback when using the package in dev mode without installing
59
# in editable mode with pip. It is highly recommended to install
610
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
711
import warnings
8-
912
warnings.warn("Importing 'jupyter_server_nbmodel' outside a proper installation.", stacklevel=1)
1013
__version__ = "dev"
14+
1115
from .extension import Extension
1216

1317

0 commit comments

Comments
 (0)