Commit
•
b2cc946
1
Parent(s):
c595fd6
Update app.py
Browse files
app.py
CHANGED
@@ -333,13 +333,18 @@ def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
|
333 |
print("ADD CERTIFIED USER")
|
334 |
repo.git_pull()
|
335 |
history = pd.read_csv(os.path.join(CERTIFIED_USERS_DIR, CERTIFIED_USERS_FILENAME))
|
336 |
-
|
|
|
337 |
check = history.loc[history['hf_username'] == hf_username]
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
343 |
history.to_csv(os.path.join(CERTIFIED_USERS_DIR, CERTIFIED_USERS_FILENAME), index=False)
|
344 |
repo.push_to_hub(commit_message="Update certified users list")
|
345 |
|
|
|
333 |
print("ADD CERTIFIED USER")
|
334 |
repo.git_pull()
|
335 |
history = pd.read_csv(os.path.join(CERTIFIED_USERS_DIR, CERTIFIED_USERS_FILENAME))
|
336 |
+
|
337 |
+
# Check if this hf_username is already in our dataset:
|
338 |
check = history.loc[history['hf_username'] == hf_username]
|
339 |
+
if !check.is_empty:
|
340 |
+
new_row = pd.DataFrame({'hf_username': hf_username, 'first_name': first_name, 'last_name': last_name, 'pass_percentage': pass_percentage, 'datetime': time.time()})
|
341 |
+
print("CHECK", check)
|
342 |
+
print("INDEX", check.index[0])
|
343 |
+
history.iloc[check.index[0]] = new_row
|
344 |
+
else:
|
345 |
+
new_row = pd.DataFrame({'hf_username': hf_username, 'first_name': first_name, 'last_name': last_name, 'pass_percentage': pass_percentage, 'datetime': time.time()}, index=[0])
|
346 |
+
history = pd.concat([new_row, history[:]]).reset_index(drop=True)
|
347 |
+
|
348 |
history.to_csv(os.path.join(CERTIFIED_USERS_DIR, CERTIFIED_USERS_FILENAME), index=False)
|
349 |
repo.push_to_hub(commit_message="Update certified users list")
|
350 |
|