Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,24 +67,6 @@ def on_user_logged_in(token: gr.OAuthToken | None):
|
|
67 |
None, # no token
|
68 |
]
|
69 |
|
70 |
-
def add_certified_user(hf_username, pass_percentage, submission_time):
|
71 |
-
"""
|
72 |
-
Add the certified user to the database
|
73 |
-
"""
|
74 |
-
print("ADD CERTIFIED USER")
|
75 |
-
repo.git_pull()
|
76 |
-
history = pd.read_csv(os.path.join(CERTIFIED_USERS_DIR, CERTIFIED_USERS_FILENAME))
|
77 |
-
|
78 |
-
# Check if this hf_username is already in our dataset:
|
79 |
-
check = history.loc[history['hf_username'] == hf_username]
|
80 |
-
if not check.empty:
|
81 |
-
history = history.drop(labels=check.index[0], axis=0)
|
82 |
-
|
83 |
-
new_row = pd.DataFrame({'hf_username': hf_username, 'pass_percentage': pass_percentage, 'datetime': submission_time}, index=[0])
|
84 |
-
history = pd.concat([new_row, history[:]]).reset_index(drop=True)
|
85 |
-
|
86 |
-
history.to_csv(os.path.join(CERTIFIED_USERS_DIR, CERTIFIED_USERS_FILENAME), index=False)
|
87 |
-
repo.push_to_hub(commit_message="Update certified users list")
|
88 |
|
89 |
def push_results_to_hub(user_answers, token: gr.OAuthToken | None):
|
90 |
"""
|
@@ -114,28 +96,8 @@ def push_results_to_hub(user_answers, token: gr.OAuthToken | None):
|
|
114 |
# check if username already has "username.parquet" in the dataset and download that (or read values directly from dataset viewer if possible)
|
115 |
# instead of replacing the values check if the new score is better than the old one
|
116 |
to_parquet(upload_api,"not-lain/testing-my-upload",user_info["name"],grade,0,0,0)
|
117 |
-
|
118 |
-
|
119 |
-
# # backward compatibility
|
120 |
-
# submission_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
121 |
-
|
122 |
-
# new_ds = Dataset.from_list(user_answers)
|
123 |
-
# new_ds = new_ds.map(
|
124 |
-
# lambda x: {
|
125 |
-
# "username": user_info["name"],
|
126 |
-
# "datetime": submission_time,
|
127 |
-
# "grade": grade,
|
128 |
-
# }
|
129 |
-
# )
|
130 |
-
# new_ds.push_to_hub(repo_id=repo_id, split=user_info["name"])
|
131 |
-
|
132 |
-
# # I'm adding a csv version
|
133 |
-
# # The idea, if the user passed, we create a simple row in a csv
|
134 |
-
# print("ADD CERTIFIED USER")
|
135 |
-
# # Add this user to our database
|
136 |
-
# add_certified_user(user_info["name"], grade, submission_time)
|
137 |
|
138 |
-
|
139 |
|
140 |
|
141 |
|
|
|
67 |
None, # no token
|
68 |
]
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
def push_results_to_hub(user_answers, token: gr.OAuthToken | None):
|
72 |
"""
|
|
|
96 |
# check if username already has "username.parquet" in the dataset and download that (or read values directly from dataset viewer if possible)
|
97 |
# instead of replacing the values check if the new score is better than the old one
|
98 |
to_parquet(upload_api,"not-lain/testing-my-upload",user_info["name"],grade,0,0,0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
gr.Success(f"Your responses have been submitted to the Hub! Final grade: {grade:.1%}")
|
101 |
|
102 |
|
103 |
|