Skip to content

Commit

Permalink
Merge pull request #3 from brichet/monorepo
Browse files Browse the repository at this point in the history
Split the project in two packages: UI (npm) and jupyterlab extension
  • Loading branch information
brichet authored Mar 26, 2024
2 parents dfb6bf9 + 7b16afa commit 5fb26ad
Show file tree
Hide file tree
Showing 80 changed files with 6,290 additions and 1,917 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,27 @@ jobs:
jlpm
jlpm run lint:check
- name: Test the extension
- name: Test the packages
run: |
set -eux
jlpm run test
- name: Package the project
- name: Build packages
run: jlpm build

- name: Package the extension
working-directory: packages/jupyter-chat-extension
run: |
set -eux
pip install build
python -m build
pip uninstall -y "jupyter_chat" jupyterlab
pip uninstall -y "jupyter_chat_extension" jupyterlab
- name: Upload project packages
uses: actions/upload-artifact@v3
with:
name: package-artifacts
path: dist/jupyter_chat*
path: packages/jupyter-chat-extension/dist/jupyter_chat_extension*
if-no-files-found: error

check_links:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:

token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/update-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ jobs:
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Install extension
run: |
set -eux
jlpm
python -m pip install .
run: ./scripts/install.sh

- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Playwright knows how to start JupyterLab server
start_server_script: 'null'
test_folder: ui-tests
test_folder: packages/jupyter-chat-extension/ui-tests
96 changes: 16 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,31 @@

[![Github Actions Status](https://github.com/QuantStack/jupyter-chat/workflows/Build/badge.svg)](https://github.com/QuantStack/jupyter-chat/actions/workflows/build.yml)

A chat extension for Jupyterlab
A chat package for Jupyterlab extension, but also an extension for Jupyterab.

This package is composed of a Python package named `jupyter_chat`
for the server side and a NPM package named `@jupyter/chat`
for the frontend side.
A lot of the components of this chat project come from
[jupyter-ai](https://github.com/jupyterlab/jupyter-ai).

## Requirements
## Composition

- JupyterLab >= 4.0.0
### Typescript package

## Install
The typescript package is located in *packages/jupyter-chat* and builds an NPM
package named `@jupyter/chat`.

To install the package, execute:
This package provides a frontend library (using react), and is intended to be
used by a jupyterlab extension.

```bash
pip install jupyter_chat
```
### Jupyterab extension

## Uninstall
The Jupyterlab extension is located in *packages/jupyter-chat-extension*.

To remove the package, execute:
It is composed of a Python package named `jupyter_chat_extension`
for the server side and a NPM package named `jupyter-chat-extension`.

```bash
pip uninstall jupyter_chat
```
This extension is an implementation of the `@jupyter/chat` package, relying on
websocket for the communication between server and front end.

## Contributing

### Development install

Note: You will need NodeJS to build the extension package.

The `jlpm` command is JupyterLab's pinned version of
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
`yarn` or `npm` in lieu of `jlpm` below.

```bash
# Clone the repo to your local environment
# Change directory to the jupyter_chat directory
# Install package in development mode
pip install -e ".[test]"
# Rebuild Typescript source after making changes
jlpm build
```

By default, the `jlpm build` command generates the source maps for this package to make it easier to debug using the browser dev tools.

### Development uninstall

```bash
pip uninstall jupyter_chat
```

### Testing the package

#### Server tests

This extension is using [Pytest](https://docs.pytest.org/) for Python code testing.

Install test dependencies (needed only once):

```sh
pip install -e ".[test]"
```

To execute them, run:

```sh
pytest -vv -r ap --cov jupyter_chat
```

#### Frontend tests

This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.

To execute them, execute:

```sh
jlpm
jlpm test
```

#### Integration tests

This extension uses [Playwright](https://playwright.dev/docs/intro) for the integration tests (aka user level tests).
More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.

More information are provided within the [ui-tests](./ui-tests/README.md) README.

### Packaging the extension

See [RELEASE](RELEASE.md)
See the contributing part of each package for details.
7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.1.0",
"npmClient": "jlpm",
"useNx": true
}
117 changes: 20 additions & 97 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@jupyter/chat",
"name": "@jupyter/chat-root",
"version": "0.1.0",
"description": "A chat extension for Jupyterlab",
"description": "A chat package for Jupyterlab extension",
"private": true,
"keywords": [
"jupyter",
"jupyterlab",
Expand All @@ -16,108 +17,30 @@
"name": "Jupyter Development Team",
"email": "[email protected]"
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
"src/**/*.{ts,tsx}",
"schema/*.json"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"repository": {
"type": "git",
"url": "https://github.com/QuantStack/jupyter-chat.git"
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "jlpm build:lib",
"build:prod": "jlpm clean && jlpm build:lib:prod",
"build:lib": "tsc --sourceMap",
"build:lib:prod": "tsc",
"clean": "jlpm clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:all": "jlpm clean:lib && jlpm clean:lintcache",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
"prettier": "jlpm prettier:base --write --list-different",
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "jlpm prettier:base --check",
"stylelint": "jlpm stylelint:check --fix",
"stylelint:check": "stylelint --cache \"style/**/*.css\"",
"test": "jest --coverage",
"watch:src": "tsc -w --sourceMap"
},
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@jupyterlab/apputils": "^4.0.5",
"@jupyterlab/coreutils": "^6.0.5",
"@jupyterlab/fileeditor": "^4.0.5",
"@jupyterlab/rendermime": "^4.0.5",
"@jupyterlab/services": "^7.0.5",
"@jupyterlab/ui-components": "^4.0.5",
"@lumino/coreutils": "^2.1.2",
"@lumino/disposable": "^2.1.2",
"@lumino/signaling": "^2.1.2",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"build": "lerna run build --stream",
"build:core": "lerna run build --stream --scope \"@jupyter-ai/core\"",
"build:prod": "lerna run build:prod --stream",
"clean": "lerna run clean",
"clean:all": "lerna run clean:all",
"dev": "jupyter lab --config playground/config.py",
"dev-install": "lerna run dev-install --stream",
"dev-uninstall": "lerna run dev-uninstall --stream",
"install-from-src": "lerna run install-from-src --stream",
"lint": "jlpm && lerna run prettier && lerna run eslint",
"lint:check": "lerna run prettier:check && lerna run eslint:check",
"watch": "lerna run watch --parallel --stream",
"test": "lerna run test"
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.0",
"@jupyterlab/testutils": "^4.0.0",
"@types/jest": "^29.2.0",
"@types/json-schema": "^7.0.11",
"@types/react": "^18.2.0",
"@types/react-addons-linked-state-mixin": "^0.14.22",
"@types/react-dom": "^18.2.0",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"css-loader": "^6.7.1",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.2.0",
"mkdirp": "^1.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.0",
"rimraf": "^5.0.1",
"source-map-loader": "^1.0.2",
"style-loader": "^3.3.1",
"stylelint": "^15.10.1",
"stylelint-config-recommended": "^13.0.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-csstree-validator": "^3.0.0",
"stylelint-prettier": "^4.0.0",
"typescript": "~5.0.2",
"yjs": "^13.5.0"
},
"sideEffects": [
"style/*.css",
"style/index.js"
],
"styleModule": "style/index.js",
"publishConfig": {
"access": "public"
},
"jupyterlab": {
"discovery": {
"server": {
"managers": [
"pip"
],
"base": {
"name": "jupyter_chat"
}
}
},
"extension": false,
"schemaDir": "schema"
"lerna": "^6.4.1"
},
"eslintIgnore": [
"node_modules",
Expand Down
Loading

0 comments on commit 5fb26ad

Please sign in to comment.