Skip to content

Commit

Permalink
Merge pull request jupyterlab#137 from jupyterlab/3.0
Browse files Browse the repository at this point in the history
Merge 3.0 -> master
  • Loading branch information
jtpio authored Jan 11, 2021
2 parents 802561f + 4f15b8e commit 944f073
Show file tree
Hide file tree
Showing 181 changed files with 3,272 additions and 516 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ jobs:
${{ runner.os }}-pip-
- name: Install the Python dependencies
if: steps.filter.outputs.extension == 'true'
run: python -m pip install jupyterlab
run: |
python -m pip install --upgrade pip
python -m pip install jupyter_packaging
python -m pip install jupyterlab
- name: Install the NPM dependencies
if: steps.filter.outputs.extension == 'true'
run: |
Expand All @@ -108,9 +111,12 @@ jobs:
if: steps.filter.outputs.extension == 'true'
run: |
cd ${EXAMPLE_FOLDER}
jlpm run build
jupyter labextension install .
pip install -e .
jupyter labextension list 1>labextensions 2>&1
cat labextensions
cat labextensions | grep -i "@jupyterlab-examples/*.*OK"
python -m jupyterlab.browser_check
pip uninstall -y $(python setup.py --name)
env:
EXAMPLE_FOLDER: ${{ matrix.example }}
shell: bash
Expand Down Expand Up @@ -176,6 +182,7 @@ jobs:
- name: Install the Python dependencies
if: steps.filter.outputs.extension == 'true'
run: |
python -m pip install --upgrade pip
python -m pip install jupyter_packaging
python -m pip install jupyterlab
- name: Install the NPM dependencies
Expand All @@ -194,13 +201,12 @@ jobs:
run: |
cd advanced/server-extension
python setup.py sdist
pip install jlab_ext_example --pre --find-links=dist --no-cache-dir
jupyter lab build
pip install ./dist/jlab_ext_example* --pre --find-links=dist --no-cache-dir
python -m jupyterlab.browser_check
- name: Check extension as dev
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
run: |
jupyter serverextension list 1>serverextensions 2>&1
jupyter server extension list 1>serverextensions 2>&1
cat serverextensions | grep "jlab_ext_example.*OK"
jupyter labextension list 1>labextensions 2>&1
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
Expand All @@ -209,19 +215,18 @@ jobs:
run: |
pip uninstall -y jlab_ext_example
jupyter lab clean
jupyter serverextension list
jupyter server extension list
jupyter labextension list
- name: Build extension as dev
if: steps.filter.outputs.extension == 'true'
run: |
cd advanced/server-extension
pip install -e .
jupyter serverextension enable --py jlab_ext_example
jupyter labextension install .
jupyter server extension enable --py jlab_ext_example
- name: Check extension as dev
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
run: |
jupyter serverextension list 1>serverextensions 2>&1
jupyter server extension list 1>serverextensions 2>&1
cat serverextensions | grep "jlab_ext_example.*OK"
jupyter labextension list 1>labextensions 2>&1
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
Expand Down Expand Up @@ -275,4 +280,3 @@ jobs:
jlpm build-ext
jlpm lint:check
jlpm install-ext
jlpm build-jlab
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ node_modules/
.ipynb_checkpoints
*.tsbuildinfo
*.lock
__pycache__

# Ensure embedme does not run ont node_modules README.md files.
**/node_modules/**/README.md

static
labextension
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
**/node_modules
**/lib
**/package.json
**/labextension
51 changes: 40 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,41 @@ The goal of this repository is to show how to develop extensions for [JupyterLab
To get started:

```bash
git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples && \
cd jupyterlab-extension-examples && \
conda env create && \
conda activate jupyterlab-extension-examples && \
cd basics/hello-world && \
jlpm && \
jlpm run build && \
jupyter labextension install . && \
jupyter lab
# clone the repository
git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples

# go to the extension examples folder
cd jupyterlab-extension-examples

# create a new environment
conda env create

# activate the environment
conda activate jupyterlab-extension-examples

# go to the hello world example
cd basics/hello-world

# install the extension in editable mode
python -m pip install -e .

# install your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite

# build the TypeScript source after making changes
jlpm run build

# start JupyterLab
jupyter lab
```

The examples currently target **JupyterLab 2.x**. If you would like to use the examples with JupyterLab 1.x, check out the [1.x branch](https://github.com/jupyterlab/extension-examples/tree/1.x). Note that the `1.x` branch is not updated anymore.
The examples currently target **JupyterLab 3.x**.

If you would like to use the examples with JupyterLab 2.x, check out the [2.x branch](https://github.com/jupyterlab/extension-examples/tree/2.x).

If you would like to use the examples with JupyterLab 1.x, check out the [1.x branch](https://github.com/jupyterlab/extension-examples/tree/1.x).

Note that the `1.x` and `2.x` branches are not updated anymore.

## Develop by Examples

Expand Down Expand Up @@ -210,11 +233,17 @@ conda env create && \
```bash
jlpm
jlpm build-ext
jlpm install-py
jlpm install-ext
jlpm build-jlab
jupyter lab
```

To rebuild all the extensions:

```bash
jlpm build-ext
```

To clean the lib folders:

```bash
Expand Down
22 changes: 22 additions & 0 deletions advanced/kernel-messaging/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include LICENSE
include README.md
include pyproject.toml
include jupyter-config/jupyterlab_examples_kernel_messaging.json

include package.json
include ts*.json

graft jupyterlab_examples_kernel_messaging/labextension

# Javascript files
graft src
graft style
prune **/node_modules
prune lib

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
17 changes: 11 additions & 6 deletions advanced/kernel-messaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Jupyterlab provides a class `SessionContext`
that manages a single kernel session. Here is the code to initialize such session:

```ts
// src/panel.ts#L33-L37
// src/panel.ts#L41-L45

this._sessionContext = new SessionContext({
sessionManager: manager.sessions,
Expand All @@ -46,7 +46,7 @@ this._sessionContext = new SessionContext({
```

<!-- prettier-ignore-start -->
<!-- embedme src/panel.ts#L43-L54 -->
<!-- embedme src/panel.ts#L51-L62 -->

```ts
void this._sessionContext
Expand All @@ -68,7 +68,7 @@ The session manager object is
provided directly by the JupyterLab application:

```ts
// src/index.ts#L48-L48
// src/index.ts#L52-L52

const manager = app.serviceManager;
```
Expand All @@ -81,14 +81,16 @@ to free the kernel session resources if the panel is closed. The whole adapted
panel class looks like this:

```ts
// src/panel.ts#L25-L74
// src/panel.ts#L31-L85

export class ExamplePanel extends StackedPanel {
constructor(manager: ServiceManager.IManager) {
constructor(manager: ServiceManager.IManager, translator?: ITranslator) {
super();
this._translator = translator || nullTranslator;
this._trans = this._translator.load('jupyterlab');
this.addClass(PANEL_CLASS);
this.id = 'kernel-messaging-panel';
this.title.label = 'Kernel Messaging Example View';
this.title.label = this._trans.__('Kernel Messaging Example View');
this.title.closable = true;

this._sessionContext = new SessionContext({
Expand Down Expand Up @@ -132,6 +134,9 @@ export class ExamplePanel extends StackedPanel {
private _model: KernelModel;
private _sessionContext: SessionContext;
private _example: KernelView;

private _translator: ITranslator;
private _trans: TranslationBundle;
}
```

Expand Down
5 changes: 5 additions & 0 deletions advanced/kernel-messaging/install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab_examples_kernel_messaging",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_kernel_messaging"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import json
import os.path as osp

from ._version import __version__

HERE = osp.abspath(osp.dirname(__file__))

with open(osp.join(HERE, 'labextension', 'package.json')) as fid:
data = json.load(fid)

def _jupyter_labextension_paths():
return [{
'src': 'labextension',
'dest': data['name']
}]



Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version_info = (0, 1, 0)
__version__ = ".".join(map(str, version_info))
57 changes: 36 additions & 21 deletions advanced/kernel-messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,55 @@
"url": "https://github.com/jupyterlab/extension-examples.git"
},
"scripts": {
"build": "tsc",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"install-ext": "jupyter labextension install . --no-build",
"prepare": "jlpm run clean && jlpm run build",
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:all": "jlpm run build:lib && jlpm run build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
"clean": "jlpm run clean:lib",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"clean:labextension": "rimraf jupyterlab_examples_kernel_messaging/labextension",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"watch": "tsc -w"
"install:extension": "jupyter labextension develop --overwrite .",
"prepare": "jlpm run clean && jlpm run build:prod",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^2.0.0",
"@jupyterlab/launcher": "^2.0.0",
"@jupyterlab/mainmenu": "^2.0.0",
"@jupyterlab/nbformat": "^2.0.0",
"@lumino/algorithm": "^1.2.3",
"@lumino/coreutils": "^1.3.1",
"@jupyterlab/application": "^3.0.0-rc.15",
"@jupyterlab/launcher": "^3.0.0-rc.15",
"@jupyterlab/mainmenu": "^3.0.0-rc.15",
"@jupyterlab/nbformat": "^3.0.0-rc.15",
"@jupyterlab/translation": "^3.0.0-rc.15",
"@lumino/algorithm": "^1.3.3",
"@lumino/coreutils": "^1.5.3",
"@lumino/datagrid": "^0.5.2",
"@lumino/disposable": "^1.3.1",
"@lumino/widgets": "^1.11.0"
"@lumino/disposable": "^1.4.3",
"@lumino/widgets": "^1.16.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"@jupyterlab/builder": "^3.0.0-rc.15",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-jsdoc": "^22.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.18.3",
"rimraf": "^3.0.0",
"typescript": "~3.7.5"
"npm-run-all": "^4.1.5",
"prettier": "^1.19.0",
"rimraf": "^3.0.2",
"typescript": "~4.1.3"
},
"sideEffects": [
"style/*.css"
],
"jupyterlab": {
"extension": true
"extension": true,
"outputDir": "jupyterlab_examples_kernel_messaging/labextension"
}
}
}
3 changes: 3 additions & 0 deletions advanced/kernel-messaging/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
Loading

0 comments on commit 944f073

Please sign in to comment.