Spaces:
Runtime error
Runtime error
Update project with docker SDK configuration
Browse files- Dockerfile +14 -0
- README.md +17 -6
- app.py +17 -0
- requirements.txt +49 -0
Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Python 3.10.9 image
|
| 2 |
+
FROM python:3.10.9
|
| 3 |
+
|
| 4 |
+
# Copy the current directory contents into the container at .
|
| 5 |
+
COPY . .
|
| 6 |
+
|
| 7 |
+
# Set the working directory to /
|
| 8 |
+
WORKDIR /
|
| 9 |
+
|
| 10 |
+
# Install requirements.txt
|
| 11 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
| 14 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -1,10 +1,21 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
|
|
|
| 7 |
pinned: false
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Collinear API
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: fastapi
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Collinear API
|
| 13 |
+
|
| 14 |
+
A simple API for the Collinear tool. This API is deployed on Hugging Face Spaces using FastAPI.
|
| 15 |
+
|
| 16 |
+
## Endpoints
|
| 17 |
+
|
| 18 |
+
- `/`: Welcome message
|
| 19 |
+
- `/health`: Health check endpoint
|
| 20 |
+
- `/docs`: Interactive API documentation (provided by Swagger UI)
|
| 21 |
+
- `/redoc`: Alternative API documentation
|
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import uvicorn
|
| 3 |
+
|
| 4 |
+
# Create a FastAPI app for Hugging Face Spaces
|
| 5 |
+
app = FastAPI(title="Collinear API")
|
| 6 |
+
|
| 7 |
+
@app.get("/")
|
| 8 |
+
async def root():
|
| 9 |
+
return {"message": "Welcome to Collinear API"}
|
| 10 |
+
|
| 11 |
+
@app.get("/health")
|
| 12 |
+
async def health():
|
| 13 |
+
return {"status": "healthy"}
|
| 14 |
+
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
# This is used when running locally
|
| 17 |
+
uvicorn.run("app:app", host="0.0.0.0", port=7860, reload=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Core dependencies
|
| 2 |
+
fastapi==0.99.1
|
| 3 |
+
uvicorn==0.22.0
|
| 4 |
+
pydantic==1.10.12
|
| 5 |
+
pydantic-settings>=2.0.0
|
| 6 |
+
tenacity>=8.2.2
|
| 7 |
+
httpx>=0.24.1
|
| 8 |
+
requests>=2.31.0 # For file downloads
|
| 9 |
+
email-validator>=2.0.0 # Required by pydantic for email validation
|
| 10 |
+
python-jose[cryptography]>=3.3.0
|
| 11 |
+
bcrypt>=4.0.0
|
| 12 |
+
passlib>=1.7.4
|
| 13 |
+
mangum>=0.17.0 # For AWS Lambda/Vercel serverless
|
| 14 |
+
|
| 15 |
+
# Task processing
|
| 16 |
+
celery>=5.3.4
|
| 17 |
+
|
| 18 |
+
# Hugging Face integration
|
| 19 |
+
huggingface_hub>=0.20.0
|
| 20 |
+
sentry-sdk>=1.28.1
|
| 21 |
+
|
| 22 |
+
# Database
|
| 23 |
+
postgrest>=0.10.6
|
| 24 |
+
supabase==2.15.1
|
| 25 |
+
|
| 26 |
+
# Caching and async processing
|
| 27 |
+
redis>=4.5.0,<5.0.0
|
| 28 |
+
hiredis>=2.0.0 # C accelerator for redis-py
|
| 29 |
+
setuptools>=65.5.1 # Required by some redis features
|
| 30 |
+
|
| 31 |
+
# Monitoring and observability
|
| 32 |
+
prometheus-client>=0.17.1
|
| 33 |
+
opentelemetry-api>=1.20.0
|
| 34 |
+
opentelemetry-sdk>=1.20.0
|
| 35 |
+
# Fixed version for compatibility
|
| 36 |
+
opentelemetry-exporter-prometheus==0.54b1
|
| 37 |
+
|
| 38 |
+
# Testing
|
| 39 |
+
pytest>=7.4.0
|
| 40 |
+
pytest-asyncio>=0.21.1
|
| 41 |
+
fakeredis>=2.20.0
|
| 42 |
+
pytest-cov>=4.1.0
|
| 43 |
+
freezegun>=1.2.2
|
| 44 |
+
|
| 45 |
+
# Development dependencies
|
| 46 |
+
python-dotenv>=1.0.0
|
| 47 |
+
|
| 48 |
+
# Added from the code block
|
| 49 |
+
gunicorn==21.2.0
|