Spaces:
Running
Running
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.ymlapp/services/classifier_service.pyapp/services/language_service.py
1. Prepare environment
cd classifier-general
cp .env.example .env
Evidence:
.env.exampleapp/core/config.py
2. Start API in Docker
docker compose up --build
Service:
classifier-apiexposed on4002
Evidence:
docker-compose.yml
3. Check health
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
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.pyapp/pipelines/classification_pipeline.py
5. Update labels and verify
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.pyapp/models/label_config.py
6. Run route contract tests
docker build -t classifier-general-refactor .
docker run --rm -w /app -e PYTHONPATH=/app classifier-general-refactor pytest -q
Evidence:
tests/test_routes.py