TanujInsane commited on
Commit ·
4d10011
1
Parent(s): 62c1df2
Fix server/app.py entrypoint for Phase 1 compatibility
Browse files- server/app.py +9 -2
server/app.py
CHANGED
|
@@ -1,14 +1,21 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
|
|
|
|
|
|
| 3 |
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 4 |
|
| 5 |
-
from
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
def main():
|
| 10 |
import uvicorn
|
| 11 |
port = int(os.environ.get("PORT", "7860"))
|
|
|
|
|
|
|
|
|
|
| 12 |
uvicorn.run(app, host="0.0.0.0", port=port, log_level="info")
|
| 13 |
|
| 14 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
+
|
| 4 |
+
# Allow importing from root directory
|
| 5 |
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 6 |
|
| 7 |
+
from openenv.core.env_server import create_app
|
| 8 |
+
from .document_classification_environment import DocumentClassificationEnvironment
|
| 9 |
|
| 10 |
+
# Create the FastAPI application using the OpenEnv factory
|
| 11 |
+
app = create_app(DocumentClassificationEnvironment)
|
| 12 |
|
| 13 |
def main():
|
| 14 |
import uvicorn
|
| 15 |
port = int(os.environ.get("PORT", "7860"))
|
| 16 |
+
# Pre-train models before starting
|
| 17 |
+
from app import ensure_models
|
| 18 |
+
ensure_models()
|
| 19 |
uvicorn.run(app, host="0.0.0.0", port=port, log_level="info")
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|