Skip to content

Commit 73d2e6c

Browse files
committed
refactor: Standardize on uv and clean up top-level directory
Remove top-level requirements.txt (duplicated pyproject.toml) and convert all pip-based workflows to uv. Move DOCKER.md into docs/ where it belongs with the rest of the documentation. - Update backend/Dockerfile to use uv sync instead of pip install - Update scripts/run_api.sh and run_ui.sh to use uv - Update docs/DEVELOPER_GUIDE.md to reference uv commands - Add Development Environment section to CLAUDE.md documenting uv usage Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Andre Fredette <afredette@redhat.com>
1 parent 3b2b7b0 commit 73d2e6c

File tree

7 files changed

+48
-97
lines changed

7 files changed

+48
-97
lines changed

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ The recommendation engine uses **multi-criteria scoring** to rank configurations
173173
- `backend/src/recommendation/analyzer.py` - Generates 5 ranked lists
174174
- `backend/src/recommendation/config_finder.py` - Orchestrates scoring during capacity planning
175175

176+
## Development Environment
177+
178+
This project uses **uv** (by Astral) for Python package management. **Do not use `pip` or `pip install`.**
179+
180+
- **Install dependencies**: `uv sync` (reads from `pyproject.toml` + `uv.lock`)
181+
- **Run Python commands**: `uv run python ...` (not bare `python`)
182+
- **Run tools**: `uv run pytest`, `uv run ruff`, `uv run uvicorn`, etc.
183+
- **Add a dependency**: `uv add <package>` (updates `pyproject.toml` and `uv.lock`)
184+
- **Source of truth**: `pyproject.toml` defines all dependencies; there is no top-level `requirements.txt`
185+
- **Makefile targets** already use `uv` — see `make setup-backend`, `make start-backend`, etc.
186+
187+
Note: `ui/requirements.txt` and `simulator/requirements.txt` exist separately for their Docker builds.
188+
176189
## Working with This Repository
177190

178191
### When Modifying Architecture Documents

backend/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ RUN apt-get update && apt-get install -y \
1111
postgresql-client \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
# Copy requirements file
15-
COPY requirements.txt .
14+
# Install uv
15+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1616

17-
# Install Python dependencies
18-
RUN pip install --no-cache-dir -r requirements.txt
17+
# Copy dependency files
18+
COPY pyproject.toml uv.lock ./
19+
20+
# Install Python dependencies (frozen = use lockfile exactly, no-dev = skip dev deps)
21+
RUN uv sync --frozen --no-dev
1922

2023
# Copy backend source code
2124
COPY backend/src ./backend/src
@@ -35,7 +38,7 @@ EXPOSE 8000
3538

3639
# Health check
3740
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
38-
CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1
41+
CMD uv run python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1
3942

4043
# Run the backend API server
41-
CMD ["python", "-m", "uvicorn", "backend.src.api.routes:app", "--host", "0.0.0.0", "--port", "8000"]
44+
CMD ["uv", "run", "uvicorn", "backend.src.api.routes:app", "--host", "0.0.0.0", "--port", "8000"]

docs/DEVELOPER_GUIDE.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -721,32 +721,15 @@ make open-backend
721721

722722
### Manual Backend Installation
723723

724-
**Terminal 1:**
725724
```bash
726-
python -m venv venv
727-
source venv/bin/activate # On Windows: venv\Scripts\activate
728-
729-
# Verify correct venv
730-
which python # Should show: .../venv/bin/python
731-
732-
pip install -r requirements.txt
725+
uv sync
733726
```
734727

735728
### Manual Frontend Installation
736729

737-
**Terminal 2 (or deactivate first):**
730+
The UI shares the same virtual environment as the backend (managed by uv):
738731
```bash
739-
# If in same terminal: deactivate first
740-
deactivate
741-
742-
cd frontend
743-
python -m venv venv
744-
source venv/bin/activate # On Windows: venv\Scripts\activate
745-
746-
# Verify correct venv
747-
which python # Should show: .../frontend/venv/bin/python
748-
749-
pip install -r requirements.txt
732+
uv sync # Same command — all deps are in pyproject.toml
750733
```
751734

752735
### Manual Ollama Model Pull
@@ -863,11 +846,8 @@ ollama pull llama3.2:3b
863846
### Import Errors
864847

865848
```bash
866-
# Make sure you're in the right venv
867-
which python # Should show path to venv
868-
869849
# Reinstall dependencies
870-
pip install -r requirements.txt
850+
uv sync
871851
```
872852

873853
## Manual Kubernetes Cluster Setup
File renamed without changes.

requirements.txt

Lines changed: 0 additions & 31 deletions
This file was deleted.

scripts/run_api.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
#!/bin/bash
22

33
# Start the NeuralNav FastAPI backend
4-
# This script activates the virtual environment and starts the API server
4+
# This script installs dependencies with uv and starts the API server
55

66
set -e
77

88
echo "🚀 Starting NeuralNav API..."
99
echo ""
1010

11-
# Check if virtual environment exists
12-
if [ ! -d "venv" ]; then
13-
echo "❌ Virtual environment not found!"
14-
echo "Creating virtual environment..."
15-
python -m venv venv
11+
# Check if uv is installed
12+
if ! command -v uv &> /dev/null; then
13+
echo "❌ uv not found! Install it: curl -LsSf https://astral.sh/uv/install.sh | sh"
14+
exit 1
1615
fi
1716

18-
# Activate virtual environment
19-
source venv/bin/activate
20-
21-
# Check if requirements are installed
22-
echo "Checking dependencies..."
23-
if ! python -c "import fastapi" &> /dev/null; then
24-
echo "⚠️ Dependencies not found. Installing from requirements.txt..."
25-
pip install -r requirements.txt
26-
echo "✅ Dependencies installed"
27-
echo ""
28-
fi
17+
# Install/sync dependencies
18+
echo "Syncing dependencies..."
19+
uv sync
20+
echo "✅ Dependencies ready"
21+
echo ""
2922

3023
# Check if Ollama is running
3124
echo "Checking if Ollama is running..."
@@ -39,4 +32,4 @@ fi
3932
echo "Starting FastAPI backend on http://localhost:8000..."
4033
echo ""
4134
cd backend
42-
uvicorn src.api.routes:app --host 0.0.0.0 --port 8000 --reload
35+
uv run uvicorn src.api.routes:app --host 0.0.0.0 --port 8000 --reload

scripts/run_ui.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
#!/bin/bash
22

33
# Start the NeuralNav UI
4-
# This script activates the virtual environment and starts the Streamlit UI
4+
# This script installs dependencies with uv and starts the Streamlit UI
55

66
set -e
77

88
echo "🤖 Starting NeuralNav UI..."
99
echo ""
1010

11-
# Check if virtual environment exists
12-
if [ ! -d "venv" ]; then
13-
echo "❌ Virtual environment not found!"
14-
echo "Creating virtual environment..."
15-
python -m venv venv
11+
# Check if uv is installed
12+
if ! command -v uv &> /dev/null; then
13+
echo "❌ uv not found! Install it: curl -LsSf https://astral.sh/uv/install.sh | sh"
14+
exit 1
1615
fi
1716

18-
# Activate virtual environment
19-
source venv/bin/activate
20-
21-
# Check if requirements are installed
22-
echo "Checking dependencies..."
23-
if ! python -c "import streamlit" &> /dev/null; then
24-
echo "⚠️ Dependencies not found. Installing from requirements.txt..."
25-
pip install -r requirements.txt
26-
echo "✅ Dependencies installed"
27-
echo ""
28-
fi
17+
# Install/sync dependencies
18+
echo "Syncing dependencies..."
19+
uv sync
20+
echo "✅ Dependencies ready"
21+
echo ""
2922

3023
# Check if FastAPI backend is running
3124
echo "Checking if FastAPI backend is running..."
@@ -42,4 +35,4 @@ echo ""
4235
# Disable Streamlit's email collection prompt on first run
4336
export STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
4437

45-
streamlit run ui/app.py --server.headless true
38+
uv run streamlit run ui/app.py --server.headless true

0 commit comments

Comments
 (0)