mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Use UV to install server for speed, package locks in dev setup, workflows
It's much faster than pip, includes dependency locks via uv.lock and comes with standard convenience utilities (e.g pipx, venv replacement)
This commit is contained in:
12
.github/workflows/pre-commit.yml
vendored
12
.github/workflows/pre-commit.yml
vendored
@@ -35,18 +35,20 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python 3.11
|
- name: Install uv
|
||||||
uses: actions/setup-python@v4
|
uses: astral-sh/setup-uv@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.11
|
version: "latest"
|
||||||
|
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
run: uv python install 3.11
|
||||||
|
|
||||||
- name: ⏬️ Install Dependencies
|
- name: ⏬️ Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update && sudo apt install -y libegl1
|
sudo apt update && sudo apt install -y libegl1
|
||||||
python -m pip install --upgrade pip
|
|
||||||
|
|
||||||
- name: ⬇️ Install Application
|
- name: ⬇️ Install Application
|
||||||
run: pip install --no-cache-dir --upgrade .[dev]
|
run: uv sync --all-extras
|
||||||
|
|
||||||
- name: 🌡️ Validate Application
|
- name: 🌡️ Validate Application
|
||||||
run: pre-commit run --hook-stage manual --all
|
run: pre-commit run --hook-stage manual --all
|
||||||
|
|||||||
19
.github/workflows/pypi.yml
vendored
19
.github/workflows/pypi.yml
vendored
@@ -34,13 +34,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python 3.11
|
- name: Install uv
|
||||||
uses: actions/setup-python@v4
|
uses: astral-sh/setup-uv@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.11.12'
|
version: "latest"
|
||||||
|
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
run: uv python install 3.11
|
||||||
|
|
||||||
- name: ⬇️ Install Server
|
- name: ⬇️ Install Server
|
||||||
run: python -m pip install --upgrade pip && pip install --upgrade .
|
run: uv sync --all-extras
|
||||||
|
|
||||||
- name: ⬇️ Install Web Client
|
- name: ⬇️ Install Web Client
|
||||||
run: |
|
run: |
|
||||||
@@ -51,7 +54,7 @@ jobs:
|
|||||||
- name: 📂 Copy Generated Files
|
- name: 📂 Copy Generated Files
|
||||||
run: |
|
run: |
|
||||||
mkdir -p src/khoj/interface/compiled
|
mkdir -p src/khoj/interface/compiled
|
||||||
cp -r /opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/site-packages/khoj/interface/compiled/* src/khoj/interface/compiled/
|
cp -r $(uv python find-python 3.11)/lib/python3.11/site-packages/khoj/interface/compiled/* src/khoj/interface/compiled/
|
||||||
|
|
||||||
- name: ⚙️ Build Python Package
|
- name: ⚙️ Build Python Package
|
||||||
run: |
|
run: |
|
||||||
@@ -61,13 +64,13 @@ jobs:
|
|||||||
rm -rf dist
|
rm -rf dist
|
||||||
|
|
||||||
# Build PyPI Package
|
# Build PyPI Package
|
||||||
pipx run build
|
uv build
|
||||||
|
|
||||||
- name: 🌡️ Validate Python Package
|
- name: 🌡️ Validate Python Package
|
||||||
run: |
|
run: |
|
||||||
# Validate PyPi Package
|
# Validate PyPi Package
|
||||||
pipx run check-wheel-contents dist/*.whl --ignore W004
|
uv tool run check-wheel-contents dist/*.whl --ignore W004
|
||||||
pipx run twine check dist/*
|
uv tool run twine check dist/*
|
||||||
|
|
||||||
- name: ⏫ Upload Python Package Artifacts
|
- name: ⏫ Upload Python Package Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
15
.github/workflows/run_evals.yml
vendored
15
.github/workflows/run_evals.yml
vendored
@@ -106,10 +106,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Install uv
|
||||||
uses: actions/setup-python@v4
|
uses: astral-sh/setup-uv@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
version: "latest"
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
run: uv python install 3.10
|
||||||
|
|
||||||
- name: Get App Version
|
- name: Get App Version
|
||||||
id: hatch
|
id: hatch
|
||||||
@@ -127,16 +130,14 @@ jobs:
|
|||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: |
|
run: |
|
||||||
# install dependencies
|
# install dependencies
|
||||||
sudo apt update && sudo apt install -y git python3-pip libegl1 sqlite3 libsqlite3-dev libsqlite3-0 ffmpeg libsm6 libxext6
|
sudo apt update && sudo apt install -y git libegl1 sqlite3 libsqlite3-dev libsqlite3-0 ffmpeg libsm6 libxext6
|
||||||
# upgrade pip
|
|
||||||
python -m ensurepip --upgrade && python -m pip install --upgrade pip
|
|
||||||
# install terrarium for code sandbox
|
# install terrarium for code sandbox
|
||||||
git clone https://github.com/khoj-ai/terrarium.git && cd terrarium && npm install --legacy-peer-deps && mkdir pyodide_cache
|
git clone https://github.com/khoj-ai/terrarium.git && cd terrarium && npm install --legacy-peer-deps && mkdir pyodide_cache
|
||||||
|
|
||||||
- name: ⬇️ Install Application
|
- name: ⬇️ Install Application
|
||||||
run: |
|
run: |
|
||||||
sed -i 's/dynamic = \["version"\]/version = "${{ steps.hatch.outputs.version }}"/' pyproject.toml
|
sed -i 's/dynamic = \["version"\]/version = "${{ steps.hatch.outputs.version }}"/' pyproject.toml
|
||||||
pip install --upgrade .[dev]
|
uv sync --all-extras
|
||||||
|
|
||||||
- name: 📝 Run Eval
|
- name: 📝 Run Eval
|
||||||
env:
|
env:
|
||||||
|
|||||||
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
@@ -54,10 +54,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Install uv
|
||||||
uses: actions/setup-python@v4
|
uses: astral-sh/setup-uv@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python_version }}
|
version: "latest"
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python_version }}
|
||||||
|
run: uv python install ${{ matrix.python_version }}
|
||||||
|
|
||||||
- name: ⏬️ Install Dependencies
|
- name: ⏬️ Install Dependencies
|
||||||
env:
|
env:
|
||||||
@@ -71,17 +74,11 @@ jobs:
|
|||||||
run : |
|
run : |
|
||||||
apt install -y postgresql postgresql-client && apt install -y postgresql-server-dev-16
|
apt install -y postgresql postgresql-client && apt install -y postgresql-server-dev-16
|
||||||
|
|
||||||
- name: ⬇️ Install pip
|
|
||||||
run: |
|
|
||||||
apt install -y python3-pip
|
|
||||||
python3 -m ensurepip --upgrade
|
|
||||||
python3 -m pip install --upgrade pip
|
|
||||||
|
|
||||||
- name: ⬇️ Install Application
|
- name: ⬇️ Install Application
|
||||||
env:
|
env:
|
||||||
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu https://abetlen.github.io/llama-cpp-python/whl/cpu"
|
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu https://abetlen.github.io/llama-cpp-python/whl/cpu"
|
||||||
CUDA_VISIBLE_DEVICES: ""
|
CUDA_VISIBLE_DEVICES: ""
|
||||||
run: sed -i 's/dynamic = \["version"\]/version = "0.0.0"/' pyproject.toml && pip install --break-system-packages --upgrade .[dev]
|
run: sed -i 's/dynamic = \["version"\]/version = "0.0.0"/' pyproject.toml && uv sync --all-extras
|
||||||
|
|
||||||
- name: 🧪 Test Application
|
- name: 🧪 Test Application
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ git clone https://github.com/khoj-ai/khoj && cd khoj
|
|||||||
python3 -m venv .venv && source .venv/bin/activate
|
python3 -m venv .venv && source .venv/bin/activate
|
||||||
|
|
||||||
# For MacOS or zsh users run this
|
# For MacOS or zsh users run this
|
||||||
pip install -e '.[dev]'
|
uv sync --all-extras
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="windows" label="Windows">
|
<TabItem value="windows" label="Windows">
|
||||||
@@ -42,7 +42,7 @@ git clone https://github.com/khoj-ai/khoj && cd khoj
|
|||||||
python3 -m venv .venv && .venv\Scripts\activate
|
python3 -m venv .venv && .venv\Scripts\activate
|
||||||
|
|
||||||
# Install Khoj for Development
|
# Install Khoj for Development
|
||||||
pip install -e '.[dev]'
|
uv sync --all-extras
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="linux" label="Linux">
|
<TabItem value="linux" label="Linux">
|
||||||
@@ -54,7 +54,7 @@ git clone https://github.com/khoj-ai/khoj && cd khoj
|
|||||||
python3 -m venv .venv && source .venv/bin/activate
|
python3 -m venv .venv && source .venv/bin/activate
|
||||||
|
|
||||||
# Install Khoj for Development
|
# Install Khoj for Development
|
||||||
pip install -e '.[dev]'
|
uv sync --all-extras
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
@@ -129,7 +129,7 @@ Always run `yarn export` to test your front-end changes on http://localhost:4211
|
|||||||
- Try reactivating the virtual environment and rerunning the `khoj` command.
|
- Try reactivating the virtual environment and rerunning the `khoj` command.
|
||||||
- If it still doesn't work repeat the installation process.
|
- If it still doesn't work repeat the installation process.
|
||||||
2. Python Package Missing
|
2. Python Package Missing
|
||||||
- Use `pip install xxx` and try running the `khoj` command.
|
- Use `uv add xxx` and try running the `khoj` command.
|
||||||
3. Command `createdb` Not Recognized
|
3. Command `createdb` Not Recognized
|
||||||
- make sure path to postgres binaries is included in environment variables. It usually looks something like
|
- make sure path to postgres binaries is included in environment variables. It usually looks something like
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -29,7 +29,13 @@ if [ "$DEVCONTAINER" = true ]; then
|
|||||||
# PATH should already include /opt/venv/bin from Dockerfile
|
# PATH should already include /opt/venv/bin from Dockerfile
|
||||||
|
|
||||||
# Install khoj in editable mode (dependencies already installed)
|
# Install khoj in editable mode (dependencies already installed)
|
||||||
python3 -m pip install -e '.[dev]'
|
# Use uv if available, else fall back to pipx
|
||||||
|
if command -v uv &> /dev/null
|
||||||
|
then
|
||||||
|
uv sync --all-extras
|
||||||
|
else
|
||||||
|
python3 -m pip install -e '.[dev]'
|
||||||
|
fi
|
||||||
|
|
||||||
# Install Web App using cached dependencies
|
# Install Web App using cached dependencies
|
||||||
echo "Installing Web App using cached dependencies..."
|
echo "Installing Web App using cached dependencies..."
|
||||||
@@ -39,7 +45,14 @@ else
|
|||||||
# Standard setup
|
# Standard setup
|
||||||
echo "Installing Server App..."
|
echo "Installing Server App..."
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
python3 -m venv .venv && . .venv/bin/activate && python3 -m pip install -e '.[dev]'
|
if command -v uv &> /dev/null
|
||||||
|
then
|
||||||
|
uv venv
|
||||||
|
uv sync --all-extras
|
||||||
|
else
|
||||||
|
python3 -m venv .venv && . .venv/bin/activate
|
||||||
|
python3 -m pip install -e '.[dev]'
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Installing Web App..."
|
echo "Installing Web App..."
|
||||||
cd "$PROJECT_ROOT/src/interface/web"
|
cd "$PROJECT_ROOT/src/interface/web"
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ sudo -u postgres createdb khoj
|
|||||||
### Install Khoj
|
### Install Khoj
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install -e '.[dev]'
|
uv sync --all-extras
|
||||||
```
|
```
|
||||||
|
|
||||||
### Make Khoj DB migrations
|
### Make Khoj DB migrations
|
||||||
|
|||||||
Reference in New Issue
Block a user