Skip to content

Commit d69f453

Browse files
authored
Merge pull request #57 from fieldsoftheworld/migrate-to-uv
Migrate to uv
2 parents b196fa9 + 9b37cf2 commit d69f453

10 files changed

Lines changed: 4470 additions & 20635 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,30 @@ jobs:
1313
matrix:
1414
os:
1515
- ubuntu-latest
16-
# - macos-latest # ignore for now
17-
# - windows-latest # ignore for now
1816
steps:
1917
- uses: actions/checkout@v4
2018

21-
- name: Set up Pixi
22-
uses: prefix-dev/setup-pixi@v0.8.3
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
2321
with:
24-
environments: test lint
25-
cache: true
22+
python-version: '3.12'
2623

27-
- name: Run linting and format checks
28-
run: pixi run -e lint lint
24+
- name: Install UV
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
enable-cache: true
2928

30-
- name: Run tests with coverage
31-
run: pixi run -e test test
29+
- name: Install dependencies
30+
run: uv sync --group dev
3231

3332
- name: Check code formatting
34-
run: pixi run -e lint check
33+
run: uv run ruff format --check .
34+
35+
- name: Run linting checks
36+
run: uv run ruff check .
37+
38+
# - name: Type check
39+
# run: uv run mypy server/app
40+
41+
- name: Run tests with coverage
42+
run: cd server && uv run pytest -v --cov=app --cov-report=xml --cov-report=term-missing

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ This project provides a FastAPI-based implementation of the Fields of the World
44

55
## Installation
66

7-
1. Install [Pixi](https://pixi.sh/):
7+
1. Install [UV](https://docs.astral.sh/uv/):
88
```bash
9-
curl -fsSL https://pixi.sh/install.sh | sh # macOS/Linux
10-
# or: brew install pixi
9+
curl -LsSf https://astral.sh/uv/install.sh | sh # macOS/Linux/WSL
10+
# or: brew install uv # macOS
11+
# or: pip install uv # Any platform
1112
```
1213

1314
2. Clone and setup:
1415
```bash
1516
git clone https://github.com/fieldsoftheworld/ftw-inference-api
1617
cd ftw-inference-api
17-
pixi install
18+
uv sync --group dev
1819
```
1920

2021
## Deployment
@@ -33,9 +34,9 @@ curl -L https://raw.githubusercontent.com/fieldsoftheworld/ftw-inference-api/mai
3334
```
3435

3536
This script will:
36-
- Install Pixi package manager
37+
- Install UV package manager
3738
- Clone the repository and checkout the specified branch
38-
- Install dependencies using Pixi production environment
39+
- Install production dependencies using UV
3940
- Enable GPU support in configuration
4041
- Configure a systemd service for automatic startup
4142
- Set up log rotation
@@ -71,22 +72,22 @@ sudo journalctl -u ftw-inference-api --since today # Today's logs
7172
2. **Start services**:
7273
```bash
7374
# Terminal 1: Start DynamoDB Local
74-
pixi run dynamodb-local
75+
docker run -p 8001:8000 amazon/dynamodb-local:latest -jar DynamoDBLocal.jar -sharedDb -inMemory
7576

7677
# Terminal 2: Export AWS credentials (local dev only) and start server
7778
export AWS_ACCESS_KEY_ID="test" AWS_SECRET_ACCESS_KEY="test"
78-
pixi run start
79+
cd server && uv run python run.py --debug
7980
```
8081

8182
### Alternative: Direct Server Start
8283

8384
```bash
84-
pixi run start # Development server with debug mode and auto reload
85+
cd server && uv run python run.py --debug # Development server with debug mode and auto reload
8586
```
8687

87-
Or run directly with options:
88+
Or run with custom options:
8889
```bash
89-
pixi run python server/run.py --host 127.0.0.1 --port 8080 --debug
90+
cd server && uv run python run.py --host 127.0.0.1 --port 8080 --debug
9091
```
9192

9293
**Command-line options:**
@@ -102,7 +103,7 @@ The server loads configuration from `server/config/base.toml` by default. Settin
102103
You can specify a custom configuration file using the `--config` command-line option:
103104

104105
```bash
105-
python run.py --config /path/to/custom_config.toml
106+
cd server && uv run python run.py --config /path/to/custom_config.toml
106107
```
107108

108109
## API Endpoints
@@ -164,20 +165,20 @@ server/
164165
Uses [Ruff](https://docs.astral.sh/ruff/) for linting/formatting and pre-commit hooks for quality checks.
165166

166167
```bash
167-
pixi run lint # Run all pre-commit hooks
168-
pixi run format # Format code
169-
pixi run check # Check without fixing
168+
uv run ruff check . # Check code without fixing
169+
uv run ruff format . # Auto-format code
170+
uv run mypy server/app # Type check
170171
```
171172

172173
Setup pre-commit:
173174
```bash
174-
pixi run pre-commit install
175+
uv run pre-commit install
175176
```
176177

177178
### Running Tests
178179

179180
```bash
180-
pixi run test # All tests with coverage
181+
cd server && uv run pytest -v --cov=app --cov-report=xml --cov-report=term-missing
181182
```
182183

183184
## License

deploy.sh

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Deployment script for Ubuntu Deep Learning AMI instances with Pixi and systemd service
2+
# Deployment script for Ubuntu Deep Learning AMI instances with UV and systemd service
33

44
set -e
55

@@ -31,17 +31,17 @@ sudo apt-get update
3131
sudo apt-get upgrade -y
3232

3333
echo "Installing system dependencies..."
34-
sudo apt-get install -y curl
34+
sudo apt-get install -y curl python3.12 python3.12-venv
3535

36-
echo "Installing Pixi..."
37-
if command -v pixi &> /dev/null; then
38-
echo "Pixi already installed, skipping..."
36+
echo "Installing UV..."
37+
if command -v uv &> /dev/null; then
38+
echo "UV already installed, skipping..."
3939
else
40-
curl -fsSL https://pixi.sh/install.sh | sh
41-
# Add pixi to PATH for current session
42-
export PATH="$HOME/.pixi/bin:$PATH"
40+
curl -LsSf https://astral.sh/uv/install.sh | sh
41+
# Add uv to PATH for current session
42+
export PATH="$HOME/.local/bin:$PATH"
4343
# Add to bashrc for future sessions
44-
echo 'export PATH="$HOME/.pixi/bin:$PATH"' >> ~/.bashrc
44+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
4545
fi
4646

4747
echo "Cloning repository..."
@@ -57,10 +57,10 @@ else
5757
cd ftw-inference-api
5858
fi
5959

60-
echo "Installing Pixi environment..."
61-
# Ensure pixi is in PATH for this command
62-
export PATH="$HOME/.pixi/bin:$PATH"
63-
pixi install
60+
echo "Installing Python dependencies with UV..."
61+
# Ensure uv is in PATH for this command
62+
export PATH="$HOME/.local/bin:$PATH"
63+
uv sync
6464

6565
echo "Creating data directories..."
6666
mkdir -p server/data/uploads server/data/results server/logs
@@ -91,16 +91,8 @@ APP_DIR="$(pwd)"
9191
USER="$(whoami)"
9292
HOME_DIR="$(eval echo ~$USER)"
9393

94-
# Conditionally build the ExecStart command based on the GPU configuration.
95-
# We check the final destination of the production.env file.
96-
BASE_EXEC_START="${HOME_DIR}/.pixi/bin/pixi run --environment production python run.py --host 0.0.0.0 --port 8000"
97-
EXEC_START_CMD=$BASE_EXEC_START
98-
99-
if grep -q "PROCESSING__GPU=null" /etc/ftw-inference-api/production.env; then
100-
echo "GPU is disabled. Applying CONDA_OVERRIDE_GLIBC to the service."
101-
# Prepend the environment variable directly to the command.
102-
EXEC_START_CMD="CONDA_OVERRIDE_GLIBC=2.17 ${BASE_EXEC_START}"
103-
fi
94+
# Build the ExecStart command using UV
95+
BASE_EXEC_START="${HOME_DIR}/.local/bin/uv run python run.py --host 0.0.0.0 --port 8000"
10496

10597
sudo tee /etc/systemd/system/ftw-inference-api.service > /dev/null <<EOF
10698
[Unit]
@@ -113,10 +105,9 @@ User=${USER}
113105
Group=${USER}
114106
WorkingDirectory=${APP_DIR}/server
115107
# Set a reliable PATH for the service environment.
116-
Environment="PATH=${HOME_DIR}/.pixi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
108+
Environment="PATH=${HOME_DIR}/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
117109
EnvironmentFile=/etc/ftw-inference-api/production.env
118-
# Use /bin/sh -c to correctly process the command string with the conditional variable.
119-
ExecStart=/bin/sh -c "${EXEC_START_CMD}"
110+
ExecStart=${BASE_EXEC_START}
120111
Restart=always
121112
RestartSec=10
122113
StandardOutput=journal

0 commit comments

Comments
 (0)