diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eef4d9290..ed028bbbc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,9 +9,7 @@ repos: - id: check-added-large-files - id: check-case-conflict - id: check-toml - exclude: ^packages/jupyter-ai-module-cookiecutter - id: check-yaml - exclude: ^packages/jupyter-ai-module-cookiecutter - id: debug-statements - id: forbid-new-submodules - id: check-builtin-literals diff --git a/docs/source/developers/index.md b/docs/source/developers/index.md index d2759039e..6209c9c71 100644 --- a/docs/source/developers/index.md +++ b/docs/source/developers/index.md @@ -153,7 +153,9 @@ Please note that this will only work with Jupyter AI magics (the `%ai` and `%%ai ## Custom slash commands in the chat UI You can add a custom slash command to the chat interface by -creating a new class that inherits from `BaseChatHandler`. Set +creating a JupyterLab extension using the +[JupyterLab extension template](https://github.com/jupyterlab/extension-template). +Create a new class that inherits from `BaseChatHandler`. Set its `id`, `name`, `help` message for display in the user interface, and `routing_type`. Each custom slash command must have a unique slash command. Slash commands can only contain ASCII letters, numerals, diff --git a/packages/jupyter-ai-module-cookiecutter/.gitignore b/packages/jupyter-ai-module-cookiecutter/.gitignore deleted file mode 100644 index 6011778ac..000000000 --- a/packages/jupyter-ai-module-cookiecutter/.gitignore +++ /dev/null @@ -1,120 +0,0 @@ -*.bundle.* -lib/ -node_modules/ -*.egg-info/ -.ipynb_checkpoints -*.tsbuildinfo -.eslintcache -.stylelintcache -{{cookiecutter.python_name}}/static - -# Created by https://www.gitignore.io/api/python -# Edit at https://www.gitignore.io/?templates=python - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ -coverage/lcov-report/ -coverage/lcov.info - -# Translations -*.mo -*.pot - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# End of https://www.gitignore.io/api/python - -# OSX files -.DS_Store - -# Default extension dir -myextension -.vscode/ diff --git a/packages/jupyter-ai-module-cookiecutter/LICENSE b/packages/jupyter-ai-module-cookiecutter/LICENSE deleted file mode 100644 index 9103850d6..000000000 --- a/packages/jupyter-ai-module-cookiecutter/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2017-2021, Project Jupyter Contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/jupyter-ai-module-cookiecutter/README.md b/packages/jupyter-ai-module-cookiecutter/README.md deleted file mode 100644 index b99f3617d..000000000 --- a/packages/jupyter-ai-module-cookiecutter/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Jupyter AI Module Cookiecutter - -A [cookiecutter](https://github.com/audreyr/cookiecutter) template for creating -a AI module. The AI module constructed from the template serves as a very simple -example that can be extended however you wish. - -## Usage - -Install cookiecutter. - -``` -pip install cookiecutter -``` - -Then from the project root, run these commands: - -``` -cd packages/ -cookiecutter jupyter-ai-module-cookiecutter -``` - -Follow the prompts to create a new AI module under `packages/`. Your -labextension name should use hyphens, whereas your Python name should use -underscores. - -# Usage (monorepo integration) - -To integrate the new AI module into this monorepo, execute this command -manually from the AI module root: - -``` -rm -r .github/ binder/ CHANGELOG.md RELEASE.md -``` - -Rename the JS package to be scoped under `@jupyter-ai/`. - -Finally, add the Python package to the `options.python_packages` field in -`.jupyter-releaser.toml`. diff --git a/packages/jupyter-ai-module-cookiecutter/cookiecutter.json b/packages/jupyter-ai-module-cookiecutter/cookiecutter.json deleted file mode 100644 index 1eee5c941..000000000 --- a/packages/jupyter-ai-module-cookiecutter/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "author_name": "Project Jupyter", - "author_email": "jupyter@googlegroups.com", - "version": "0.1.0", - "labextension_name": "myextension", - "python_name": "{{ cookiecutter.labextension_name | replace('-', '_') }}", - "project_short_description": "A JupyterLab extension.", - "has_settings": "n", - "has_binder": "n", - "test": "y", - "repository": "https://github.com/jupyterlab/jupyter-ai" -} diff --git a/packages/jupyter-ai-module-cookiecutter/hooks/post_gen_project.py b/packages/jupyter-ai-module-cookiecutter/hooks/post_gen_project.py deleted file mode 100644 index aa816e397..000000000 --- a/packages/jupyter-ai-module-cookiecutter/hooks/post_gen_project.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -from pathlib import Path - -PROJECT_DIRECTORY = Path.cwd() - - -def remove_path(path: Path) -> None: - """Remove the provided path. - - If the target path is a directory, remove it recursively. - """ - if not path.exists(): - return - - if path.is_file(): - path.unlink() - elif path.is_dir(): - for f in path.iterdir(): - remove_path(f) - path.rmdir() - - -if __name__ == "__main__": - if not "{{ cookiecutter.has_settings }}".lower().startswith("y"): - remove_path(PROJECT_DIRECTORY / "schema") - - if not "{{ cookiecutter.has_binder }}".lower().startswith("y"): - remove_path(PROJECT_DIRECTORY / "binder") - remove_path(PROJECT_DIRECTORY / ".github/workflows/binder-on-pr.yml") - - if not "{{ cookiecutter.test }}".lower().startswith("y"): - remove_path( - PROJECT_DIRECTORY / ".github" / "workflows" / "update-integration-tests.yml" - ) - remove_path(PROJECT_DIRECTORY / "src" / "__tests__") - remove_path(PROJECT_DIRECTORY / "ui-tests") - remove_path(PROJECT_DIRECTORY / "{{ cookiecutter.python_name }}" / "tests") - remove_path(PROJECT_DIRECTORY / "babel.config.js") - remove_path(PROJECT_DIRECTORY / "conftest.py") - remove_path(PROJECT_DIRECTORY / "jest.config.js") diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.eslintignore b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.eslintignore deleted file mode 100644 index fffa32fdf..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -dist -coverage -**/*.d.ts -tests - -**/__tests__ -ui-tests diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.eslintrc.js b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.eslintrc.js deleted file mode 100644 index fc2ba9ac6..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.eslintrc.js +++ /dev/null @@ -1,41 +0,0 @@ -module.exports = { - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended' - ], - parser: '@typescript-eslint/parser', - parserOptions: { - project: './tsconfig.json' - }, - plugins: ['@typescript-eslint'], - rules: { - '@typescript-eslint/naming-convention': [ - 'error', - { - selector: 'interface', - format: ['PascalCase'], - custom: { - regex: '^I[A-Z]', - match: true - } - } - ], - '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-namespace': 'off', - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/quotes': [ - 'error', - 'single', - { avoidEscape: true, allowTemplateLiterals: false } - ], - curly: ['error', 'all'], - eqeqeq: 'error', - 'prefer-arrow-callback': 'error' - }, - overrides: { - files: ['src/**/*'] - } -}; diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/binder-on-pr.yml b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/binder-on-pr.yml deleted file mode 100644 index 5d7944bb6..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/binder-on-pr.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html -name: Binder Badge -on: - pull_request_target: - types: [opened] - -permissions: - pull-requests: write -{# Escape double curly brace #} -{% raw %} -jobs: - binder: - runs-on: ubuntu-latest - steps: - - name: comment on PR with Binder link - uses: actions/github-script@v3 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO; - var PR_HEAD_REF = process.env.PR_HEAD_REF; - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Launch a Binder on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_` - }) - env: - PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} - PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }} -{% endraw %} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/build.yml b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/build.yml deleted file mode 100644 index 0706fd9a5..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/build.yml +++ /dev/null @@ -1,149 +0,0 @@ -name: Build - -on: - push: - branches: main - pull_request: - branches: '*' - -jobs: - build: - 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 dependencies - run: python -m pip install -U jupyterlab~=4.0 - - - name: Lint the extension - run: | - set -eux - jlpm - jlpm run lint:check -{% if cookiecutter.test.lower().startswith('y') %} - - name: Test the extension - run: | - set -eux - jlpm run test -{% endif %} - - name: Build the extension - run: | - set -eux - python -m pip install .[test] - - jupyter labextension list - jupyter labextension list 2>&1 | grep -ie "{{ cookiecutter.labextension_name }}.*OK" - python -m jupyterlab.browser_check - - - name: Package the extension - run: | - set -eux - - pip install build - python -m build - pip uninstall -y "{{ cookiecutter.python_name }}" jupyterlab - - - name: Upload extension packages - uses: actions/upload-artifact@v3 - with: - name: extension-artifacts - path: dist/{{ cookiecutter.python_name }}* - if-no-files-found: error - - test_isolated: - needs: build - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - architecture: 'x64' - - uses: actions/download-artifact@v3 - with: - name: extension-artifacts - - name: Install and Test - run: | - set -eux - # Remove NodeJS, twice to take care of system and locally installed node versions. - sudo rm -rf $(which node) - sudo rm -rf $(which node) - - pip install "jupyterlab~=4.0" {{ cookiecutter.python_name }}*.whl - - jupyter labextension list - jupyter labextension list 2>&1 | grep -ie "{{ cookiecutter.labextension_name }}.*OK" - python -m jupyterlab.browser_check --no-chrome-test -{% if cookiecutter.test.lower().startswith('y') %} - integration-tests: - name: Integration tests - needs: build - runs-on: ubuntu-latest - - env: - PLAYWRIGHT_BROWSERS_PATH: ${{ "{{ github.workspace }}" }}/pw-browsers - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - - name: Download extension package - uses: actions/download-artifact@v3 - with: - name: extension-artifacts - - - name: Install the extension - run: | - set -eux - python -m pip install "jupyterlab~=4.0" {{ cookiecutter.python_name }}*.whl - - - name: Install dependencies - working-directory: ui-tests - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: jlpm install -{% raw %} - - name: Set up browser cache - uses: actions/cache@v3 - with: - path: | - ${{ github.workspace }}/pw-browsers - key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }} -{% endraw %} - - name: Install browser - run: jlpm playwright install chromium - working-directory: ui-tests - - - name: Execute integration tests - working-directory: ui-tests - run: | - jlpm playwright test - - - name: Upload Playwright Test report - if: always() - uses: actions/upload-artifact@v3 - with: - name: {{ cookiecutter.python_name }}-playwright-tests - path: | - ui-tests/test-results - ui-tests/playwright-report{% endif %} - - check_links: - name: Check Links - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@v3 - - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1 diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/check-release.yml b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/check-release.yml deleted file mode 100644 index ad19ee9da..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/check-release.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Check Release -on: - push: - branches: ["main"] - pull_request: - branches: ["*"] - -jobs: - check_release: - 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 Dependencies - run: | - pip install -e . - - name: Check Release - uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2 - with: -{% raw %} - token: ${{ secrets.GITHUB_TOKEN }} -{% endraw %} - - name: Upload Distributions - uses: actions/upload-artifact@v3 - with: - name: {{ cookiecutter.python_name }}-releaser-dist-${{ '{{ github.run_number }}' }} - path: .jupyter_releaser_checkout/dist diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/update-integration-tests.yml b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/update-integration-tests.yml deleted file mode 100644 index df49004e6..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.github/workflows/update-integration-tests.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Update Playwright Snapshots - -on: - issue_comment: - types: [created, edited] - -permissions: - contents: write - pull-requests: write - -jobs: - {# Escape double curly brace #} - {% raw %} - update-snapshots: - if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots') }} - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Configure git to use https - run: git config --global hub.protocol https - - - name: Checkout the branch from the PR that triggered the job - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - - name: Install dependencies - run: python -m pip install -U jupyterlab~=4.0 - - - name: Install extension - run: | - set -eux - jlpm - python -m pip install . - - - 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 - {% endraw %} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.gitignore b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.gitignore deleted file mode 100644 index cdbe48ab7..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.gitignore +++ /dev/null @@ -1,122 +0,0 @@ -*.bundle.* -lib/ -node_modules/ -*.log -.eslintcache -.stylelintcache -*.egg-info/ -.ipynb_checkpoints -*.tsbuildinfo -{{cookiecutter.python_name}}/labextension -# Version file is handled by hatchling -{{cookiecutter.python_name}}/_version.py - -# Integration tests -ui-tests/test-results/ -ui-tests/playwright-report/ - -# Created by https://www.gitignore.io/api/python -# Edit at https://www.gitignore.io/?templates=python - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage/ -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# End of https://www.gitignore.io/api/python - -# OSX files -.DS_Store diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.prettierignore b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.prettierignore deleted file mode 100644 index 1df93abe2..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -**/node_modules -**/lib -**/package.json -!/package.json -{{cookiecutter.python_name}} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.prettierrc b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.prettierrc deleted file mode 100644 index d0824a69c..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "none", - "arrowParens": "avoid", - "endOfLine": "auto" -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.stylelintrc b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.stylelintrc deleted file mode 100644 index 0e1ff3032..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/.stylelintrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": [ - "stylelint-config-recommended", - "stylelint-config-standard", - "stylelint-prettier/recommended" - ], - "rules": { - "property-no-vendor-prefix": null, - "selector-no-vendor-prefix": null, - "value-no-vendor-prefix": null - } -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/CHANGELOG.md b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/CHANGELOG.md deleted file mode 100644 index 2d352af42..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Changelog - - - - diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/LICENSE b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/LICENSE deleted file mode 100644 index c71b5cc78..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }} -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/README.md b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/README.md deleted file mode 100644 index 726fd8850..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/README.md +++ /dev/null @@ -1,124 +0,0 @@ -# {{ cookiecutter.python_name }} - -This extension is composed of a Python package named `{{ cookiecutter.python_name }}` -that exposes the model engines to the Jupyter AI server extension, -and an NPM package named `{{ cookiecutter.labextension_name }}` -that provides a frontend labextension registering inserters. - -## Requirements - -- Python 3.8 - 3.11 -- JupyterLab 4 - -## Install - -To install the extension, execute: - -```bash -pip install {{ cookiecutter.python_name }} -``` - -## Uninstall - -To remove the extension, execute: - -```bash -pip uninstall {{ cookiecutter.python_name }} -``` -## 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 {{ cookiecutter.python_name }} directory -# Install package in development mode -pip install -e ".{% if cookiecutter.test.lower().startswith('y') %}[test]{% endif %}" -# Link your development version of the extension with JupyterLab -jupyter labextension develop . --overwrite -# Rebuild extension Typescript source after making changes -jlpm build -``` - -You can watch the source directory and run JupyterLab at the same time in -different terminals to watch for changes in the extension's source and -automatically rebuild the extension. - -```bash -# Watch the source directory in one terminal, automatically rebuilding when needed -jlpm watch -# Run JupyterLab in another terminal -jupyter lab -``` - -With the watch command running, every saved change will immediately be built -locally and available in your running JupyterLab. Refresh JupyterLab to load the -change in your browser (you may need to wait several seconds for the extension -to be rebuilt). - -By default, the `jlpm build` command generates the source maps for this -extension to make it easier to debug using the browser dev tools. To also -generate source maps for the JupyterLab core extensions, you can run the -following command: - -```bash -jupyter lab build --minimize=False -``` - -### Development uninstall - -```bash -pip uninstall {{ cookiecutter.python_name }} -``` - -In development mode, you will also need to remove the symlink created by `jupyter labextension develop` -command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions` -folder is located. Then you can remove the symlink named `{{ cookiecutter.labextension_name }}` within that folder. -{% if cookiecutter.test.lower().startswith('y') %} -### Testing the extension - -#### Backend tests - -This AI module is using [Pytest](https://docs.pytest.org/) for Python code testing. - -Install test dependencies (needed only once): - -```sh -pip install -e ".[test]" -# Each time you install the Python package, you need to restore the front-end extension link -jupyter labextension develop . --overwrite -``` - -To execute them, run: - -```sh -pytest -vv -r ap --cov {{ cookiecutter.python_name }} -``` - -#### 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. -{% endif %} -### Packaging the extension - -See [RELEASE](RELEASE.md) diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/RELEASE.md b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/RELEASE.md deleted file mode 100644 index 95d17e321..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/RELEASE.md +++ /dev/null @@ -1,68 +0,0 @@ -# Making a new release of {{ cookiecutter.python_name }} - -The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser). - -## Manual release - -### Python package - -This extension can be distributed as Python -packages. All of the Python -packaging instructions in the `pyproject.toml` file to wrap your extension in a -Python package. Before generating a package, we first need to install `build`. - -```bash -pip install build twine hatch -``` - -Bump the version using `hatch`. By default this will create a tag. -See the docs on [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version#semver) for details. - -```bash -hatch version -``` - -To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do: - -```bash -python -m build -``` - -> `python setup.py sdist bdist_wheel` is deprecated and will not work for this package. - -Then to upload the package to PyPI, do: - -```bash -twine upload dist/* -``` - -### NPM package - -To publish the frontend part of the extension as a NPM package, do: - -```bash -npm login -npm publish --access public -``` - -## Automated releases with the Jupyter Releaser - -The extension repository should already be compatible with the Jupyter Releaser. - -Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for more information. - -Here is a summary of the steps to cut a new release: - -- Fork the [`jupyter-releaser` repo](https://github.com/jupyter-server/jupyter_releaser) -- Add `ADMIN_GITHUB_TOKEN`, `PYPI_TOKEN` and `NPM_TOKEN` to the Github Secrets in the fork -- Go to the Actions panel -- Run the "Draft Changelog" workflow -- Merge the Changelog PR -- Run the "Draft Release" workflow -- Run the "Publish Release" workflow - -## Publishing to `conda-forge` - -If the package is not on conda forge yet, check the documentation to learn how to add it: https://conda-forge.org/docs/maintainer/adding_pkgs.html - -Otherwise a bot should pick up the new version publish to PyPI, and open a new PR on the feedstock repository automatically. diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/babel.config.js b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/babel.config.js deleted file mode 100644 index 8b5c76420..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/babel.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@jupyterlab/testutils/lib/babel.config'); diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/binder/environment.yml b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/binder/environment.yml deleted file mode 100644 index 04fcd5b25..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/binder/environment.yml +++ /dev/null @@ -1,21 +0,0 @@ -# a mybinder.org-ready environment for demoing {{ cookiecutter.python_name }} -# this environment may also be used locally on Linux/MacOS/Windows, e.g. -# -# conda env update --file binder/environment.yml -# conda activate {{ cookiecutter.python_name | replace('_', '-') }}-demo -# -name: {{ cookiecutter.python_name | replace('_', '-') }}-demo - -channels: - - conda-forge - -dependencies: - # runtime dependencies - - python >=3.8,<3.9.0a0 - - jupyterlab >=4,<5 - # labextension build dependencies - - nodejs >=18,<19 - - pip - - wheel - # additional packages for demos - # - ipywidgets diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/binder/postBuild b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/binder/postBuild deleted file mode 100755 index d4b13f656..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/binder/postBuild +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 -""" perform a development install of {{ cookiecutter.python_name }} - - On Binder, this will run _after_ the environment has been fully created from - the environment.yml in this directory. - - This script should also run locally on Linux/MacOS/Windows: - - python3 binder/postBuild -""" -import subprocess -import sys -from pathlib import Path - - -ROOT = Path.cwd() - - -def _(*args, **kwargs): - """Run a command, echoing the args - - fails hard if something goes wrong - """ - print("\n\t", " ".join(args), "\n") - return_code = subprocess.call(args, **kwargs) - if return_code != 0: - print("\nERROR", return_code, " ".join(args)) - sys.exit(return_code) - - -# verify the environment is self-consistent before even starting -_(sys.executable, "-m", "pip", "check") - -# install the labextension -_(sys.executable, "-m", "pip", "install", "-e", ".") -_(sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", ".") - -# verify the environment the extension didn't break anything -_(sys.executable, "-m", "pip", "check") - -# list the extensions -_("jupyter", "server", "extension", "list") - -# initially list installed extensions to determine if there are any surprises -_("jupyter", "labextension", "list") - - -print("JupyterLab with {{ cookiecutter.python_name }} is ready to run with:\n") -print("\tjupyter lab\n") diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/install.json b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/install.json deleted file mode 100644 index df7b7f493..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/install.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "packageManager": "python", - "packageName": "{{ cookiecutter.python_name }}", - "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package {{ cookiecutter.python_name }}" -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/jest.config.js b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/jest.config.js deleted file mode 100644 index 4f1bf3dab..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/jest.config.js +++ /dev/null @@ -1,46 +0,0 @@ -const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config'); - -const esModules = [ - '@jupyterlab/', - 'lib0', - 'y\\-protocols', - 'y\\-websocket', - 'yjs' -].join('|'); - -const jlabConfig = jestJupyterLab(__dirname); - -const { - moduleFileExtensions, - moduleNameMapper, - preset, - setupFilesAfterEnv, - setupFiles, - testPathIgnorePatterns, - transform -} = jlabConfig; - -module.exports = { - moduleFileExtensions, - moduleNameMapper, - preset, - setupFilesAfterEnv, - setupFiles, - testPathIgnorePatterns, - transform, - automock: false, - collectCoverageFrom: [ - 'src/**/*.{ts,tsx}', - '!src/**/*.d.ts', - '!src/**/.ipynb_checkpoints/*' - ], - coverageDirectory: 'coverage', - coverageReporters: ['lcov', 'text'], - globals: { - 'ts-jest': { - tsconfig: 'tsconfig.json' - } - }, - testRegex: 'src/.*/.*.spec.ts[x]?$', - transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`] -}; diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/package.json b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/package.json deleted file mode 100644 index 750418fa0..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/package.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "name": "{{ cookiecutter.labextension_name }}", - "version": "{{ cookiecutter.version }}", - "description": "{{ cookiecutter.project_short_description }}", - "keywords": [ - "jupyter", - "jupyterlab", - "jupyterlab-extension" - ], - "homepage": "{{ cookiecutter.repository }}", - "bugs": { - "url": "{{ cookiecutter.repository }}/issues", - "email": "{{ cookiecutter.author_email }}" - }, - "license": "BSD-3-Clause", - "author": { - "name": "{{ cookiecutter.author_name }}", - "email": "{{ cookiecutter.author_email }}" - }, - "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}"{% if cookiecutter.has_settings.lower().startswith('y') %}, - "schema/*.json"{% endif %} - ], - "main": "lib/index.js", - "types": "lib/index.d.ts", - "style": "style/index.css", - "repository": { - "type": "git", - "url": "{{ cookiecutter.repository }}.git" - }, - "scripts": { - "build": "jlpm build:lib && jlpm build:labextension:dev", - "build:prod": "jlpm clean && jlpm build:lib && jlpm build:labextension", - "build:labextension": "jupyter labextension build .", - "build:labextension:dev": "jupyter labextension build --development True .", - "build:lib": "tsc", - "clean": "jlpm clean:lib", - "clean:lib": "rimraf lib tsconfig.tsbuildinfo", - "clean:lintcache": "rimraf .eslintcache .stylelintcache", - "clean:labextension": "rimraf {{ cookiecutter.python_name }}/labextension {{ cookiecutter.python_name }}/_version.py", - "clean:all": "jlpm clean:lib && jlpm clean:labextension && 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", - "dev-install": "pip install -e . && jupyter labextension develop . --overwrite && jupyter server extension enable {{ cookiecutter.python_name }}", - "stylelint": "jlpm stylelint:check --fix", - "stylelint:check": "stylelint --cache \"style/**/*.css\"",{% if cookiecutter.test.lower().startswith('y') %} - "test": "jest --coverage",{% endif %} - "watch": "run-p watch:src watch:labextension", - "watch:src": "tsc -w", - "watch:labextension": "jupyter labextension watch ." - }, - "dependencies": { - "@jupyterlab/application": "^3.1.0"{% if cookiecutter.has_settings.lower().startswith('y') %}, - "@jupyterlab/settingregistry": "^3.1.0"{% endif %} - }, - "devDependencies": { - {% if cookiecutter.test.lower().startswith('y') %}"@babel/core": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "@jupyter-ai/core": "^{{ cookiecutter.version }}", - {% endif %}"@jupyterlab/builder": "^3.1.0",{% if cookiecutter.test.lower().startswith('y') %} - "@jupyterlab/testutils": "^3.0.0", - "@types/jest": "^26.0.0",{% endif %} - "@typescript-eslint/eslint-plugin": "^4.8.1", - "@typescript-eslint/parser": "^4.8.1", - "eslint": "^7.14.0", - "eslint-config-prettier": "^6.15.0", - "eslint-plugin-prettier": "^3.1.4",{% if cookiecutter.test.lower().startswith('y') %} - "jest": "^26.0.0",{% endif %} - "npm-run-all": "^4.1.5", - "prettier": "^2.1.1", - "rimraf": "^3.0.2", - "stylelint": "^14.3.0", - "stylelint-config-prettier": "^9.0.4", - "stylelint-config-recommended": "^6.0.0", - "stylelint-config-standard": "~24.0.0", - "stylelint-prettier": "^2.0.0", - "typescript": "~4.1.3"{% if cookiecutter.test.lower().startswith('y') %}, - "ts-jest": "^26.0.0"{% endif %} - }, - "sideEffects": [ - "style/*.css", - "style/index.js" - ], - "styleModule": "style/index.js", - "publishConfig": { - "access": "public" - }, - "jupyterlab": { - "extension": true, - "outputDir": "{{cookiecutter.python_name}}/labextension"{% if cookiecutter.has_settings.lower().startswith('y') %}, - "schemaDir": "schema"{% endif %} - } -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/pyproject.toml b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/pyproject.toml deleted file mode 100644 index 3c21fd8cf..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/pyproject.toml +++ /dev/null @@ -1,89 +0,0 @@ -[build-system] -requires = ["hatchling>=1.4.0", "jupyterlab~=4.0", "hatch-nodejs-version"] -build-backend = "hatchling.build" - -[project] -name = "{{ cookiecutter.python_name }}" -readme = "README.md" -license = { file = "LICENSE" } -requires-python = ">=3.8" -classifiers = [ - "Framework :: Jupyter", - "Framework :: Jupyter :: JupyterLab", - "Framework :: Jupyter :: JupyterLab :: 4", - "Framework :: Jupyter :: JupyterLab :: Extensions", - "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", -] - -dynamic = ["version", "description", "authors", "urls", "keywords"] -{% if cookiecutter.test.lower().startswith('y') %} -[project.optional-dependencies] -test = [ - "coverage", - "pytest", - "pytest-asyncio", - "pytest-cov" -] -{% endif %} -dependencies = [ - "jupyter_ai" -] - -[project.entry-points."jupyter_ai.model_engine_classes"] -TestModelEngine = "{{ cookiecutter.python_name }}:TestModelEngine" - -[project.entry-points."jupyter_ai.default_tasks"] -TestDefaultTasks = "{{ cookiecutter.python_name }}:tasks" - -[tool.hatch.version] -source = "nodejs" - -[tool.hatch.metadata.hooks.nodejs] -fields = ["description", "authors", "urls"] - -[tool.hatch.build.targets.sdist] -artifacts = ["{{ cookiecutter.python_name }}/labextension"] -exclude = [".github", "binder"] - -[tool.hatch.build.targets.wheel.shared-data] -"{{ cookiecutter.python_name }}/labextension" = "share/jupyter/labextensions/{{ cookiecutter.labextension_name }}" -"install.json" = "share/jupyter/labextensions/{{ cookiecutter.labextension_name }}/install.json" - -[tool.hatch.build.hooks.version] -path = "{{ cookiecutter.python_name }}/_version.py" - -[tool.hatch.build.hooks.jupyter-builder] -dependencies = ["hatch-jupyter-builder>=0.5"] -build-function = "hatch_jupyter_builder.npm_builder" -ensured-targets = [ - "{{ cookiecutter.python_name }}/labextension/static/style.js", - "{{ cookiecutter.python_name }}/labextension/package.json", -] -skip-if-exists = ["{{ cookiecutter.python_name }}/labextension/static/style.js"] - -[tool.hatch.build.hooks.jupyter-builder.build-kwargs] -build_cmd = "build:prod" -npm = ["jlpm"] - -[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs] -build_cmd = "install:extension" -npm = ["jlpm"] -source_dir = "src" -build_dir = "{{cookiecutter.python_name}}/labextension" - -[tool.jupyter-releaser.options] -version_cmd = "hatch version" - -[tool.jupyter-releaser.hooks] -before-build-npm = ["python -m pip install jupyterlab~=4.0", "jlpm", "jlpm build:prod"] -before-build-python = ["jlpm clean:all"] - -[tool.check-wheel-contents] -ignore = ["W002"] diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/schema/plugin.json b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/schema/plugin.json deleted file mode 100644 index 8ad573965..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/schema/plugin.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "jupyter.lab.shortcuts": [], - "title": "{{ cookiecutter.labextension_name }}", - "description": "{{ cookiecutter.labextension_name }} settings.", - "type": "object", - "properties": {}, - "additionalProperties": false -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/setup.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/setup.py deleted file mode 100644 index aefdf20db..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/setup.py +++ /dev/null @@ -1 +0,0 @@ -__import__("setuptools").setup() diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/src/__tests__/{{cookiecutter.python_name}}.spec.ts b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/src/__tests__/{{cookiecutter.python_name}}.spec.ts deleted file mode 100644 index 244d0548c..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/src/__tests__/{{cookiecutter.python_name}}.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Example of [Jest](https://jestjs.io/docs/getting-started) unit tests - */ - -describe('{{ cookiecutter.labextension_name }}', () => { - it('should be tested', () => { - expect(1 + 1).toEqual(2); - }); -}); diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/src/index.ts b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/src/index.ts deleted file mode 100644 index 28e8a22de..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/src/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { - JupyterFrontEnd, - JupyterFrontEndPlugin -} from '@jupyterlab/application'; - -import type { InsertionContext } from '@jupyter-ai/core';{% if cookiecutter.has_settings.lower().startswith('y') %} - -import { ISettingRegistry } from '@jupyterlab/settingregistry';{% endif %} - -/** - * Initialization data for the {{ cookiecutter.labextension_name }} extension. - */ -const plugin: JupyterFrontEndPlugin = { - id: '{{ cookiecutter.labextension_name }}:plugin', - autoStart: true,{% if cookiecutter.has_settings.lower().startswith('y') %} - optional: [ISettingRegistry],{% endif %} - activate: (app: JupyterFrontEnd{% if cookiecutter.has_settings.lower().startswith('y') %}, settingRegistry: ISettingRegistry | null{% endif %}) => { - console.log('JupyterLab extension {{ cookiecutter.labextension_name }} is activated!');{% if cookiecutter.has_settings.lower().startswith('y') %} - - if (settingRegistry) { - settingRegistry - .load(plugin.id) - .then(settings => { - console.log('{{ cookiecutter.labextension_name }} settings loaded:', settings.composite); - }) - .catch(reason => { - console.error('Failed to load settings for {{ cookiecutter.labextension_name }}.', reason); - }); - }{% endif %} - - // handles "test" insertion mode, which just shows output in a native - // browser alert. - app.commands.addCommand('ai:insert-test', { - execute: ((context: InsertionContext) => { - alert(context.response.output) - }) as any - }) - } -}; - -export default plugin; diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/base.css b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/base.css deleted file mode 100644 index e11f45777..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/base.css +++ /dev/null @@ -1,5 +0,0 @@ -/* - See the JupyterLab Developer Guide for useful CSS Patterns: - - https://jupyterlab.readthedocs.io/en/stable/developer/css.html -*/ diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/index.css b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/index.css deleted file mode 100644 index 8a7ea29e6..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/index.css +++ /dev/null @@ -1 +0,0 @@ -@import url('base.css'); diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/index.js b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/index.js deleted file mode 100644 index a028a7640..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/style/index.js +++ /dev/null @@ -1 +0,0 @@ -import './base.css'; diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/tsconfig.json b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/tsconfig.json deleted file mode 100644 index bf07c0513..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "composite": true, - "declaration": true, - "esModuleInterop": true, - "incremental": true, - "jsx": "react", - "module": "esnext", - "moduleResolution": "node", - "noEmitOnError": true, - "noImplicitAny": true, - "noUnusedLocals": true, - "preserveWatchOutput": true, - "resolveJsonModule": true, - "outDir": "lib", - "rootDir": "src", - "strict": true, - "strictNullChecks": true, - "skipLibCheck": true, - "target": "es2017", - "types": [{% if cookiecutter.test.lower().startswith('y') %}"jest"{% endif %}] - }, - "include": ["src/*"] -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/README.md b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/README.md deleted file mode 100644 index 3544aec4e..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/README.md +++ /dev/null @@ -1,148 +0,0 @@ -# Integration Testing - -This folder contains the integration tests of the extension. - -They are defined using [Playwright](https://playwright.dev/docs/intro) test runner -and [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) helper. - -The Playwright configuration is defined in [playwright.config.js](./playwright.config.js). - -The JupyterLab server configuration to use for the integration test is defined -in [jupyter_server_test_config.py](./jupyter_server_test_config.py). - -The default configuration will produce video for failing tests and an HTML report. - -## Run the tests - -> All commands are assumed to be executed from the root directory - -To run the tests, you need to: - -1. Compile the extension: - -```sh -jlpm install -jlpm build:prod -``` - -> Check the extension is installed in JupyterLab. - -2. Install test dependencies (needed only once): - -```sh -cd ./ui-tests -jlpm install -jlpm playwright install -cd .. -``` - -3. Execute the [Playwright](https://playwright.dev/docs/intro) tests: - -```sh -cd ./ui-tests -jlpm playwright test -``` - -Test results will be shown in the terminal. In case of any test failures, the test report -will be opened in your browser at the end of the tests execution; see -[Playwright documentation](https://playwright.dev/docs/test-reporters#html-reporter) -for configuring that behavior. - -## Update the tests snapshots - -> All commands are assumed to be executed from the root directory - -If you are comparing snapshots to validate your tests, you may need to update -the reference snapshots stored in the repository. To do that, you need to: - -1. Compile the extension: - -```sh -jlpm install -jlpm build:prod -``` - -> Check the extension is installed in JupyterLab. - -2. Install test dependencies (needed only once): - -```sh -cd ./ui-tests -jlpm install -jlpm playwright install -cd .. -``` - -3. Execute the [Playwright](https://playwright.dev/docs/intro) command: - -```sh -cd ./ui-tests -jlpm playwright test -u -``` - -> Some discrepancy may occurs between the snapshots generated on your computer and -> the one generated on the CI. To ease updating the snapshots on a PR, you can -> type `please update playwright snapshots` to trigger the update by a bot on the CI. -> Once the bot has computed new snapshots, it will commit them to the PR branch. - -## Create tests - -> All commands are assumed to be executed from the root directory - -To create tests, the easiest way is to use the code generator tool of playwright: - -1. Compile the extension: - -```sh -jlpm install -jlpm build:prod -``` - -> Check the extension is installed in JupyterLab. - -2. Install test dependencies (needed only once): - -```sh -cd ./ui-tests -jlpm install -jlpm playwright install -cd .. -``` - -3. Execute the [Playwright code generator](https://playwright.dev/docs/codegen): - -```sh -cd ./ui-tests -jlpm playwright codegen localhost:8888 -``` - -## Debug tests - -> All commands are assumed to be executed from the root directory - -To debug tests, a good way is to use the inspector tool of playwright: - -1. Compile the extension: - -```sh -jlpm install -jlpm build:prod -``` - -> Check the extension is installed in JupyterLab. - -2. Install test dependencies (needed only once): - -```sh -cd ./ui-tests -jlpm install -jlpm playwright install -cd .. -``` - -3. Execute the Playwright tests in [debug mode](https://playwright.dev/docs/debug): - -```sh -cd ./ui-tests -PWDEBUG=1 jlpm playwright test -``` diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/jupyter_server_test_config.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/jupyter_server_test_config.py deleted file mode 100644 index 23d06f6dd..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/jupyter_server_test_config.py +++ /dev/null @@ -1,20 +0,0 @@ -"""Server configuration for integration tests. - -!! Never use this configuration in production because it -opens the server to the world and provide access to JupyterLab -JavaScript objects through the global window variable. -""" -from tempfile import mkdtemp - -c.ServerApp.port = 8888 -c.ServerApp.port_retries = 0 -c.ServerApp.open_browser = False - -c.ServerApp.root_dir = mkdtemp(prefix="galata-test-") -c.ServerApp.token = "" -c.ServerApp.password = "" -c.ServerApp.disable_check_xsrf = True -c.LabApp.expose_app_in_browser = True - -# Uncomment to set server log level to debug level -# c.ServerApp.log_level = "DEBUG" diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/package.json b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/package.json deleted file mode 100644 index 08d07f9a3..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "{{ cookiecutter.labextension_name }}-ui-tests", - "version": "1.0.0", - "description": "JupyterLab {{ cookiecutter.labextension_name }} Integration Tests", - "private": true, - "scripts": { - "start": "jupyter lab --config jupyter_server_test_config.py", - "test": "jlpm playwright test", - "test:update": "jlpm playwright test --update-snapshots" - }, - "devDependencies": { - "@jupyterlab/galata": "^4.3.0" - } -} diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/playwright.config.js b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/playwright.config.js deleted file mode 100644 index 9ece6fa11..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/playwright.config.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Configuration for Playwright using default from @jupyterlab/galata - */ -const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); - -module.exports = { - ...baseConfig, - webServer: { - command: 'jlpm start', - url: 'http://localhost:8888/lab', - timeout: 120 * 1000, - reuseExistingServer: !process.env.CI - } -}; diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/tests/{{cookiecutter.python_name}}.spec.ts b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/tests/{{cookiecutter.python_name}}.spec.ts deleted file mode 100644 index a0c95499e..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/ui-tests/tests/{{cookiecutter.python_name}}.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { expect, test } from '@jupyterlab/galata'; - -/** - * Don't load JupyterLab webpage before running the tests. - * This is required to ensure we capture all log messages. - */ -test.use({ autoGoto: false }); - -test('should emit an activation console message', async ({ page }) => { - const logs: string[] = []; - - page.on('console', message => { - logs.push(message.text()); - }); - - await page.goto(); - - expect( - logs.filter(s => s === 'JupyterLab extension {{ cookiecutter.labextension_name }} is activated!') - ).toHaveLength(1); -}); diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/__init__.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/__init__.py deleted file mode 100644 index db43ba181..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from ._version import __version__ - -# expose engines and tasks on the module root so that they may be declared as -# entrypoints in `pyproject.toml` -from .engine import TestModelEngine -from .tasks import tasks - - -def _jupyter_labextension_paths(): - return [{"src": "labextension", "dest": "{{ cookiecutter.labextension_name }}"}] diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/engine.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/engine.py deleted file mode 100644 index 63066ef07..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/engine.py +++ /dev/null @@ -1,38 +0,0 @@ -from typing import Dict - -from jupyter_ai.engine import BaseModelEngine -from jupyter_ai.models import DescribeTaskResponse - - -class TestModelEngine(BaseModelEngine): - name = "test" - input_type = "txt" - output_type = "txt" - - # BaseModelEngine is also a traitlets.config.Configurable object, so you can - # also expose configurable traits on the class definition like so: - # - # api_key = Unicode( - # config=True, - # help="OpenAI API key", - # allow_none=False - # ) - # - - async def execute( - self, task: DescribeTaskResponse, prompt_variables: Dict[str, str] - ): - # Core method that executes a model when provided with a task - # description and a dictionary of prompt variables. For example, to - # execute an OpenAI text completion model: - # - # prompt = task.prompt_template.format(**prompt_variables) - # openai.api_key = self.api_key - # response = openai.Completion.create( - # model="davinci-002", - # prompt=prompt, - # ... - # ) - # return response['choices'][0]['text'] - - return "test output" diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/tasks.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/tasks.py deleted file mode 100644 index 07226c447..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/tasks.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import List - -from jupyter_ai import DefaultTaskDefinition - -# tasks your AI module exposes by default. declared in `pyproject.toml` as an -# entry point. -tasks: List[DefaultTaskDefinition] = [ - { - "id": "test", - "name": "Test task", - "prompt_template": "{body}", - "modality": "txt2txt", - "insertion_mode": "test", - } -] diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/tests/__init__.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/tests/__init__.py deleted file mode 100644 index edc5557d1..000000000 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.labextension_name}}/{{cookiecutter.python_name}}/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Python unit tests for {{ cookiecutter.python_name }}.""" diff --git a/pyproject.toml b/pyproject.toml index cc45dd977..82f108d42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,3 @@ source_modules = ["jupyter_ai", "jupyter_ai_magics"] forbidden_modules = ["pydantic"] # TODO: get `langchain` to export `ModelMetaclass` to avoid needing this statement ignore_imports = ["jupyter_ai_magics.providers -> pydantic"] - -[tool.pytest.ini_options] -addopts = "--ignore packages/jupyter-ai-module-cookiecutter"