Spaces:
Running
Running
File size: 1,645 Bytes
50231a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # Getting Started
This tutorial runs the classifier API and validates endpoint contracts.
## Prerequisites
- Docker and Docker Compose
- Internet access for external classifier/language services (unless tests are monkeypatched)
Evidence:
- `docker-compose.yml`
- `app/services/classifier_service.py`
- `app/services/language_service.py`
## 1. Prepare environment
```bash
cd classifier-general
cp .env.example .env
```
Evidence:
- `.env.example`
- `app/core/config.py`
## 2. Start API in Docker
```bash
docker compose up --build
```
Service:
- `classifier-api` exposed on `4002`
Evidence:
- `docker-compose.yml`
## 3. Check health
```bash
curl -s http://localhost:4002/health/liveness
curl -s http://localhost:4002/health/readiness
```
Expected:
- `{"status":"ok"}`
- `{"status":"ready","labels_count":<n>}`
Evidence:
- `app/routers/health.py`
## 4. Call text classification
```bash
curl -s -X POST http://localhost:4002/api/classifier \
-H 'content-type: application/json' \
-d '{"text":"This is a long enough sentence for classification."}'
```
Evidence:
- `app/routers/classification.py`
- `app/pipelines/classification_pipeline.py`
## 5. Update labels and verify
```bash
curl -s -X POST http://localhost:4002/configlabel \
-H 'content-type: application/json' \
-d '{"text":"tech,health,legal"}'
curl -s http://localhost:4002/labels
```
Evidence:
- `app/services/label_service.py`
- `app/models/label_config.py`
## 6. Run route contract tests
```bash
docker build -t classifier-general-refactor .
docker run --rm -w /app -e PYTHONPATH=/app classifier-general-refactor pytest -q
```
Evidence:
- `tests/test_routes.py`
|