aastikny commited on
Commit
97e7faf
·
verified ·
1 Parent(s): c83400c

Create server/app.py

Browse files
Files changed (1) hide show
  1. server/app.py +30 -0
server/app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uvicorn
2
+ from fastapi import FastAPI
3
+ import sys
4
+ import os
5
+
6
+ # Force the root directory into the python path
7
+ current_dir = os.path.dirname(os.path.abspath(__file__))
8
+ parent_dir = os.path.dirname(current_dir)
9
+ if parent_dir not in sys.path:
10
+ sys.path.insert(0, parent_dir)
11
+
12
+ import env
13
+
14
+ app = FastAPI(title="SQLite Rescue Environment API")
15
+ env_instance = env.DatabaseRescueEnv()
16
+
17
+ @app.get("/")
18
+ def health_check():
19
+ return {"status": "ok", "environment": "sqlite-rescue-env"}
20
+
21
+ @app.post("/reset")
22
+ def reset_env(task_name: str = "easy_data_cleaning"):
23
+ obs = env_instance.reset(task_name)
24
+ return {"status": "reset", "observation": obs.model_dump()} # Changed .dict() to .model_dump() for Pydantic v2
25
+
26
+ def main():
27
+ uvicorn.run(app, host="0.0.0.0", port=7860) # Port 7860 is the HF default
28
+
29
+ if __name__ == "__main__":
30
+ main()