rikunarita-2 commited on
Commit
ffb3dbc
·
verified ·
1 Parent(s): 38dacda

Update backend/main.py

Browse files
Files changed (1) hide show
  1. backend/main.py +3 -5
backend/main.py CHANGED
@@ -9,7 +9,6 @@ from job_queue import JobQueue
9
  import db
10
  import uvicorn
11
 
12
- # ---------- lifespan で起動時処理を定義 ----------
13
  @asynccontextmanager
14
  async def lifespan(app: FastAPI):
15
  # 起動時処理
@@ -22,7 +21,7 @@ app = FastAPI(lifespan=lifespan)
22
  queue = JobQueue()
23
 
24
  class MergeRequest(BaseModel):
25
- model_config = {'protected_namespaces': ()} # "model_" プレフィックス警告を抑制
26
 
27
  model_a_source: str
28
  model_a_id: str
@@ -63,12 +62,11 @@ async def get_queue():
63
  @app.post("/api/upload-dataset")
64
  async def upload_dataset(file: UploadFile = File(...)):
65
  import tempfile
66
- os.makedirs("/data/datasets", exist_ok=True)
67
- path = f"/data/datasets/{file.filename}"
68
  with open(path, "wb") as f:
69
  f.write(await file.read())
70
  return {"path": path}
71
 
72
- # ---------- 起動コード ----------
73
  if __name__ == "__main__":
74
  uvicorn.run("main:app", host="0.0.0.0", port=8000, log_level="info")
 
9
  import db
10
  import uvicorn
11
 
 
12
  @asynccontextmanager
13
  async def lifespan(app: FastAPI):
14
  # 起動時処理
 
21
  queue = JobQueue()
22
 
23
  class MergeRequest(BaseModel):
24
+ model_config = {'protected_namespaces': ()}
25
 
26
  model_a_source: str
27
  model_a_id: str
 
62
  @app.post("/api/upload-dataset")
63
  async def upload_dataset(file: UploadFile = File(...)):
64
  import tempfile
65
+ os.makedirs("/app/data/datasets", exist_ok=True)
66
+ path = f"/app/data/datasets/{file.filename}"
67
  with open(path, "wb") as f:
68
  f.write(await file.read())
69
  return {"path": path}
70
 
 
71
  if __name__ == "__main__":
72
  uvicorn.run("main:app", host="0.0.0.0", port=8000, log_level="info")