Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JupyterLab Extension to Launch Text Notebooks #1154

Merged
merged 19 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ on:
description: Upload build artifacts
push:
paths-ignore:
- 'CHANGELOG.md'
branches: [ main ]
- "CHANGELOG.md"
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '0 11 * * 4'
- cron: "0 11 * * 4"

permissions:
# All nested workflows will inherit these permissions and so no need to declare
Expand All @@ -34,25 +34,29 @@ jobs:
uses: ./.github/workflows/step_pre-commit.yml

codeql:
needs: [ pre-commit ]
needs: [pre-commit]
uses: ./.github/workflows/step_static-analysis.yml

test-pip:
needs: [ codeql ]
needs: [codeql]
uses: ./.github/workflows/step_tests-pip.yml

test-conda:
needs: [ codeql ]
needs: [codeql]
uses: ./.github/workflows/step_tests-conda.yml

test-ui:
needs: [codeql]
uses: ./.github/workflows/step_tests-ui.yml

build:
needs: [ test-pip, test-conda ]
needs: [test-pip, test-conda, test-ui]
uses: ./.github/workflows/step_build.yml
with:
upload: ${{ inputs.upload-build-artifacts || false }}

pass:
needs: [ pre-commit, codeql, test-pip, test-conda, build ]
needs: [pre-commit, codeql, test-pip, test-conda, test-ui, build]
runs-on: ubuntu-latest
steps:
- name: Check jobs
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/step_tests-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: test-ui
run-name: Run UI tests with Galata

on:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ui-test
cancel-in-progress: true

jobs:
test-ui:
continue-on-error: false
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install from source (required for the pre-commit tests)
run: python -m pip install -e '.[test-cov]'

- name: Install galata
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install

- name: Install browser
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
run: jlpm playwright install chromium

- name: Integration tests
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
run: jlpm playwright test

- name: Upload UI Test artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: ui-test-output
path: |
jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests/test-results
Binary file added docs/images/jupyterlab_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jupyterlab_main_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jupyterlab_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
install.md
text-notebooks.md
paired-notebooks.md
jupyterlab-extension.md
config.md
advanced-options.md
formats-scripts.md
Expand Down
31 changes: 31 additions & 0 deletions docs/jupyterlab-extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Frontend extension

Recent versions of Jupytext (`>=1.16.0`) ships frontend extension that enables users
to create text notebooks and pair notebooks from main menu of JupyterLab 4 and
Notebook 7. In addition, the frontend extension adds selected Jupytext text
notebook formats to launcher in the `Jupytext` section so that users can launch text
notebooks as they launch a regular notebook from JupyterLab launcher.

## Launcher icons

After installing Jupytext extension, users will have a new category in the launcher
called Jupytext as shown below:

![](images/jupyterlab_launcher.png)

Users can remove and/or add new formats to the Jupytext section _via_ `Settings>Jupytext`.

![](images/jupyterlab_settings.png)

By clicking `Add` and adding a new format, say `qmd`, will
add the Quatro Text Notebook to the launcher. **Note** that users need to refresh the current browser tab when they modify the settings for them to take effect.

Besides, users can also change the category of Text Notebook launcher icons using
`Category` field in the Settings. For example, by using `Notebook` as category, all
Text Notebook launchers will be moved into `Notebook` category.

## Main menu

It is also possible to launch text notebooks and/or pair existing notebooks from the dedicated Jupytext main menu as shown below.

![](images/jupyterlab_main_menu.png)
4 changes: 4 additions & 0 deletions jupyterlab/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ lib/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo

# Ignore playwright stuff
**/playwright-report
**/test-results
2 changes: 1 addition & 1 deletion jupyterlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.eslint.json",
"project": "packages/**/tsconfig.json",
"sourceType": "module",
"tsconfigRootDir": "."
},
Expand Down
26 changes: 22 additions & 4 deletions jupyterlab/packages/jupyterlab-jupytext-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,33 @@ jupyter labextension install jupyterlab-jupytext@1.1.1 # for JupyterLab 1.x

# How to develop this extension

Please follow the instructions at [developing.md](../../../docs/developing.md), i.e.
create a Python environment with a recent version of `nodejs`, and install
a development version of Jupytext by running
For fine-grained access to the `jlpm` command and various build steps:

```bash
pip install -e '.[dev]'
cd jupyterlab/packages/jupyterlab-jupytext
jlpm
jlpm install:extension # Symlink into `{sys.prefix}/share/jupyter/labextensions`
```

at the root of the Jupytext repository.
(see also the instructions at [developing.md](../../../docs/developing.md) on how to create a Python environment with a recent version of `nodejs`)

Watch the source directory and automatically rebuild the `lib` folder:

```bash
cd jupyterlab/packages/jupyterlab-jupytext
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab
```

While running `jlpm watch`, every saved change to a `.ts` file will immediately be
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very helpful! Thanks!

Copy link
Contributor

@parmentelat parmentelat Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

about jlpm watch it is indeed very convenient, just keep in mind the .ts part, because it won't trigger if you only change a .json though, so in these cases it is important to kill it and restart it, at least that was my experience; I'm unsure about .css files, so out of safety I am used to relaunching jlpm watch too, it may be unnecessary.

built locally and available in your running Jupyter client. "Hard" refresh JupyterLab or Notebook
with <kbd>CTRL-F5</kbd> or <kbd>⌘-F5</kbd> to load the change in your browser
(you may need to wait several seconds for the extension to be fully rebuilt).

Read more on this on the [JupyterLab documentation](https://jupyterlab.readthedocs.io/en/latest/extension/extension_dev.html#developing-a-prebuilt-extension).

# How to publish a new version of the extension on npm

Expand Down
14 changes: 11 additions & 3 deletions jupyterlab/packages/jupyterlab-jupytext-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"type": "git",
"url": "https://github.com/mwouts/jupytext.git"
},
"workspaces": [
"ui-tests"
],
"scripts": {
"build": "jlpm run build:lib && jlpm run build:labextension:dev && jlpm run copy:extensioncfgfile",
"build:labextension": "jupyter labextension build .",
Expand All @@ -35,7 +38,7 @@
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"clean:labextension": "rimraf ../../jupyterlab_jupytext/labextension",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"install:extension": "jupyter labextension develop --overwrite .",
"install:extension": "python ../../scripts/install_extension.py",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
Expand Down Expand Up @@ -65,18 +68,23 @@
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@jupyterlab/codeeditor": "^4.0.0",
"@jupyterlab/docregistry": "^4.0.0",
"@jupyterlab/filebrowser": "^4.0.0",
"@jupyterlab/launcher": "^4.0.0",
"@jupyterlab/nbformat": "^4.0.0",
"@jupyterlab/notebook": "^4.0.0",
"@jupyterlab/rendermime": "^4.0.0",
"@jupyterlab/settingregistry": "^4.0.0",
"@jupyterlab/translation": "^4.0.0",
"@jupyterlab/ui-components": "^4.0.0",
"@lumino/coreutils": "^2.0.0",
"@lumino/disposable": "^2.0.0",
"jupyterlab-rise": "^0.41.0"
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"typescript": "~5.0.1"
"rimraf": "^4.4.1",
"typescript": "~5.0.2"
}
}
Loading
Loading