Abhishek Thakur commited on
Commit
c672c3f
·
1 Parent(s): 908a76b

use basemodel

Browse files
Files changed (1) hide show
  1. competitions/app.py +22 -3
competitions/app.py CHANGED
@@ -11,6 +11,7 @@ from huggingface_hub import hf_hub_download
11
  from huggingface_hub.utils import disable_progress_bars
12
  from huggingface_hub.utils._errors import EntryNotFoundError
13
  from loguru import logger
 
14
 
15
  from competitions import utils
16
  from competitions.errors import AuthenticationError
@@ -48,6 +49,18 @@ if REQUIREMENTS_FNAME:
48
  utils.install_requirements(REQUIREMENTS_FNAME)
49
 
50
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  def run_job_runner():
52
  job_runner = JobRunner(
53
  competition_id=COMPETITION_ID,
@@ -151,7 +164,9 @@ async def get_submission_info(request: Request):
151
 
152
 
153
  @app.post("/leaderboard", response_class=JSONResponse)
154
- async def fetch_leaderboard(request: Request, lb: str):
 
 
155
  if request.session.get("oauth_info") is not None:
156
  user_token = request.session.get("oauth_info").get("access_token")
157
 
@@ -281,7 +296,9 @@ async def new_submission(
281
 
282
 
283
  @app.post("/update_selected_submissions", response_class=JSONResponse)
284
- def update_selected_submissions(request: Request, submission_ids: str):
 
 
285
  if request.session.get("oauth_info") is not None:
286
  user_token = request.session.get("oauth_info")["access_token"]
287
  else:
@@ -308,7 +325,9 @@ def update_selected_submissions(request: Request, submission_ids: str):
308
 
309
 
310
  @app.post("/update_team_name", response_class=JSONResponse)
311
- def update_team_name(request: Request, new_team_name: str):
 
 
312
  if request.session.get("oauth_info") is not None:
313
  user_token = request.session.get("oauth_info")["access_token"]
314
  else:
 
11
  from huggingface_hub.utils import disable_progress_bars
12
  from huggingface_hub.utils._errors import EntryNotFoundError
13
  from loguru import logger
14
+ from pydantic import BaseModel
15
 
16
  from competitions import utils
17
  from competitions.errors import AuthenticationError
 
49
  utils.install_requirements(REQUIREMENTS_FNAME)
50
 
51
 
52
+ class LeaderboardRequest(BaseModel):
53
+ lb: str
54
+
55
+
56
+ class UpdateSelectedSubmissionsRequest(BaseModel):
57
+ submission_ids: str
58
+
59
+
60
+ class UpdateTeamNameRequest(BaseModel):
61
+ new_team_name: str
62
+
63
+
64
  def run_job_runner():
65
  job_runner = JobRunner(
66
  competition_id=COMPETITION_ID,
 
164
 
165
 
166
  @app.post("/leaderboard", response_class=JSONResponse)
167
+ async def fetch_leaderboard(request: Request, body: LeaderboardRequest):
168
+ lb = body.lb
169
+
170
  if request.session.get("oauth_info") is not None:
171
  user_token = request.session.get("oauth_info").get("access_token")
172
 
 
296
 
297
 
298
  @app.post("/update_selected_submissions", response_class=JSONResponse)
299
+ def update_selected_submissions(request: Request, body: UpdateSelectedSubmissionsRequest):
300
+ submission_ids = body.submission_ids
301
+
302
  if request.session.get("oauth_info") is not None:
303
  user_token = request.session.get("oauth_info")["access_token"]
304
  else:
 
325
 
326
 
327
  @app.post("/update_team_name", response_class=JSONResponse)
328
+ def update_team_name(request: Request, body: UpdateTeamNameRequest):
329
+ new_team_name = body.new_team_name
330
+
331
  if request.session.get("oauth_info") is not None:
332
  user_token = request.session.get("oauth_info")["access_token"]
333
  else: