Spaces:
Sleeping
Sleeping
rudraparmar76 commited on
Commit ·
094f0c3
1
Parent(s): 147a45e
added dockerfile and configuration
Browse files- Dockerfile +12 -0
- ame/app/config.py +0 -2
- ame/app/db.py +13 -3
- ame/app/main.py +8 -0
- requirements.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
EXPOSE 7860
|
| 11 |
+
|
| 12 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
ame/app/config.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
DATABASE_URL = "postgresql://postgres:0706@localhost:5432/amep_db"
|
| 2 |
-
|
| 3 |
WEIGHTS = {
|
| 4 |
"diagnostic": 0.5,
|
| 5 |
"assignment": 0.3,
|
|
|
|
|
|
|
|
|
|
| 1 |
WEIGHTS = {
|
| 2 |
"diagnostic": 0.5,
|
| 3 |
"assignment": 0.3,
|
ame/app/db.py
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
|
|
| 1 |
from sqlalchemy import create_engine
|
| 2 |
from sqlalchemy.orm import sessionmaker
|
| 3 |
-
from app.config import DATABASE_URL
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
from sqlalchemy import create_engine
|
| 3 |
from sqlalchemy.orm import sessionmaker
|
|
|
|
| 4 |
|
| 5 |
+
DATABASE_URL = os.environ.get("DATABASE_URL")
|
| 6 |
+
|
| 7 |
+
engine = create_engine(
|
| 8 |
+
DATABASE_URL,
|
| 9 |
+
pool_pre_ping=True
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
SessionLocal = sessionmaker(
|
| 13 |
+
autocommit=False,
|
| 14 |
+
autoflush=False,
|
| 15 |
+
bind=engine
|
| 16 |
+
)
|
ame/app/main.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from app.schemas import AMEEvent,AttendanceUpdate
|
| 3 |
from app.logic import process_event, smart_recommendation,compute_severity
|
|
@@ -205,3 +206,10 @@ def class_risk(class_id: str):
|
|
| 205 |
"risk_summary": summary,
|
| 206 |
"risk_cases": risk_cases
|
| 207 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import uvicorn
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from app.schemas import AMEEvent,AttendanceUpdate
|
| 4 |
from app.logic import process_event, smart_recommendation,compute_severity
|
|
|
|
| 206 |
"risk_summary": summary,
|
| 207 |
"risk_cases": risk_cases
|
| 208 |
}
|
| 209 |
+
|
| 210 |
+
if __name__ == "__main__":
|
| 211 |
+
uvicorn.run(
|
| 212 |
+
"app.main:app",
|
| 213 |
+
host="0.0.0.0",
|
| 214 |
+
port = 7860
|
| 215 |
+
)
|
requirements.txt
CHANGED
|
@@ -3,3 +3,4 @@ uvicorn
|
|
| 3 |
sqlalchemy
|
| 4 |
psycopg2-binary
|
| 5 |
pydantic
|
|
|
|
|
|
| 3 |
sqlalchemy
|
| 4 |
psycopg2-binary
|
| 5 |
pydantic
|
| 6 |
+
python-dotenv
|