Spaces:
Sleeping
Sleeping
jarajpu
commited on
Commit
·
36b88a5
1
Parent(s):
caf5910
enhanced admin panel
Browse files
app.py
CHANGED
|
@@ -9,9 +9,8 @@ from pathlib import Path
|
|
| 9 |
import pandas as pd
|
| 10 |
import pytz
|
| 11 |
import streamlit as st
|
| 12 |
-
from datasets import load_dataset
|
| 13 |
from huggingface_hub import CommitScheduler, HfApi
|
| 14 |
-
from datasets import Dataset
|
| 15 |
|
| 16 |
# File paths as constants
|
| 17 |
PREDICTIONS_CSV = 'dis_predictions.csv'
|
|
@@ -348,10 +347,11 @@ with st.expander("Leaderboard 🏆"):
|
|
| 348 |
############################# Admin Panel ##################################
|
| 349 |
ADMIN_PASSPHRASE = "admin123"
|
| 350 |
|
|
|
|
| 351 |
def fetch_latest_predictions(match_id):
|
| 352 |
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="predictions")
|
| 353 |
# Convert to pandas DataFrame
|
| 354 |
-
df =
|
| 355 |
# Remove duplicate rows
|
| 356 |
df_unique = df.drop_duplicates(subset=['user_name'])
|
| 357 |
predictions = df_unique['train'].filter(lambda example: example['match_id'] == match_id)
|
|
@@ -366,11 +366,11 @@ def save_match_outcomes(outcomes):
|
|
| 366 |
def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
|
| 367 |
# Fetch latest predictions from the dataset repo
|
| 368 |
predictions = fetch_latest_predictions(match_id)
|
| 369 |
-
|
| 370 |
outcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes
|
| 371 |
# Load existing match outcomes and user data from the test split
|
| 372 |
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="leaders")
|
| 373 |
-
users =
|
| 374 |
|
| 375 |
# Directly update or add the match outcome
|
| 376 |
outcome_exists = False
|
|
|
|
| 9 |
import pandas as pd
|
| 10 |
import pytz
|
| 11 |
import streamlit as st
|
| 12 |
+
from datasets import Dataset, load_dataset
|
| 13 |
from huggingface_hub import CommitScheduler, HfApi
|
|
|
|
| 14 |
|
| 15 |
# File paths as constants
|
| 16 |
PREDICTIONS_CSV = 'dis_predictions.csv'
|
|
|
|
| 347 |
############################# Admin Panel ##################################
|
| 348 |
ADMIN_PASSPHRASE = "admin123"
|
| 349 |
|
| 350 |
+
|
| 351 |
def fetch_latest_predictions(match_id):
|
| 352 |
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="predictions")
|
| 353 |
# Convert to pandas DataFrame
|
| 354 |
+
df = pd.DataFrame(dataset)
|
| 355 |
# Remove duplicate rows
|
| 356 |
df_unique = df.drop_duplicates(subset=['user_name'])
|
| 357 |
predictions = df_unique['train'].filter(lambda example: example['match_id'] == match_id)
|
|
|
|
| 366 |
def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
|
| 367 |
# Fetch latest predictions from the dataset repo
|
| 368 |
predictions = fetch_latest_predictions(match_id)
|
| 369 |
+
|
| 370 |
outcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes
|
| 371 |
# Load existing match outcomes and user data from the test split
|
| 372 |
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="leaders")
|
| 373 |
+
users = pd.DataFrame(dataset)
|
| 374 |
|
| 375 |
# Directly update or add the match outcome
|
| 376 |
outcome_exists = False
|