Skip to content

Latest commit

 

History

History
179 lines (117 loc) · 4.85 KB

DEVELOPER_GUIDE.md

File metadata and controls

179 lines (117 loc) · 4.85 KB

Development

Welcome. Thanks for your interest in Panel-Chat-Examples ❤️

You can contribute in many ways, for example, by

  • Giving our project a ⭐ on Github.
  • Sharing knowledge about Panel-Chat-Examples on social media.
  • Contributing very clear and easily reproducible Bug Reports or Feature Requests.
  • Improving our README, docs and developer infrastructure.
  • Improving our collection of examples.

Before you start contributing to our code base or documentation, please make sure your contribution is well described and discussed in a Github Issue.

If you need help to get started, please reach out via Discord.

Contributing TLDR

First time:

  1. Fork the repository https://github.com/holoviz-topics/panel-chat-examples/fork
  2. Run the following commands, updating <YOUR_USERNAME>
git clone https://github.com/<YOUR_USERNAME>/panel-chat-examples
cd panel-chat-examples
pip install hatch
hatch run playwright install chromium
hatch run pre-commit install

On contribution:

  1. Add desired example under examples/
  2. Update tests/ui/inputs.py to include your new example
  3. Then run the following commands, updating <NAME_OF_YOUR_EXAMPLE> and <YOUR_BRANCH_NAME>
hatch run pytest -s -m ui --screenshot on --video on --headed -k <NAME_OF_YOUR_EXAMPLE>
hatch run docs-build
hatch run docs-serve  # to make sure everything looks correct
git checkout -b <YOUR_BRANCH_NAME>
git add commit
git push origin <YOUR_BRANCH_NAME>

Getting Installed

Start by cloning the repository

git clone https://github.com/holoviz-topics/panel-chat-examples
cd panel-chat-examples

If you are not a core contributor you will have to work with your own fork too. See the Github Fork a Repo guide for more details.

We use Hatch to manage the development environment and production build.

Please ensure it's installed on your system with

pip install hatch

Please ensure Playwright browsers are installed.

hatch run playwright install chromium

The first time hatch run ... is run, it will install the required dependencies.

Please ensure pre-commit is installed by running:

hatch run pre-commit install

You will also need to set the below environment variables if it's not already in your environment.

export OPENAI_API_KEY=...

Please note that you will be incurring costs from OPENAI when you run the tests or serve the apps!

Format, lint and type check the code

Execute the following command to apply autoformatting, linting and check typing:

hatch run lint

Run all tests

You can run all the tests with:

hatch run test

Run UI tests

To run the Playwright tests in headed mode (i.e. show the browser) you can run:

hatch run pytest -s -m ui --headed

You can take screenshots or record videos the --screenshot and --video flags.

hatch run pytest -s -m ui --screenshot on --video on --headed

The screenshots and videos can be found in the test-results folder.

You can convert .webm to .mp4 and put them into the docs' assets directory by running postprocess_videos.py. Ensure you have ffmpeg installed on your machine.

hatch run python scripts/postprocess_videos.py

For more info on using Playwright+Panel see the Panel UI tests guide.

Run Load tests

To ensure the apps can be deployed for example to Hugging Face spaces we need them to load fast. We can test the loading time with Locust.

First you need to serve the examples

hatch run panel-serve

Then you should run

hatch run loadtest

Finally you can open http://localhost:8089/ and click "Start swarming"

You should make sure the RPS (Request per seconds) stay above 1. In the image below its 2.3.

Locust

Serve the documentation

You can serve the Mkdocs documentation with livereload via:

hatch run docs-serve

It'll automatically watch for changes in your code.

Publish a new version

You can bump the version, create a commit and associated tag with one command:

hatch version patch
hatch version minor
hatch version major

Your default Git text editor will open so you can add information about the release.

When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft.