Quick Links
pip install batbotor, from source:
git clone https://github.com/Kitware/batbot
cd batbot
pip install -e .To then add GPU acceleration, you need to replace onnxruntime with onnxruntime-gpu:
pip uninstall -y onnxruntime
pip install onnxruntime-gpuYou can run the Gradio demo with:
python app.pyTo run with Docker:
cd batbot
docker run \
-it \
--entrypoint bash \
--rm \
--name batbot \
-v $(pwd):/code \
kitware/batbot:latestor to run the Gradio app:
docker run \
-it \
--rm \
-p 7860:7860 \
--gpus all \
--name batbot \
kitware/batbot:latest \
python3 app.pyTo run with Docker Compose:
version: "3"
services:
batbot:
image: kitware/batbot:latest
command: python3 app.py
ports:
- "7860:7860"
environment:
CLASSIFIER_BATCH_SIZE: 512
restart: unless-stopped
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["all"]
capabilities: [gpu]and run docker compose up -d.
The application can also be built into a Docker image and is hosted on Docker Hub as kitware/batbot:latest. Any time the main branch is updated or a tagged release is made (see the PyPI instructions below), an automated GitHub CD action will build and deploy the newest image to Docker Hub automatically.
To do this manually, use the code below:
docker login
export DOCKER_BUILDKIT=1
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx create --name multi-arch-builder --use
docker buildx build \
-t kitware/batbot:latest \
--platform linux/amd64 \
--push \
.To upload the latest BatBot version to the Python Package Index (PyPI), follow the steps below:
Edit
batbot/__init__.py:65and setVERSIONto the desired versionVERSION = 'X.Y.Z'
Push any changes and version update to the
mainbranch on GitHub and wait for CI tests to passgit pull origin main git commit -am "Release for Version X.Y.Z" git push origin mainTag the
mainbranch as a new release using the SemVer pattern (e.g.,vX.Y.Z)git pull origin main git tag vX.Y.Z git push origin vX.Y.Z
Wait for the automated GitHub CD actions to build and push to PyPI and Docker Hub.
You can run the automated tests in the tests/ folder by running:
pip install -r requirements/optional.txt
pytestYou may also get a coverage percentage by running:
coverage htmland open the coverage/html/index.html file in your browser.
There is Sphinx documentation in the docs/ folder, which can be built by running:
cd docs/
pip install -r requirements/optional.txt
sphinx-build -M html . build/The script uses Python's built-in logging functionality called logging. All print functions are replaced with log.info(), which sends the output to two places:
- the terminal window, and
- the file batbot.log
It's recommended that you use pre-commit to ensure linting procedures are run
on any code you write. See pre-commit.com for more information.
Reference pre-commit's installation instructions for software installation on your OS/platform. After you have the software installed, run pre-commit install on the command line. Now every time you commit to this project's code base the linter procedures will automatically run over the changed files. To run pre-commit on files preemtively from the command line use:
pip install -r requirements/optional.txt
pre-commit run --all-filesThe code base has been formatted by Black. Furthermore, try to conform to PEP8. You should set up your preferred editor to use flake8 as its Python linter, but pre-commit will ensure compliance before a git commit is completed. This will use the flake8 configuration within setup.cfg, which ignores several errors and stylistic considerations. See the setup.cfg file for a full and accurate listing of stylistic codes to ignore.