Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
header:
license:
spdx-id: Datalayer
copyright-owner: Datalayer, Inc.
copyright-year: 2024-2025
content: |
Copyright (c) [year] [owner]

Distributed under the terms of the Modified BSD License.

paths-ignore:
- '**/*.apt'
- '**/*.cedar'
- '**/*.dash'
- '**/*.fga'
- '**/*.ipynb'
- '**/*.j2'
- '**/*.json'
- '**/*.mamba'
- '**/*.md'
- '**/*.mod'
- '**/*.nblink'
- '**/*.rego'
- '**/*.sum'
- '**/*.svg'
- '**/*.template'
- '**/*.tsbuildinfo'
- '**/*.txt'
- '**/*.yaml'
- '**/*.yml'
- '**/*_key'
- '**/*_key.pub'
- '**/.*'
- '**/LICENSE.txt'
- '**/MANIFEST.in'
- '**/build'
- '**/lib'
- '**/node_modules'
- '**/schemas'
- '**/ssh/*'
- '**/static'
- '**/themes'
- '**/typings'
- '**/*.patch'
- '**/*.bundle.js'
- '**/*.map.js'
- 'LICENSE'

comment: on-failure
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2023-2024 Datalayer, Inc.
#
# BSD 3-Clause License

SHELL=/bin/bash

.DEFAULT_GOAL := default

.PHONY: clean build

default: all ## Default target is all.

help: ## display this help.
@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)

all: clean dev ## Clean Install and Build

install:
pip install .

dev:
pip install ".[test,lint,typing]"

build:
pip install build
python -m build .

clean: ## clean
git clean -fdx

jupyter-server: ## jupyter-server
jupyter server --port 8888 --autoreload --ServerApp.disable_check_xsrf=True --IdentityProvider.token= --ServerApp.port_retries=0

publish-pypi: # publish the pypi package
git clean -fdx && \
python -m build
@exec echo
@exec echo twine upload ./dist/*-py3-none-any.whl
@exec echo
@exec echo https://pypi.org/project/jupyter-server-nbmodel/#history
35 changes: 26 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# jupyter_server_nbmodel

[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)

[![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)

# 🪐 Jupyter Server NbModel

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

A Jupyter Server extension to execute code cell from the server.
> Stop session timeouts and lost.

A Jupyter Server extension to execute code from the server-side NbModel.

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

## Requirements

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

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

```bash
# Terminal 1.
# You can also invoke `make jupyter-server`
jupyter server --port 8888 --autoreload --ServerApp.disable_check_xsrf=True --IdentityProvider.token= --ServerApp.port_retries=0
```

```bash
# Terminal 2.
KERNEL=$(curl -X POST http://localhost:8888/api/kernels)
echo $KERNEL

KERNEL_ID=$(echo $KERNEL | jq --raw-output '.id')
echo $KERNEL_ID
REQUEST=$(curl --include http://localhost:8888/api/kernels/$KERNEL_ID/execute -d "{ \"code\": \"print('1+1')\" }")
RESULT=$(echo $REQUEST | grep -i ^Location: | cut -d' ' -f2 | tr -d '\r')
echo $RESULT

curl http://localhost:8888$RESULT
{"status": "ok", "execution_count": 1, "outputs": "[{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": \"1+1\\n\"}]"}
RESPONSE=$(curl --include http://localhost:8888/api/kernels/$KERNEL_ID/execute -d "{ \"code\": \"print('1+1')\" }")
echo $RESPONSE

RESULT_PATH=$(echo $RESPONSE | grep -oP 'Location:\s*\K[^ ]+' | tr -d '\r\n')
echo $RESULT_PATH

URL="http://localhost:8888${RESULT_PATH}"
echo $URL

curl "$URL"
# {"status": "ok", "execution_count": 1, "outputs": "[{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": \"1+1\\n\"}]"}
```

### Running Tests
Expand Down
6 changes: 5 additions & 1 deletion jupyter_server_nbmodel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Copyright (c) 2024-2025 Datalayer, Inc.
#
# Distributed under the terms of the Modified BSD License.

try:
from ._version import __version__
except ImportError:
# Fallback when using the package in dev mode without installing
# in editable mode with pip. It is highly recommended to install
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings

warnings.warn("Importing 'jupyter_server_nbmodel' outside a proper installation.", stacklevel=1)
__version__ = "dev"

from .extension import Extension


Expand Down
Loading
Loading