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

Improve development setup #1

Merged
merged 5 commits into from
Feb 21, 2023
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ dmypy.json
# OSX files
.DS_Store

# notebooks folder
notebooks/
# playground folder
playground/
54 changes: 48 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,55 @@
[![Github Actions Status](https://github.com/jupyterlab/jupyter_ai/workflows/Build/badge.svg)](https://github.com/jupyterlab/jupyter_ai/actions/workflows/build.yml)
A generative AI extension for JupyterLab

### Dev setup
```shell
hatch -e default shell # once, "exit" will escape from shell
jlpm run build # for each change
This is a monorepo that houses the core `jupyter_ai` package in addition to the
default supported AI modules. To learn more about the core package, please refer
to the [README](packages/jupyter-ai/README.md).

### Development install

Install the Hatch CLI, which installs the Hatchling build backend automatically.

```
pip install hatch
```

Then, simply enter the default hatch environment, which automatically installs
all dependencies and executes development setup when entering for the first
time. This command must be run with the current directory set to the root of the
monorepo (`<jupyter-ai-top>`).

```
cd <jupyter-ai-top>
hatch shell
```

Set up your development environment and start the server:

```
jlpm setup:dev # only needs to be run once
jlpm dev
```

Finally, in a separate shell, enter the hatch environment and build the project
after making any changes.

```
cd <jupyter-ai-top>
hatch shell
jlpm build
```

To exit the hatch environment at any time, exit like you would normally exit a
shell process, via the `exit` command or `Ctrl+D`.

If installation fails for any reason, you will have to first uninstall the hatch
environment and then test your fix by reinstalling. See "Uninstall" procedure
below.

### Uninstall
```shell

Just remove the hatch environment:

```
hatch env remove default
```
```
10 changes: 5 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.0.0",
"npmClient": "yarn"
}
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.0.0",
"npmClient": "yarn"
}
15 changes: 15 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"targetDefaults": {
"setup:dev": {
"dependsOn": ["build"]
}
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "test"]
}
}
}
}
37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"setup": "lerna run setup:dev --stream --concurrency=1",
"build": "lerna run build --stream --concurrency=1",
"lint": "jlpm && lerna run prettier && lerna run eslint",
"lint:check": "lerna run prettier:check && lerna run eslint:check",
"clean": "lerna run clean",
"watch": "lerna run watch --parallel --stream"
},
"devDependencies": {
"lerna": "^6.4.1",
"@jupyterlab/builder": "^3.1.0"
}
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"setup:dev": "lerna run setup:dev --stream --concurrency=1",
"build": "lerna run build --stream --concurrency=1",
"clean": "lerna run clean",
"clean:all": "lerna run clean:all",
"dev": "jupyter lab --config playground/config.py",
"lint": "jlpm && lerna run prettier && lerna run eslint",
"lint:check": "lerna run prettier:check && lerna run eslint:check",
"watch": "lerna run watch --parallel --stream"
},
"devDependencies": {
"lerna": "^6.4.1",
"@jupyterlab/builder": "^3.1.0"
}
}
3 changes: 2 additions & 1 deletion packages/jupyter-ai-dalle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"stylelint-config-standard": "~24.0.0",
"stylelint-prettier": "^2.0.0",
"typescript": "~4.1.3",
"ts-jest": "^26.0.0"
"ts-jest": "^26.0.0",
"jupyter_ai": "^0.1.0"
},
"sideEffects": [
"style/*.css",
Expand Down
1 change: 1 addition & 0 deletions packages/jupyter-ai-dalle/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ classifiers = [
dependencies = [
"openai~=0.26",
]

dynamic = ["version", "description", "authors", "urls", "keywords"]

[project.optional-dependencies]
Expand Down
1 change: 1 addition & 0 deletions packages/jupyter-ai-dalle/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"rootDir": "src",
"strict": true,
"strictNullChecks": true,
"skipLibCheck": true,
"target": "ES2018",
"types": ["jest"]
},
Expand Down
4 changes: 4 additions & 0 deletions playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# jupyter-ai playground

Contents root that should be served by JupyterLab when developing Jupyter AI. An
example configuration is provided in `config.example.py`.
9 changes: 9 additions & 0 deletions playground/config.example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# JupyterLab configuration file for Jupyter AI local development
# Reference: https://jupyter-server.readthedocs.io/en/latest/other/full-config.html

#c.GPT3ModelEngine.api_key = "<YOUR-API-KEY-HERE>"
#c.DalleModelEngine.api_key = "<YOUR-API-KEY-HERE>"

# Specify full path to the notebook dir if running jupyter lab from
# outside of the jupyter-ai project root directory
c["notebook-dir"] = "./playground"
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling>=1.4.0", "jupyterlab>=3.4.7,<4.0.0", "hatch-nodejs-version"]
requires = ["hatchling>=1.4.0", "jupyterlab~=3.4", "hatch-nodejs-version"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -29,13 +29,13 @@ Homepage = "https://jupyter.org"

[tool.hatch.envs.default]
pre-install-commands = [
"pip install jupyterlab",
"jlpm install"
"pip install jupyterlab~=3.4",
"cp playground/config.example.py playground/config.py"
]
post-install-commands = [
"scripts/install.sh"
"jlpm install", # install JS dependencies
"scripts/install.sh", # install Jupyter server extensions and their Python dependencies
]
dependencies = ["jupyterlab>=3.4.7,<4.0.0"]

[tool.hatch.version]
source = "nodejs"
Expand Down