Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
voting-system-update (#844)
Browse files- Add logic to upvote a user model (d42f637b9bf5747abfea89cc926ed2deb9171fab)
- Update vote logic upvote submitted (aa2a210ec118f8334c55192011c34f5ddf3e965b)
- Remove requests (376eeca655d33432935412f0a104e64ff665c70b)
- src/display/utils.py +1 -1
- src/submission/submit.py +20 -7
src/display/utils.py
CHANGED
@@ -5,10 +5,10 @@ import logging
|
|
5 |
from datetime import datetime
|
6 |
import pandas as pd
|
7 |
|
8 |
-
|
9 |
# Configure logging
|
10 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
11 |
|
|
|
12 |
# Convert ISO 8601 dates to datetime objects for comparison
|
13 |
def parse_iso8601_datetime(date_str):
|
14 |
if date_str.endswith('Z'):
|
|
|
5 |
from datetime import datetime
|
6 |
import pandas as pd
|
7 |
|
|
|
8 |
# Configure logging
|
9 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
10 |
|
11 |
+
|
12 |
# Convert ISO 8601 dates to datetime objects for comparison
|
13 |
def parse_iso8601_datetime(date_str):
|
14 |
if date_str.endswith('Z'):
|
src/submission/submit.py
CHANGED
@@ -14,6 +14,8 @@ from src.envs import (
|
|
14 |
QUEUE_REPO,
|
15 |
RATE_LIMIT_PERIOD,
|
16 |
RATE_LIMIT_QUOTA,
|
|
|
|
|
17 |
)
|
18 |
from src.leaderboard.filter_models import DO_NOT_SUBMIT_MODELS
|
19 |
from src.submission.check_validity import (
|
@@ -24,9 +26,13 @@ from src.submission.check_validity import (
|
|
24 |
user_submission_permission,
|
25 |
)
|
26 |
|
|
|
|
|
27 |
REQUESTED_MODELS = None
|
28 |
USERS_TO_SUBMISSION_DATES = None
|
29 |
|
|
|
|
|
30 |
@dataclass
|
31 |
class ModelSizeChecker:
|
32 |
model: str
|
@@ -62,7 +68,7 @@ def add_new_eval(
|
|
62 |
use_chat_template: bool,
|
63 |
profile: gr.OAuthProfile | None
|
64 |
):
|
65 |
-
# Login
|
66 |
if profile is None:
|
67 |
return styled_error("Hub Login Required")
|
68 |
|
@@ -87,10 +93,6 @@ def add_new_eval(
|
|
87 |
if model_type is None or model_type == "":
|
88 |
return styled_error("Please select a model type.")
|
89 |
|
90 |
-
# Is user submitting own model?
|
91 |
-
# Check that username in the org.
|
92 |
-
# if org_or_user != profile.username:
|
93 |
-
|
94 |
# Is the user rate limited?
|
95 |
if org_or_user != "":
|
96 |
user_can_submit, error_msg = user_submission_permission(
|
@@ -196,6 +198,17 @@ def add_new_eval(
|
|
196 |
# Remove the local file
|
197 |
os.remove(out_path)
|
198 |
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
201 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
QUEUE_REPO,
|
15 |
RATE_LIMIT_PERIOD,
|
16 |
RATE_LIMIT_QUOTA,
|
17 |
+
VOTES_REPO,
|
18 |
+
VOTES_PATH,
|
19 |
)
|
20 |
from src.leaderboard.filter_models import DO_NOT_SUBMIT_MODELS
|
21 |
from src.submission.check_validity import (
|
|
|
26 |
user_submission_permission,
|
27 |
)
|
28 |
|
29 |
+
from src.voting.vote_system import VoteManager
|
30 |
+
|
31 |
REQUESTED_MODELS = None
|
32 |
USERS_TO_SUBMISSION_DATES = None
|
33 |
|
34 |
+
vote_manager = VoteManager(VOTES_PATH, EVAL_REQUESTS_PATH, VOTES_REPO)
|
35 |
+
|
36 |
@dataclass
|
37 |
class ModelSizeChecker:
|
38 |
model: str
|
|
|
68 |
use_chat_template: bool,
|
69 |
profile: gr.OAuthProfile | None
|
70 |
):
|
71 |
+
# Login required
|
72 |
if profile is None:
|
73 |
return styled_error("Hub Login Required")
|
74 |
|
|
|
93 |
if model_type is None or model_type == "":
|
94 |
return styled_error("Please select a model type.")
|
95 |
|
|
|
|
|
|
|
|
|
96 |
# Is the user rate limited?
|
97 |
if org_or_user != "":
|
98 |
user_can_submit, error_msg = user_submission_permission(
|
|
|
198 |
# Remove the local file
|
199 |
os.remove(out_path)
|
200 |
|
201 |
+
# Always add a vote for the submitted model
|
202 |
+
vote_manager.add_vote(
|
203 |
+
selected_model=model,
|
204 |
+
pending_models_df=None,
|
205 |
+
profile=profile
|
206 |
)
|
207 |
+
print(f"Automatically added a vote for {model} submitted by {username}")
|
208 |
+
|
209 |
+
# Upload votes to the repository
|
210 |
+
vote_manager.upload_votes()
|
211 |
+
|
212 |
+
return styled_message(
|
213 |
+
"Your request and vote has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
|
214 |
+
)
|